[Lldb-commits] [lldb] [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (PR #70303)
DavidSpickett wrote: Unless there are objections this is going in end of today. https://github.com/llvm/llvm-project/pull/70303 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/70639 When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_variable` like we do for out-of-class definitions. To make it more convenient for debuggers to get to the value of inline static data members, this patch makes sure we emit definitions for static variables with constant initializers the same way we do for other static variables. This also aligns Clang closer to GCC, which produces CU-level definitions for inline statics and also emits these into `.debug_pubnames`. The implementation keeps track of newly created static data members. Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable` with a `DW_AT_const_value` for any of those declarations that didn't end up with a definition in the `DeclCache`. The newly emitted `DW_TAG_variable` will look as follows: ``` 0x007b: DW_TAG_structure_type DW_AT_calling_convention(DW_CC_pass_by_value) DW_AT_name ("Foo") ... 0x008d: DW_TAG_member DW_AT_name("i") DW_AT_type(0x0062 "const int") DW_AT_external(true) DW_AT_declaration (true) DW_AT_const_value (4) Newly added v 0x009a: DW_TAG_variable DW_AT_specification (0x008d "i") DW_AT_const_value (4) DW_AT_linkage_name ("_ZN2t2IiE1iIfEE") ``` >From cbae5425ac00e3cb597827e4b6c402446cc40d9d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:33:07 +0100 Subject: [PATCH 1/2] [clang][DebugInfo][NFC] Add createConstantValueExpression helper This patch factors out the code to create a DIExpression from an APValue into a separate helper function. This will be useful in a follow-up patch where we re-use this logic elsewhere. --- clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++- clang/lib/CodeGen/CGDebugInfo.h | 5 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..9de55e41f885d26 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -5580,25 +5580,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { auto &GV = DeclCache[VD]; if (GV) return; - llvm::DIExpression *InitExpr = nullptr; - if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { -// FIXME: Add a representation for integer constants wider than 64 bits. -if (Init.isInt()) { - const llvm::APSInt &InitInt = Init.getInt(); - std::optional InitIntOpt; - if (InitInt.isUnsigned()) -InitIntOpt = InitInt.tryZExtValue(); - else if (auto tmp = InitInt.trySExtValue(); tmp.has_value()) -// Transform a signed optional to unsigned optional. When cpp 23 comes, -// use std::optional::transform -InitIntOpt = (uint64_t)tmp.value(); - if (InitIntOpt) -InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value()); -} else if (Init.isFloat()) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); - } + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init); llvm::MDTuple *TemplateParameters = nullptr; if (isa(VD)) @@ -5935,3 +5918,28 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const { return llvm::DINode::FlagAllCallsDescribed; } + +llvm::DIExpression * +CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD, + const APValue &Val) { + llvm::DIExpression *ValExpr = nullptr; + if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { +// FIXME: Add a representation for integer constants wider than 64 bits. +if (Val.isInt()) { + const llvm::APSInt &ValInt = Val.getInt(); + std::optional ValIntOpt; + if (ValInt.isUnsigned()) +ValIntOpt = ValInt.tryZExtValue(); + else if (auto tmp = ValInt.trySExtValue(); tmp.has_value()) +// Transform a signed optional to unsigned optional. When cpp 23 comes, +// use std::optional::transform +ValIntOpt = (uint64_t)tmp.value(); +
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
Michael137 wrote: Summing the size of all *.o files in my local debug Clang build increased by `0.7%` with this patch https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
https://github.com/Michael137 ready_for_review https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Michael Buch (Michael137) Changes When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_variable` like we do for out-of-class definitions. To make it more convenient for debuggers to get to the value of inline static data members, this patch makes sure we emit definitions for static variables with constant initializers the same way we do for other static variables. This also aligns Clang closer to GCC, which produces CU-level definitions for inline statics and also emits these into `.debug_pubnames`. The implementation keeps track of newly created static data members. Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable` with a `DW_AT_const_value` for any of those declarations that didn't end up with a definition in the `DeclCache`. The newly emitted `DW_TAG_variable` will look as follows: ``` 0x007b: DW_TAG_structure_type DW_AT_calling_convention(DW_CC_pass_by_value) DW_AT_name ("Foo") ... 0x008d: DW_TAG_member DW_AT_name("i") DW_AT_type(0x0062 "const int") DW_AT_external(true) DW_AT_declaration (true) DW_AT_const_value (4) Newly added v 0x009a: DW_TAG_variable DW_AT_specification (0x008d "i") DW_AT_const_value (4) DW_AT_linkage_name ("_ZN2t2IiE1iIfEE") ``` --- Full diff: https://github.com/llvm/llvm-project/pull/70639.diff 5 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+72-18) - (modified) clang/lib/CodeGen/CGDebugInfo.h (+11) - (modified) clang/test/CodeGenCXX/debug-info-class.cpp (+9-4) - (added) clang/test/CodeGenCXX/debug-info-static-inline-member.cpp (+79) - (modified) lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py (+4-3) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..8b85fb03c05f6e7 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1693,6 +1693,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy, llvm::DIDerivedType *GV = DBuilder.createStaticMemberType( RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Align); StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV); + StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl()); return GV; } @@ -5580,25 +5581,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { auto &GV = DeclCache[VD]; if (GV) return; - llvm::DIExpression *InitExpr = nullptr; - if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { -// FIXME: Add a representation for integer constants wider than 64 bits. -if (Init.isInt()) { - const llvm::APSInt &InitInt = Init.getInt(); - std::optional InitIntOpt; - if (InitInt.isUnsigned()) -InitIntOpt = InitInt.tryZExtValue(); - else if (auto tmp = InitInt.trySExtValue(); tmp.has_value()) -// Transform a signed optional to unsigned optional. When cpp 23 comes, -// use std::optional::transform -InitIntOpt = (uint64_t)tmp.value(); - if (InitIntOpt) -InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value()); -} else if (Init.isFloat()) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); - } + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init); llvm::MDTuple *TemplateParameters = nullptr; if (isa(VD)) @@ -5613,6 +5597,39 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { TemplateParameters, Align)); } +void CGDebugInfo::EmitGlobalVariable(const VarDecl *VD) { + assert(VD->hasInit()); + assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); + if (VD->hasAttr()) +return; + + auto &GV = DeclCache[VD]; + if (GV) +return; + + auto const *InitVal = VD->evaluateValue(); + if (!InitVal) +return; + + llvm::DIFile *Unit = nullptr; + llvm::DIScope *DContext = nullptr; + unsigned LineNo; + StringRef DeclName, LinkageName; + QualType T; + llvm::MDTuple *TemplateParamete
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ constexpr static data members (PR #70641)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/70641 Tests that LLDB can find inline static data members. Relies on the debug-info change in: https://github.com/llvm/llvm-project/pull/70639 >From 7de2335efd85ae6058705a6a6cd9c5b160aef757 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sat, 28 Oct 2023 15:24:47 +0100 Subject: [PATCH] [lldb][test] Add FindGlobalVariables tests for C++ constexpr static data members --- .../TestConstStaticIntegralMember.py | 31 +++ 1 file changed, 31 insertions(+) diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py index 530191e8a37ba1b..8944044d5a265c0 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -113,6 +113,37 @@ def test_class_with_only_const_static(self): self.expect_expr("ClassWithOnlyConstStatic::member", result_value="3") +def check_global_var(self, name: str, expect_type, expect_val): +var_list = self.target().FindGlobalVariables(name, lldb.UINT32_MAX) +self.assertEqual(len(var_list), 1) +varobj = var_list[0] +self.assertEqual(varobj.type.name, expect_type) +self.assertEqual(varobj.value, expect_val) + +# For debug-info produced by older versions of clang, inline static data members +# wouldn't get indexed into the Names accelerator table preventing LLDB from finding +# them. +@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"]) +@expectedFailureAll(debug_info=no_match(["dsym"])) +def test_inline_static_members(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) + +self.check_global_var("A::int_val", "const int", "1") +self.check_global_var("A::int_val_with_address", "const int", "2") +self.check_global_var("A::bool_val", "const bool", "true") +self.check_global_var("A::enum_val", "Enum", "enum_case2") +self.check_global_var("A::enum_bool_val", "EnumBool", "enum_bool_case1") +self.check_global_var("A::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + +self.check_global_var("ClassWithOnlyConstStatic::member", "const int", "3") + +self.check_global_var("ClassWithConstexprs::member", "const int", "2") +self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2") +self.check_global_var("ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + # With older versions of Clang, LLDB fails to evaluate classes with only # constexpr members when dsymutil is enabled @expectedFailureAll( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ constexpr static data members (PR #70641)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Tests that LLDB can find inline static data members. Relies on the debug-info change in: https://github.com/llvm/llvm-project/pull/70639 --- Full diff: https://github.com/llvm/llvm-project/pull/70641.diff 1 Files Affected: - (modified) lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py (+31) ``diff diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py index 530191e8a37ba1b..8944044d5a265c0 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -113,6 +113,37 @@ def test_class_with_only_const_static(self): self.expect_expr("ClassWithOnlyConstStatic::member", result_value="3") +def check_global_var(self, name: str, expect_type, expect_val): +var_list = self.target().FindGlobalVariables(name, lldb.UINT32_MAX) +self.assertEqual(len(var_list), 1) +varobj = var_list[0] +self.assertEqual(varobj.type.name, expect_type) +self.assertEqual(varobj.value, expect_val) + +# For debug-info produced by older versions of clang, inline static data members +# wouldn't get indexed into the Names accelerator table preventing LLDB from finding +# them. +@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"]) +@expectedFailureAll(debug_info=no_match(["dsym"])) +def test_inline_static_members(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) + +self.check_global_var("A::int_val", "const int", "1") +self.check_global_var("A::int_val_with_address", "const int", "2") +self.check_global_var("A::bool_val", "const bool", "true") +self.check_global_var("A::enum_val", "Enum", "enum_case2") +self.check_global_var("A::enum_bool_val", "EnumBool", "enum_bool_case1") +self.check_global_var("A::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + +self.check_global_var("ClassWithOnlyConstStatic::member", "const int", "3") + +self.check_global_var("ClassWithConstexprs::member", "const int", "2") +self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2") +self.check_global_var("ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + # With older versions of Clang, LLDB fails to evaluate classes with only # constexpr members when dsymutil is enabled @expectedFailureAll( `` https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ constexpr static data members (PR #70641)
@@ -113,6 +113,37 @@ def test_class_with_only_const_static(self): self.expect_expr("ClassWithOnlyConstStatic::member", result_value="3") +def check_global_var(self, name: str, expect_type, expect_val): +var_list = self.target().FindGlobalVariables(name, lldb.UINT32_MAX) +self.assertEqual(len(var_list), 1) +varobj = var_list[0] +self.assertEqual(varobj.type.name, expect_type) +self.assertEqual(varobj.value, expect_val) + +# For debug-info produced by older versions of clang, inline static data members +# wouldn't get indexed into the Names accelerator table preventing LLDB from finding +# them. +@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"]) +@expectedFailureAll(debug_info=no_match(["dsym"])) Michael137 wrote: This is a separate issue to do with how variable DIEs are parsed when debug maps are present. Will fix in a follow-up https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff a902ca66428164b4f11dedf1c551393add511271 e3ae0862dd834ca54a096b3154bbbcc5a627014f -- clang/test/CodeGenCXX/debug-info-static-inline-member.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGenCXX/debug-info-class.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 8b85fb03c05f..53a82e53fb29 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -5901,7 +5901,7 @@ void CGDebugInfo::finalize() { } for (auto const *VD : StaticDataMemberDefinitionsToEmit) { -assert (VD->isStaticDataMember()); +assert(VD->isStaticDataMember()); if (auto It = DeclCache.find(VD); It != DeclCache.end()) continue; `` https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ inline static data members (PR #70641)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ inline static data members (PR #70641)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r a902ca66428164b4f11dedf1c551393add511271..7de2335efd85ae6058705a6a6cd9c5b160aef757 lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py `` View the diff from darker here. ``diff --- TestConstStaticIntegralMember.py2023-10-29 10:33:43.00 + +++ TestConstStaticIntegralMember.py2023-10-30 10:12:10.442530 + @@ -140,11 +140,13 @@ self.check_global_var("ClassWithOnlyConstStatic::member", "const int", "3") self.check_global_var("ClassWithConstexprs::member", "const int", "2") self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2") -self.check_global_var("ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") +self.check_global_var( +"ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2" +) # With older versions of Clang, LLDB fails to evaluate classes with only # constexpr members when dsymutil is enabled @expectedFailureAll( debug_info=["dsym"], compiler=["clang"], compiler_version=["<", "14.0"] `` https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70551)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/70551 >From e02939572877cdc839894454a6fab36ab143d924 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:33:07 +0100 Subject: [PATCH 1/4] [clang][DebugInfo][NFC] Add createConstantValueExpression helper This patch factors out the code to create a DIExpression from an APValue into a separate helper function. This will be useful in a follow-up patch where we re-use this logic elsewhere. --- clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++- clang/lib/CodeGen/CGDebugInfo.h | 5 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c430713b0d77d79..a109f140cca80c8 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -5574,25 +5574,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { auto &GV = DeclCache[VD]; if (GV) return; - llvm::DIExpression *InitExpr = nullptr; - if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { -// FIXME: Add a representation for integer constants wider than 64 bits. -if (Init.isInt()) { - const llvm::APSInt &InitInt = Init.getInt(); - std::optional InitIntOpt; - if (InitInt.isUnsigned()) -InitIntOpt = InitInt.tryZExtValue(); - else if (auto tmp = InitInt.trySExtValue(); tmp.has_value()) -// Transform a signed optional to unsigned optional. When cpp 23 comes, -// use std::optional::transform -InitIntOpt = (uint64_t)tmp.value(); - if (InitIntOpt) -InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value()); -} else if (Init.isFloat()) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); - } + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init); llvm::MDTuple *TemplateParameters = nullptr; if (isa(VD)) @@ -5929,3 +5912,28 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const { return llvm::DINode::FlagAllCallsDescribed; } + +llvm::DIExpression * +CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD, + const APValue &Val) { + llvm::DIExpression *ValExpr = nullptr; + if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { +// FIXME: Add a representation for integer constants wider than 64 bits. +if (Val.isInt()) { + const llvm::APSInt &ValInt = Val.getInt(); + std::optional ValIntOpt; + if (ValInt.isUnsigned()) +ValIntOpt = ValInt.tryZExtValue(); + else if (auto tmp = ValInt.trySExtValue(); tmp.has_value()) +// Transform a signed optional to unsigned optional. When cpp 23 comes, +// use std::optional::transform +ValIntOpt = (uint64_t)tmp.value(); + if (ValIntOpt) +ValExpr = DBuilder.createConstantValueExpression(ValIntOpt.value()); +} else if (Val.isFloat()) + ValExpr = DBuilder.createConstantValueExpression( + Val.getFloat().bitcastToAPInt().getZExtValue()); + } + + return ValExpr; +} diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index ae12485850ca775..7b60e94555d0608 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -800,6 +800,11 @@ class CGDebugInfo { llvm::MDTuple *&TemplateParameters, llvm::DIScope *&VDContext); + /// Create a DIExpression representing the constant corresponding + /// to the specified 'Val'. Returns nullptr on failure. + llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD, +const APValue &Val); + /// Allocate a copy of \p A using the DebugInfoNames allocator /// and return a reference to it. If multiple arguments are given the strings /// are concatenated. >From 8060e632025f0c480feff434822df40c3e82810b Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:19:47 +0100 Subject: [PATCH 2/4] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/70639 >From cbae5425ac00e3cb597827e4b6c402446cc40d9d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:33:07 +0100 Subject: [PATCH 1/3] [clang][DebugInfo][NFC] Add createConstantValueExpression helper This patch factors out the code to create a DIExpression from an APValue into a separate helper function. This will be useful in a follow-up patch where we re-use this logic elsewhere. --- clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++- clang/lib/CodeGen/CGDebugInfo.h | 5 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..9de55e41f885d26 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -5580,25 +5580,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { auto &GV = DeclCache[VD]; if (GV) return; - llvm::DIExpression *InitExpr = nullptr; - if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { -// FIXME: Add a representation for integer constants wider than 64 bits. -if (Init.isInt()) { - const llvm::APSInt &InitInt = Init.getInt(); - std::optional InitIntOpt; - if (InitInt.isUnsigned()) -InitIntOpt = InitInt.tryZExtValue(); - else if (auto tmp = InitInt.trySExtValue(); tmp.has_value()) -// Transform a signed optional to unsigned optional. When cpp 23 comes, -// use std::optional::transform -InitIntOpt = (uint64_t)tmp.value(); - if (InitIntOpt) -InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value()); -} else if (Init.isFloat()) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); - } + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init); llvm::MDTuple *TemplateParameters = nullptr; if (isa(VD)) @@ -5935,3 +5918,28 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const { return llvm::DINode::FlagAllCallsDescribed; } + +llvm::DIExpression * +CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD, + const APValue &Val) { + llvm::DIExpression *ValExpr = nullptr; + if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { +// FIXME: Add a representation for integer constants wider than 64 bits. +if (Val.isInt()) { + const llvm::APSInt &ValInt = Val.getInt(); + std::optional ValIntOpt; + if (ValInt.isUnsigned()) +ValIntOpt = ValInt.tryZExtValue(); + else if (auto tmp = ValInt.trySExtValue(); tmp.has_value()) +// Transform a signed optional to unsigned optional. When cpp 23 comes, +// use std::optional::transform +ValIntOpt = (uint64_t)tmp.value(); + if (ValIntOpt) +ValExpr = DBuilder.createConstantValueExpression(ValIntOpt.value()); +} else if (Val.isFloat()) + ValExpr = DBuilder.createConstantValueExpression( + Val.getFloat().bitcastToAPInt().getZExtValue()); + } + + return ValExpr; +} diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index ae12485850ca775..7b60e94555d0608 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -800,6 +800,11 @@ class CGDebugInfo { llvm::MDTuple *&TemplateParameters, llvm::DIScope *&VDContext); + /// Create a DIExpression representing the constant corresponding + /// to the specified 'Val'. Returns nullptr on failure. + llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD, +const APValue &Val); + /// Allocate a copy of \p A using the DebugInfoNames allocator /// and return a reference to it. If multiple arguments are given the strings /// are concatenated. >From e3ae0862dd834ca54a096b3154bbbcc5a627014f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:19:47 +0100 Subject: [PATCH 2/3] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/70639 >From cbae5425ac00e3cb597827e4b6c402446cc40d9d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:33:07 +0100 Subject: [PATCH 1/4] [clang][DebugInfo][NFC] Add createConstantValueExpression helper This patch factors out the code to create a DIExpression from an APValue into a separate helper function. This will be useful in a follow-up patch where we re-use this logic elsewhere. --- clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++- clang/lib/CodeGen/CGDebugInfo.h | 5 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..9de55e41f885d26 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -5580,25 +5580,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { auto &GV = DeclCache[VD]; if (GV) return; - llvm::DIExpression *InitExpr = nullptr; - if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { -// FIXME: Add a representation for integer constants wider than 64 bits. -if (Init.isInt()) { - const llvm::APSInt &InitInt = Init.getInt(); - std::optional InitIntOpt; - if (InitInt.isUnsigned()) -InitIntOpt = InitInt.tryZExtValue(); - else if (auto tmp = InitInt.trySExtValue(); tmp.has_value()) -// Transform a signed optional to unsigned optional. When cpp 23 comes, -// use std::optional::transform -InitIntOpt = (uint64_t)tmp.value(); - if (InitIntOpt) -InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value()); -} else if (Init.isFloat()) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); - } + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init); llvm::MDTuple *TemplateParameters = nullptr; if (isa(VD)) @@ -5935,3 +5918,28 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const { return llvm::DINode::FlagAllCallsDescribed; } + +llvm::DIExpression * +CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD, + const APValue &Val) { + llvm::DIExpression *ValExpr = nullptr; + if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { +// FIXME: Add a representation for integer constants wider than 64 bits. +if (Val.isInt()) { + const llvm::APSInt &ValInt = Val.getInt(); + std::optional ValIntOpt; + if (ValInt.isUnsigned()) +ValIntOpt = ValInt.tryZExtValue(); + else if (auto tmp = ValInt.trySExtValue(); tmp.has_value()) +// Transform a signed optional to unsigned optional. When cpp 23 comes, +// use std::optional::transform +ValIntOpt = (uint64_t)tmp.value(); + if (ValIntOpt) +ValExpr = DBuilder.createConstantValueExpression(ValIntOpt.value()); +} else if (Val.isFloat()) + ValExpr = DBuilder.createConstantValueExpression( + Val.getFloat().bitcastToAPInt().getZExtValue()); + } + + return ValExpr; +} diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index ae12485850ca775..7b60e94555d0608 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -800,6 +800,11 @@ class CGDebugInfo { llvm::MDTuple *&TemplateParameters, llvm::DIScope *&VDContext); + /// Create a DIExpression representing the constant corresponding + /// to the specified 'Val'. Returns nullptr on failure. + llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD, +const APValue &Val); + /// Allocate a copy of \p A using the DebugInfoNames allocator /// and return a reference to it. If multiple arguments are given the strings /// are concatenated. >From e3ae0862dd834ca54a096b3154bbbcc5a627014f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:19:47 +0100 Subject: [PATCH 2/4] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70551)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/70551 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
taalhaataahir0102 wrote: Hi David! I've done the following: 1. Used regex search in the `printRed` format function instead of sub string search. 2. Used ANSI function which you mentioned above https://github.com/llvm/llvm-project/blob/cbbb545c4618969850d88bb008ab7f1c2918d5c3/lldb/include/lldb/Utility/AnsiTerminal.h#L83 3. In the above function, to cater with the bool variable, which takes weather the Use-Color settings are switched on or not, I've passed the CommandInterpreter object to the `PrintRed` function (as it was available to me in the dump functon) and fetching the Use-colors settings option (true or false) through it using: `interpreter->GetDebugger().GetUseColor()` And passing this bool to the ANSI function. 4. Updated the Test-cases by writing a few more test cases which covers some commonly used regex symbols for searching. Now all previous test cases are working fine including `tests/Shell/Commands/command-target-modules-lookup` and in my test cases, I've passed the `use-color = true` option in run commands: `# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' | FileCheck %s --check-prefix CHECK1` Next: Will figure out a way to remove duplicate PriintRed functions in different files. Can you please confirm if passing the pointer to `CommandInterpreter` object in `PrintRed` function to get the use-color options a good idea? Are the test cases good enough and also does the future plan sounds Okay? https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adapt code to Python 3.13 (PR #70445)
https://github.com/tuliom closed https://github.com/llvm/llvm-project/pull/70445 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b2929be - [lldb] Adapt code to Python 3.13 (#70445)
Author: Tulio Magno Quites Machado Filho Date: 2023-10-30T08:55:34-03:00 New Revision: b2929bebb6ce8d75acab4f2fde43213673cb6010 URL: https://github.com/llvm/llvm-project/commit/b2929bebb6ce8d75acab4f2fde43213673cb6010 DIFF: https://github.com/llvm/llvm-project/commit/b2929bebb6ce8d75acab4f2fde43213673cb6010.diff LOG: [lldb] Adapt code to Python 3.13 (#70445) 1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads Both of these functions were removed in Python 3.13 [1] after being deprecated since Python 3.9. According to "What's new in Python 3.13" document [1]: Since Python 3.7, Py_Initialize() always creates the GIL: calling PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized() always returned non-zero. 2. Replace _Py_IsFinalizing() with Py_IsFinalizing(). [1] https://docs.python.org/3.13/whatsnew/3.13.html Added: Modified: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Removed: diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 9ac840a4a102da3..fe3438c42471543 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -71,7 +71,9 @@ Expected python::As(Expected &&obj) { } static bool python_is_finalizing() { -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 +#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3) + return Py_IsFinalizing(); +#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 return _Py_Finalizing != nullptr; #else return _Py_IsFinalizing(); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index a57c8e4984ad8a8..968cc8ca03001e5 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -179,18 +179,27 @@ struct InitializePythonRAII { return; #endif +// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in +// Python 3.13. It has been returning `true` always since Python 3.7. +#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3) if (PyEval_ThreadsInitialized()) { +#endif Log *log = GetLog(LLDBLog::Script); m_was_already_initialized = true; m_gil_state = PyGILState_Ensure(); LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n", m_gil_state == PyGILState_UNLOCKED ? "un" : ""); + +// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in +// Python 3.13. +#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3) return; } // InitThreads acquires the GIL if it hasn't been called before. PyEval_InitThreads(); +#endif } PyGILState_STATE m_gil_state = PyGILState_UNLOCKED; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
DavidSpickett wrote: > Can you please confirm if passing the pointer to CommandInterpreter object in > PrintRed function to get the use-color options a good idea? Yes but it can be better :) See my comments. > Are the test cases good enough and also does the future plan sounds Okay? I suggested one more test case, otherwise they look good to me. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [sanitizer][msan] fix AArch64 vararg support for KMSAN (PR #70659)
https://github.com/ramosian-glider created https://github.com/llvm/llvm-project/pull/70659 Cast StackSaveAreaPtr, GrRegSaveAreaPtr, VrRegSaveAreaPtr to pointers to fix assertions in getShadowOriginPtrKernel(). Fixes: https://github.com/llvm/llvm-project/issues/69738 Patch by Mark Johnston. >From 3be71f474ee11326567458c8145c3b4e56031189 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Mon, 30 Oct 2023 12:18:47 +0100 Subject: [PATCH] [sanitizer][msan] fix AArch64 vararg support for KMSAN Cast StackSaveAreaPtr, GrRegSaveAreaPtr, VrRegSaveAreaPtr to pointers to fix assertions in getShadowOriginPtrKernel(). Fixes: https://github.com/llvm/llvm-project/issues/69738 Patch by Mark Johnston. --- .../Instrumentation/MemorySanitizer.cpp | 10 ++-- .../MemorySanitizer/AArch64/vararg-kmsan.ll | 51 +++ .../MemorySanitizer/X86/vararg.ll | 1 + 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index e72db2d9d770eef..315d7c96ec65390 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -5258,21 +5258,25 @@ struct VarArgAArch64Helper : public VarArgHelper { // we need to adjust the offset for both GR and VR fields based on // the __{gr,vr}_offs value (since they are stores based on incoming // named arguments). + Type *RegSaveAreaPtrTy = IRB.getInt8PtrTy(); // Read the stack pointer from the va_list. - Value *StackSaveAreaPtr = getVAField64(IRB, VAListTag, 0); + Value *StackSaveAreaPtr = + IRB.CreateIntToPtr(getVAField64(IRB, VAListTag, 0), RegSaveAreaPtrTy); // Read both the __gr_top and __gr_off and add them up. Value *GrTopSaveAreaPtr = getVAField64(IRB, VAListTag, 8); Value *GrOffSaveArea = getVAField32(IRB, VAListTag, 24); - Value *GrRegSaveAreaPtr = IRB.CreateAdd(GrTopSaveAreaPtr, GrOffSaveArea); + Value *GrRegSaveAreaPtr = IRB.CreateIntToPtr( + IRB.CreateAdd(GrTopSaveAreaPtr, GrOffSaveArea), RegSaveAreaPtrTy); // Read both the __vr_top and __vr_off and add them up. Value *VrTopSaveAreaPtr = getVAField64(IRB, VAListTag, 16); Value *VrOffSaveArea = getVAField32(IRB, VAListTag, 28); - Value *VrRegSaveAreaPtr = IRB.CreateAdd(VrTopSaveAreaPtr, VrOffSaveArea); + Value *VrRegSaveAreaPtr = IRB.CreateIntToPtr( + IRB.CreateAdd(VrTopSaveAreaPtr, VrOffSaveArea), RegSaveAreaPtrTy); // It does not know how many named arguments is being used and, on the // callsite all the arguments were saved. Since __gr_off is defined as diff --git a/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll b/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll new file mode 100644 index 000..2189424cd76faaf --- /dev/null +++ b/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll @@ -0,0 +1,51 @@ +; RUN: opt < %s -S -passes=msan -msan-kernel=1 2>&1 | FileCheck %s + +target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.__va_list = type { ptr, ptr, ptr, i32, i32 } + +define i32 @foo(i32 %guard, ...) { + %vl = alloca %struct.__va_list, align 8 + call void @llvm.lifetime.start.p0(i64 32, ptr %vl) + call void @llvm.va_start(ptr %vl) + call void @llvm.va_end(ptr %vl) + call void @llvm.lifetime.end.p0(i64 32, ptr %vl) + ret i32 0 +} + +; First check if the variadic shadow values are saved in stack with correct +; size (192 is total of general purpose registers size, 64, plus total of +; floating-point registers size, 128). + +; CHECK-LABEL: @foo +; CHECK: [[A:%.*]] = load {{.*}} ptr %va_arg_overflow_size +; CHECK: [[B:%.*]] = add i64 192, [[A]] +; CHECK: alloca {{.*}} [[B]] + +; We expect three memcpy operations: one for the general purpose registers, +; one for floating-point/SIMD ones, and one for thre remaining arguments. + +; Propagate the GR shadow values on for the va_list::__gp_top, adjust the +; offset in the __msan_va_arg_tls based on va_list:__gp_off, and finally +; issue the memcpy. +; CHECK: [[GRP:%.*]] = getelementptr inbounds i8, ptr {{%.*}}, i64 {{%.*}} +; CHECK: [[GRSIZE:%.*]] = sub i64 64, {{%.*}} +; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 {{%.*}}, ptr align 8 [[GRP]], i64 [[GRSIZE]], i1 false) + +; Propagate the VR shadow values on for the va_list::__vr_top, adjust the +; offset in the __msan_va_arg_tls based on va_list:__vr_off, and finally +; issue the memcpy. +; CHECK: [[VRP:%.*]] = getelementptr inbounds i8, ptr {{%.*}}, i64 {{%.*}} +; CHECK: [[VRSIZE:%.*]] = sub i64 128, {{%.*}} +; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 {{%.*}}, ptr align 8 [[VRP]], i64 [[VRSIZE]], i1 false) + +; Copy the
[Lldb-commits] [lldb] [sanitizer][msan] fix AArch64 vararg support for KMSAN (PR #70659)
llvmbot wrote: @llvm/pr-subscribers-compiler-rt-sanitizer Author: Alexander Potapenko (ramosian-glider) Changes Cast StackSaveAreaPtr, GrRegSaveAreaPtr, VrRegSaveAreaPtr to pointers to fix assertions in getShadowOriginPtrKernel(). Fixes: https://github.com/llvm/llvm-project/issues/69738 Patch by Mark Johnston. --- Full diff: https://github.com/llvm/llvm-project/pull/70659.diff 3 Files Affected: - (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+7-3) - (added) llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll (+51) - (modified) llvm/test/Instrumentation/MemorySanitizer/X86/vararg.ll (+1) ``diff diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index e72db2d9d770eef..315d7c96ec65390 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -5258,21 +5258,25 @@ struct VarArgAArch64Helper : public VarArgHelper { // we need to adjust the offset for both GR and VR fields based on // the __{gr,vr}_offs value (since they are stores based on incoming // named arguments). + Type *RegSaveAreaPtrTy = IRB.getInt8PtrTy(); // Read the stack pointer from the va_list. - Value *StackSaveAreaPtr = getVAField64(IRB, VAListTag, 0); + Value *StackSaveAreaPtr = + IRB.CreateIntToPtr(getVAField64(IRB, VAListTag, 0), RegSaveAreaPtrTy); // Read both the __gr_top and __gr_off and add them up. Value *GrTopSaveAreaPtr = getVAField64(IRB, VAListTag, 8); Value *GrOffSaveArea = getVAField32(IRB, VAListTag, 24); - Value *GrRegSaveAreaPtr = IRB.CreateAdd(GrTopSaveAreaPtr, GrOffSaveArea); + Value *GrRegSaveAreaPtr = IRB.CreateIntToPtr( + IRB.CreateAdd(GrTopSaveAreaPtr, GrOffSaveArea), RegSaveAreaPtrTy); // Read both the __vr_top and __vr_off and add them up. Value *VrTopSaveAreaPtr = getVAField64(IRB, VAListTag, 16); Value *VrOffSaveArea = getVAField32(IRB, VAListTag, 28); - Value *VrRegSaveAreaPtr = IRB.CreateAdd(VrTopSaveAreaPtr, VrOffSaveArea); + Value *VrRegSaveAreaPtr = IRB.CreateIntToPtr( + IRB.CreateAdd(VrTopSaveAreaPtr, VrOffSaveArea), RegSaveAreaPtrTy); // It does not know how many named arguments is being used and, on the // callsite all the arguments were saved. Since __gr_off is defined as diff --git a/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll b/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll new file mode 100644 index 000..2189424cd76faaf --- /dev/null +++ b/llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg-kmsan.ll @@ -0,0 +1,51 @@ +; RUN: opt < %s -S -passes=msan -msan-kernel=1 2>&1 | FileCheck %s + +target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-gnu" + +%struct.__va_list = type { ptr, ptr, ptr, i32, i32 } + +define i32 @foo(i32 %guard, ...) { + %vl = alloca %struct.__va_list, align 8 + call void @llvm.lifetime.start.p0(i64 32, ptr %vl) + call void @llvm.va_start(ptr %vl) + call void @llvm.va_end(ptr %vl) + call void @llvm.lifetime.end.p0(i64 32, ptr %vl) + ret i32 0 +} + +; First check if the variadic shadow values are saved in stack with correct +; size (192 is total of general purpose registers size, 64, plus total of +; floating-point registers size, 128). + +; CHECK-LABEL: @foo +; CHECK: [[A:%.*]] = load {{.*}} ptr %va_arg_overflow_size +; CHECK: [[B:%.*]] = add i64 192, [[A]] +; CHECK: alloca {{.*}} [[B]] + +; We expect three memcpy operations: one for the general purpose registers, +; one for floating-point/SIMD ones, and one for thre remaining arguments. + +; Propagate the GR shadow values on for the va_list::__gp_top, adjust the +; offset in the __msan_va_arg_tls based on va_list:__gp_off, and finally +; issue the memcpy. +; CHECK: [[GRP:%.*]] = getelementptr inbounds i8, ptr {{%.*}}, i64 {{%.*}} +; CHECK: [[GRSIZE:%.*]] = sub i64 64, {{%.*}} +; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 {{%.*}}, ptr align 8 [[GRP]], i64 [[GRSIZE]], i1 false) + +; Propagate the VR shadow values on for the va_list::__vr_top, adjust the +; offset in the __msan_va_arg_tls based on va_list:__vr_off, and finally +; issue the memcpy. +; CHECK: [[VRP:%.*]] = getelementptr inbounds i8, ptr {{%.*}}, i64 {{%.*}} +; CHECK: [[VRSIZE:%.*]] = sub i64 128, {{%.*}} +; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 {{%.*}}, ptr align 8 [[VRP]], i64 [[VRSIZE]], i1 false) + +; Copy the remaining shadow values on the va_list::__stack position (it is +; on the constant offset of 192 from __msan_va_arg_tls). +; CHECK: [[STACK:%.*]] = getelementptr inbounds i8, ptr {{%.*}}, i32 192 +; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 16 {{%.*}}, ptr align 16 [[STACK]], i64 {{%.*}}, i1 false) + +declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
[Lldb-commits] [lldb] [sanitizer][msan] fix AArch64 vararg support for KMSAN (PR #70659)
https://github.com/ramosian-glider closed https://github.com/llvm/llvm-project/pull/70659 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [AMDGPU] Select 64-bit imm moves if can be encoded as 32 bit operand (PR #70395)
https://github.com/rampitec closed https://github.com/llvm/llvm-project/pull/70395 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/nmustakin updated https://github.com/llvm/llvm-project/pull/70667 >From 153c6d812939cd23bb71e53c71378117ed5b23c7 Mon Sep 17 00:00:00 2001 From: Nafis Mustakin Date: Mon, 30 Oct 2023 07:50:59 -0700 Subject: [PATCH] Add memory diff dump for kernel record-replay --- .../PluginInterface/PluginInterface.cpp | 65 +++ 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp index 0243f0205dbf0e5..8469e8eaf1593cd 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp @@ -83,7 +83,7 @@ struct RecordReplayTy { return Plugin::success(); } - void dumpDeviceMemory(StringRef Filename) { + void dumpDeviceMemory(StringRef Filename, bool saveDiff) { ErrorOr> DeviceMemoryMB = WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); if (!DeviceMemoryMB) @@ -93,15 +93,58 @@ struct RecordReplayTy { MemoryStart, MemorySize, nullptr); if (Err) report_fatal_error("Error retrieving data for target pointer"); - -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); -std::error_code EC; -raw_fd_ostream OS(Filename, EC); -if (EC) + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if(EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; -OS.close(); + +if (saveDiff){ + //Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + //read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if(std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if(InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + //get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + //compare pre-record memorydump to current contents + size_t i = 0; + while(i < MemorySize){ +//if mismatch found, create a new diff line +//current format - location, size, differences ... +if(InputBufferContents[i] != DeviceMemoryContents[i]){ + OS << i << " "; //marks the start offset + SmallVector modified; + modified.push_back(DeviceMemoryContents[i]); + size_t j = 1; + //loop until next match is found + while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){ +modified.push_back(DeviceMemoryContents[i+j]); +j++; + } + OS << j << " "; //marks the length of the mismatching sequence + for(const auto &value : modified) +OS << value << " "; + OS << "\n"; + i+=j+1; +} +else i++; + } +} +else { + StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); + OS << DeviceMemory; +} +OS.close(); } public: @@ -209,7 +252,7 @@ struct RecordReplayTy { JsonKernelInfo["ArgOffsets"] = json::Value(std::move(JsonArgOffsets)); SmallString<128> MemoryFilename = {Name, ".memory"}; -dumpDeviceMemory(MemoryFilename); +dumpDeviceMemory(MemoryFilename, false); SmallString<128> GlobalsFilename = {Name, ".globals"}; dumpGlobals(GlobalsFilename, Image); @@ -227,7 +270,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, true); } void *alloc(uint64_t Size) { @@ -1307,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs, GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets, KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0], KernelArgs.Tripcount); - + if (RecordReplay.isRecording()) RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6a62707c048e16ce9bad37ed8e3520799139436b 153c6d812939cd23bb71e53c71378117ed5b23c7 -- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp `` View the diff from clang-format here. ``diff diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp index 8469e8eaf159..062165112317 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp @@ -93,58 +93,58 @@ private: MemoryStart, MemorySize, nullptr); if (Err) report_fatal_error("Error retrieving data for target pointer"); - -std::error_code EC; -raw_fd_ostream OS(Filename, EC); -if(EC) + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); - -if (saveDiff){ - //Get the pre-record memory filename + +if (saveDiff) { + // Get the pre-record memory filename SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; - //read the pre-record memorydump - auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); - if(std::error_code EC = InputFileBuffer.getError()) + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) report_fatal_error("Error reading pre-record device memory"); - - StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); - if(InputBufferContents.size() != MemorySize) + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) report_fatal_error("Error: Pre-record device memory size mismatch"); - - //get current memory contents + + // get current memory contents StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), DeviceMemoryMB.get()->getBuffer().size()); - - //compare pre-record memorydump to current contents + + // compare pre-record memorydump to current contents size_t i = 0; - while(i < MemorySize){ -//if mismatch found, create a new diff line -//current format - location, size, differences ... -if(InputBufferContents[i] != DeviceMemoryContents[i]){ - OS << i << " "; //marks the start offset - SmallVector modified; + while (i < MemorySize) { +// if mismatch found, create a new diff line +// current format - location, size, differences ... +if (InputBufferContents[i] != DeviceMemoryContents[i]) { + OS << i << " "; // marks the start offset + SmallVector modified; modified.push_back(DeviceMemoryContents[i]); size_t j = 1; - //loop until next match is found - while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){ -modified.push_back(DeviceMemoryContents[i+j]); + // loop until next match is found + while (InputBufferContents[i + j] != DeviceMemoryContents[i + j]) { +modified.push_back(DeviceMemoryContents[i + j]); j++; } - OS << j << " "; //marks the length of the mismatching sequence - for(const auto &value : modified) + OS << j << " "; // marks the length of the mismatching sequence + for (const auto &value : modified) OS << value << " "; - OS << "\n"; - i+=j+1; -} -else i++; + OS << "\n"; + i += j + 1; +} else + i++; } -} -else { - StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); +} else { + StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), + MemorySize); OS << DeviceMemory; } -OS.close(); +OS.close(); } public: @@ -1350,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs, GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets, KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0], KernelArgs.Tripcount); - + if (RecordReplay.isRecording()) RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage()); `` https://github.com/llvm/llvm-project/pull/70667
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
@@ -274,7 +317,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, true); shiltian wrote: ```suggestion dumpDeviceMemory(OutputFilename, /*saveDiff*/true); ``` https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bb9dced - [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (#70303)
Author: David Spickett Date: 2023-10-30T15:45:40Z New Revision: bb9dced2d3b479fc47221a25eae496f15c573c3c URL: https://github.com/llvm/llvm-project/commit/bb9dced2d3b479fc47221a25eae496f15c573c3c DIFF: https://github.com/llvm/llvm-project/commit/bb9dced2d3b479fc47221a25eae496f15c573c3c.diff LOG: [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (#70303) For most register sets, if it was enabled this meant you could use it, it was present in the process. There was no present but turned off state. So "enabled" made sense. Then ZA came along (and soon to be ZT0) where ZA can be present in the hardware when you have SME, but ZA itself can be made inactive. This means that "IsZAEnabled()" doesn't mean is it active, it means do you have SME. Which is very confusing when we actually want to know if ZA is active. So instead say "IsZAPresent", to make these checks more specific. For things that can't be made inactive, present will imply "active" as they're never inactive. Added: Modified: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp Removed: diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index b5210c368144206..22aa2f3a920945d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -166,10 +166,10 @@ NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64( m_tls_is_valid = false; // SME adds the tpidr2 register - m_tls_size = GetRegisterInfo().IsSSVEEnabled() ? sizeof(m_tls_regs) + m_tls_size = GetRegisterInfo().IsSSVEPresent() ? sizeof(m_tls_regs) : sizeof(m_tls_regs.tpidr_reg); - if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) + if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent()) m_sve_state = SVEState::Unknown; else m_sve_state = SVEState::Disabled; @@ -609,8 +609,7 @@ NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) { if (error.Fail()) return error; - // Here this means, does the system have ZA, not whether it is active. - if (GetRegisterInfo().IsZAEnabled()) { + if (GetRegisterInfo().IsZAPresent()) { error = ReadZAHeader(); if (error.Fail()) return error; @@ -628,7 +627,7 @@ NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) { } // If SVE is enabled we need not copy FPR separately. - if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) { + if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent()) { // Store mode and register data. cached_size += sizeof(RegisterSetType) + sizeof(m_sve_state) + GetSVEBufferSize(); @@ -640,7 +639,7 @@ NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) { if (error.Fail()) return error; - if (GetRegisterInfo().IsMTEEnabled()) { + if (GetRegisterInfo().IsMTEPresent()) { cached_size += sizeof(RegisterSetType) + GetMTEControlSize(); error = ReadMTEControl(); if (error.Fail()) @@ -708,7 +707,7 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( // constants and the functions vec_set_vector_length, sve_set_common and // za_set in the Linux Kernel. - if ((m_sve_state != SVEState::Streaming) && GetRegisterInfo().IsZAEnabled()) { + if ((m_sve_state != SVEState::Streaming) && GetRegisterInfo().IsZAPresent()) { // Use the header size not the buffer size, as we may be using the buffer // for fake data, which we do not want to write out. assert(m_za_header.size <= GetZABufferSize()); @@ -716,7 +715,7 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( m_za_header.size); } - if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) { + if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent()) { dst = AddRegisterSetType(dst, RegisterSetType::SVE); *(reinterpret_cast(dst)) = m_sve_state; dst += sizeof(m_sve_state); @@ -726,13 +725,13 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( GetFPRSize()); } - if ((m_sve_state == SVEState::Streaming) && GetRegisterInfo().IsZAEnabled()) { + if ((m_sve_state == SVEState::Streaming) && GetRegisterInfo().IsZAPresent()) { assert(m_za_header.size <= GetZABufferSize()); dst = AddSavedRegisters(dst, RegisterSetType::SME, GetZABuffer(), m_za_header.size); } - if (GetRegisterInfo().IsMTEEnabled())
[Lldb-commits] [lldb] [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (PR #70303)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/70303 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
Michael137 wrote: This could also help with the type merging issues discussed in https://github.com/llvm/llvm-project/pull/68721#issuecomment-1764685418 https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/70639 >From 18db082fc5008283f77cc98d9c733a47c63b7096 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Oct 2023 16:19:47 +0100 Subject: [PATCH 1/3] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an LLDB user asks for the value of a static data member, LLDB starts by searching the Names accelerator table for the corresponding variable definition DIE. For static data members with out-of-class definitions that works fine, because those get represented as global variables with a location and making them eligible to be added to the Names table. However, in-class definitions won’t get indexed because we usually don't emit global variables for them. So in DWARF we end up with a single `DW_TAG_member` that usually holds the constant initializer. But we don't get a corresponding CU-level `DW_TAG_variable` like we do for out-of-class definitions. To make it more convenient for debuggers to get to the value of inline static data members, this patch makes sure we emit definitions for static variables with constant initializers the same way we do for other static variables. This also aligns Clang closer to GCC, which produces CU-level definitions for inline statics and also emits these into `.debug_pubnames`. The implementation keeps track of newly created static data members. Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable` with a `DW_AT_const_value` for any of those declarations that didn't end up with a definition in the `DeclCache`. The newly emitted `DW_TAG_variable` will look as follows: ``` 0x007b: DW_TAG_structure_type DW_AT_calling_convention(DW_CC_pass_by_value) DW_AT_name ("Foo") ... 0x008d: DW_TAG_member DW_AT_name("i") DW_AT_type(0x0062 "const int") DW_AT_external(true) DW_AT_declaration (true) DW_AT_const_value (4) Newly added v 0x009a: DW_TAG_variable DW_AT_specification (0x008d "i") DW_AT_const_value (4) DW_AT_linkage_name ("_ZN2t2IiE1iIfEE") ``` --- clang/lib/CodeGen/CGDebugInfo.cpp | 46 +++ clang/lib/CodeGen/CGDebugInfo.h | 6 ++ clang/test/CodeGenCXX/debug-info-class.cpp| 13 ++- .../debug-info-static-inline-member.cpp | 79 +++ .../TestConstStaticIntegralMember.py | 7 +- 5 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGenCXX/debug-info-static-inline-member.cpp diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..7529f114996d2ec 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1693,6 +1693,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy, llvm::DIDerivedType *GV = DBuilder.createStaticMemberType( RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Align); StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV); + StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl()); return GV; } @@ -5613,6 +5614,39 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { TemplateParameters, Align)); } +void CGDebugInfo::EmitGlobalVariable(const VarDecl *VD) { + assert(VD->hasInit()); + assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); + if (VD->hasAttr()) +return; + + auto &GV = DeclCache[VD]; + if (GV) +return; + + auto const *InitVal = VD->evaluateValue(); + if (!InitVal) +return; + + llvm::DIFile *Unit = nullptr; + llvm::DIScope *DContext = nullptr; + unsigned LineNo; + StringRef DeclName, LinkageName; + QualType T; + llvm::MDTuple *TemplateParameters = nullptr; + collectVarDeclProps(VD, Unit, LineNo, T, DeclName, LinkageName, + TemplateParameters, DContext); + + auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); + llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD); + llvm::DIExpression *InitExpr = createConstantValueExpression(VD, *InitVal); + + GV.reset(DBuilder.createGlobalVariableExpression( + TheCU, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit), + true, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VD), + TemplateParameters, Align, Annotations)); +} + void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var, const VarDecl *D) { assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); @@ -5883,6 +5917,18 @@ void CGDebugInfo::finalize() {
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/nmustakin updated https://github.com/llvm/llvm-project/pull/70667 >From 153c6d812939cd23bb71e53c71378117ed5b23c7 Mon Sep 17 00:00:00 2001 From: Nafis Mustakin Date: Mon, 30 Oct 2023 07:50:59 -0700 Subject: [PATCH 1/2] Add memory diff dump for kernel record-replay --- .../PluginInterface/PluginInterface.cpp | 65 +++ 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp index 0243f0205dbf0e5..8469e8eaf1593cd 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp @@ -83,7 +83,7 @@ struct RecordReplayTy { return Plugin::success(); } - void dumpDeviceMemory(StringRef Filename) { + void dumpDeviceMemory(StringRef Filename, bool saveDiff) { ErrorOr> DeviceMemoryMB = WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); if (!DeviceMemoryMB) @@ -93,15 +93,58 @@ struct RecordReplayTy { MemoryStart, MemorySize, nullptr); if (Err) report_fatal_error("Error retrieving data for target pointer"); - -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); -std::error_code EC; -raw_fd_ostream OS(Filename, EC); -if (EC) + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if(EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; -OS.close(); + +if (saveDiff){ + //Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + //read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if(std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if(InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + //get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + //compare pre-record memorydump to current contents + size_t i = 0; + while(i < MemorySize){ +//if mismatch found, create a new diff line +//current format - location, size, differences ... +if(InputBufferContents[i] != DeviceMemoryContents[i]){ + OS << i << " "; //marks the start offset + SmallVector modified; + modified.push_back(DeviceMemoryContents[i]); + size_t j = 1; + //loop until next match is found + while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){ +modified.push_back(DeviceMemoryContents[i+j]); +j++; + } + OS << j << " "; //marks the length of the mismatching sequence + for(const auto &value : modified) +OS << value << " "; + OS << "\n"; + i+=j+1; +} +else i++; + } +} +else { + StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); + OS << DeviceMemory; +} +OS.close(); } public: @@ -209,7 +252,7 @@ struct RecordReplayTy { JsonKernelInfo["ArgOffsets"] = json::Value(std::move(JsonArgOffsets)); SmallString<128> MemoryFilename = {Name, ".memory"}; -dumpDeviceMemory(MemoryFilename); +dumpDeviceMemory(MemoryFilename, false); SmallString<128> GlobalsFilename = {Name, ".globals"}; dumpGlobals(GlobalsFilename, Image); @@ -227,7 +270,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, true); } void *alloc(uint64_t Size) { @@ -1307,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs, GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets, KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0], KernelArgs.Tripcount); - + if (RecordReplay.isRecording()) RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage()); >From 8daffad57074dd09287d321acd79c74a667eb65f Mon Sep 17 00:00:00 2001 From: Nafis Mustakin Date: Mon, 30 Oct 2023 08:39:40 -0700 Subject: [PATCH 2/2] Fix clang-formatting issues, accept reviewed suggestions --- .../PluginInterface/PluginInterface.cpp | 78
[Lldb-commits] [lldb] [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (PR #70544)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/70544 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: @nmustakin What's the use-case/motivation for this patch? https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
avl-llvm wrote: Should not we remove constant initializer from the type definition if we have a DW_TAG_variable with a DW_AT_const_value now? ``` 0x008d: DW_TAG_member DW_AT_name("i") DW_AT_type(0x0062 "const int") DW_AT_external(true) DW_AT_declaration (true) DW_AT_const_value (4) < ``` https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)
@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) { // Invoke xcrun with the shlib dir. if (FileSpec fspec = HostInfo::GetShlibDir()) { if (FileSystem::Instance().Exists(fspec)) { -std::string contents_dir = -XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()); -llvm::StringRef shlib_developer_dir = -llvm::sys::path::parent_path(contents_dir); -if (!shlib_developer_dir.empty()) { - auto sdk = - xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir)); +llvm::SmallString<0> shlib_developer_dir( +XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath())); +llvm::sys::path::append(shlib_developer_dir, "Developer"); +if (FileSystem::Instance().Exists(shlib_developer_dir)) { adrian-prantl wrote: There is already a code path to try without DEVELOPER_DIR, and this avoids making the same query twice if it doesn't exist. https://github.com/llvm/llvm-project/pull/70528 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c42b640 - Fix the DEVELOPER_DIR computation (#70528)
Author: Adrian Prantl Date: 2023-10-30T10:00:40-07:00 New Revision: c42b640208aa74c65cef5943bc05522780a72723 URL: https://github.com/llvm/llvm-project/commit/c42b640208aa74c65cef5943bc05522780a72723 DIFF: https://github.com/llvm/llvm-project/commit/c42b640208aa74c65cef5943bc05522780a72723.diff LOG: Fix the DEVELOPER_DIR computation (#70528) The code was incorrectly going into the wrong direction by removing one component instead of appendeing /Developer to it. Due to fallback mechanisms in xcrun this never seemed to have caused any issues. Added: Modified: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Removed: diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index e3506a01c606b78..33d94504fe70f8c 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) { // Invoke xcrun with the shlib dir. if (FileSpec fspec = HostInfo::GetShlibDir()) { if (FileSystem::Instance().Exists(fspec)) { -std::string contents_dir = -XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()); -llvm::StringRef shlib_developer_dir = -llvm::sys::path::parent_path(contents_dir); -if (!shlib_developer_dir.empty()) { - auto sdk = - xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir)); +llvm::SmallString<0> shlib_developer_dir( +XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath())); +llvm::sys::path::append(shlib_developer_dir, "Developer"); +if (FileSystem::Instance().Exists(shlib_developer_dir)) { + auto sdk = xcrun(sdk_name, show_sdk_path, shlib_developer_dir); if (!sdk) return sdk.takeError(); if (!sdk->empty()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)
https://github.com/adrian-prantl closed https://github.com/llvm/llvm-project/pull/70528 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c3f7ca7 - [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (#70544)
Author: Michael Buch Date: 2023-10-30T17:08:25Z New Revision: c3f7ca78101b77fa522f059af520526ff878a5b0 URL: https://github.com/llvm/llvm-project/commit/c3f7ca78101b77fa522f059af520526ff878a5b0 DIFF: https://github.com/llvm/llvm-project/commit/c3f7ca78101b77fa522f059af520526ff878a5b0.diff LOG: [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (#70544) These tests were failing on the LLDB public matrix build-bots for older clang versions: ``` clang-7: warning: argument unused during compilation: '-nostdlib++' [-Wunused-command-line-argument] error: invalid value 'c++20' in '-std=c++20' note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard note: use 'c++11' for 'ISO C++ 2011 with amendments' standard note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard note: use 'c++14' for 'ISO C++ 2014 with amendments' standard note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard note: use 'c++17' for 'ISO C++ 2017 with amendments' standard note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard make: *** [main.o] Error 1 ``` The test fails because we try to compile it with `-std=c++20` (which is required for std::chrono::{days,weeks,months,years}) on clang versions that don't support the `-std=c++20` flag. We could change the test to conditionally compile the C++20 parts of the test based on the `-std=` flag and have two versions of the python tests, one for the C++11 chrono features and one for the C++20 features. This patch instead just disables the test on older clang versions (because it's simpler and we don't really lose important coverage). Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index 076b0d07b88aec7..b2f86817f3b0e8f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -11,6 +11,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @add_test_categories(["libc++"]) +@skipIf(compiler="clang", compiler_version=["<", "11.0"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (PR #70544)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/70544 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
nmustakin wrote: @ggeorgakoudis To reduce the memory consumption for kernel tuning using record/replay. https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/nmustakin edited https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Release] Build compiler-rt during Phase 1 on AIX (PR #70672)
https://github.com/azhan92 updated https://github.com/llvm/llvm-project/pull/70672 >From 691672671fb29bf8e98df22444c428f1392798be Mon Sep 17 00:00:00 2001 From: Alison Zhang Date: Mon, 30 Oct 2023 11:27:43 -0400 Subject: [PATCH] build clang-rt on AIX --- llvm/utils/release/test-release.sh | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/utils/release/test-release.sh b/llvm/utils/release/test-release.sh index 5fd5f82b544796e..967b98a94b8081f 100755 --- a/llvm/utils/release/test-release.sh +++ b/llvm/utils/release/test-release.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +u!/usr/bin/env bash #===-- test-release.sh - Test the LLVM release candidates --===# # # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -417,6 +417,10 @@ function configure_llvmCore() { # building itself and any selected runtimes in the second phase. if [ "$Phase" -lt "2" ]; then runtime_list="" + # compiler-rt built-ins needed on AIX to have a functional Phase 1 clang. + if [ "$System" = "AIX" ]; then +runtime_list="compiler-rt" + fi else runtime_list="$runtimes" fi ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Release] Build compiler-rt during Phase 1 on AIX (PR #70672)
@@ -1,4 +1,4 @@ -#!/usr/bin/env bash +u!/usr/bin/env bash daltenty wrote: Unintended typo? https://github.com/llvm/llvm-project/pull/70672 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/nmustakin updated https://github.com/llvm/llvm-project/pull/70667 >From 153c6d812939cd23bb71e53c71378117ed5b23c7 Mon Sep 17 00:00:00 2001 From: Nafis Mustakin Date: Mon, 30 Oct 2023 07:50:59 -0700 Subject: [PATCH 1/3] Add memory diff dump for kernel record-replay --- .../PluginInterface/PluginInterface.cpp | 65 +++ 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp index 0243f0205dbf0e5..8469e8eaf1593cd 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp @@ -83,7 +83,7 @@ struct RecordReplayTy { return Plugin::success(); } - void dumpDeviceMemory(StringRef Filename) { + void dumpDeviceMemory(StringRef Filename, bool saveDiff) { ErrorOr> DeviceMemoryMB = WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); if (!DeviceMemoryMB) @@ -93,15 +93,58 @@ struct RecordReplayTy { MemoryStart, MemorySize, nullptr); if (Err) report_fatal_error("Error retrieving data for target pointer"); - -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); -std::error_code EC; -raw_fd_ostream OS(Filename, EC); -if (EC) + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if(EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; -OS.close(); + +if (saveDiff){ + //Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + //read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if(std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if(InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + //get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + //compare pre-record memorydump to current contents + size_t i = 0; + while(i < MemorySize){ +//if mismatch found, create a new diff line +//current format - location, size, differences ... +if(InputBufferContents[i] != DeviceMemoryContents[i]){ + OS << i << " "; //marks the start offset + SmallVector modified; + modified.push_back(DeviceMemoryContents[i]); + size_t j = 1; + //loop until next match is found + while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){ +modified.push_back(DeviceMemoryContents[i+j]); +j++; + } + OS << j << " "; //marks the length of the mismatching sequence + for(const auto &value : modified) +OS << value << " "; + OS << "\n"; + i+=j+1; +} +else i++; + } +} +else { + StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); + OS << DeviceMemory; +} +OS.close(); } public: @@ -209,7 +252,7 @@ struct RecordReplayTy { JsonKernelInfo["ArgOffsets"] = json::Value(std::move(JsonArgOffsets)); SmallString<128> MemoryFilename = {Name, ".memory"}; -dumpDeviceMemory(MemoryFilename); +dumpDeviceMemory(MemoryFilename, false); SmallString<128> GlobalsFilename = {Name, ".globals"}; dumpGlobals(GlobalsFilename, Image); @@ -227,7 +270,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, true); } void *alloc(uint64_t Size) { @@ -1307,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs, GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets, KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0], KernelArgs.Tripcount); - + if (RecordReplay.isRecording()) RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage()); >From 8daffad57074dd09287d321acd79c74a667eb65f Mon Sep 17 00:00:00 2001 From: Nafis Mustakin Date: Mon, 30 Oct 2023 08:39:40 -0700 Subject: [PATCH 2/3] Fix clang-formatting issues, accept reviewed suggestions --- .../PluginInterface/PluginInterface.cpp | 78
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: > @ggeorgakoudis To reduce the memory consumption for kernel tuning using > record/replay. I do not see this so much about saving memory consumption but more as saving disk space. Makes sense to me this way, will review shortly. https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/nmustakin edited https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
@@ -0,0 +1,87 @@ +// RUN: %clangxx -target arm64-apple-macosx11.0.0 -g %s -emit-llvm -S -o - | FileCheck --check-prefixes=CHECK %s + +enum class Enum : int { + VAL = -1 +}; + +struct Empty {}; + +constexpr auto func() { return 25; } + +struct Foo { +static constexpr int cexpr_int = func(); +static constexpr int cexpr_int2 = func() + 1; +static constexpr float cexpr_float = 2.0 + 1.0; +static constexpr Enum cexpr_enum = Enum::VAL; +static constexpr Empty cexpr_empty{}; +static inlineEnum inline_enum = Enum::VAL; + +template +static constexpr T cexpr_template{}; +}; + +int main() { +Foo f; + +// Force global variable definitions to be emitted. +(void)&Foo::cexpr_int; +(void)&Foo::cexpr_empty; + +return Foo::cexpr_int + Foo::cexpr_float + + (int)Foo::cexpr_enum + Foo::cexpr_template; +} + +// CHECK: @{{.*}}cexpr_int{{.*}} = +// CHECK-SAME: !dbg ![[INT_GLOBAL:[0-9]+]] + +// CHECK: @{{.*}}cexpr_empty{{.*}} = +// CHECK-SAME!dbg ![[EMPTY_GLOBAL:[0-9]+]] + +// CHECK: !DIGlobalVariableExpression(var: ![[INT_VAR:[0-9]+]], expr: !DIExpression()) dwblaikie wrote: Why doesn't this have a value/expression? (but INT_VAR2 does) https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
dwblaikie wrote: > Should not we remove constant initializer from the type definition if we have > a DW_TAG_variable with a DW_AT_const_value now? Yep, +1 to this. This is where the type normalization benefit would come from - no longer having this const value on the member declaration, but only on the definition. https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
dwblaikie wrote: > Summing the size of all *.o files in my local debug Clang build increased by > 0.7% with this patch That's a bit significant. Any chance you could get a per-section breakdown/growth on that? (& exact flags - is this with compressed debug info, for instance? Or not?) I use `bloaty` for this ( https://github.com/google/bloaty ) - though it's a bit involved to do this to sum over all the object files - summing up the results from per-object file, etc... https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
Michael137 wrote: > > Should not we remove constant initializer from the type definition if we > > have a DW_TAG_variable with a DW_AT_const_value now? > > Yep, +1 to this. This is where the type normalization benefit would come from > - no longer having this const value on the member declaration, but only on > the definition. Makes sense. I'll create a separate PR for that, unless people are fine with doing that as part of this change https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
dwblaikie wrote: > > > Should not we remove constant initializer from the type definition if we > > > have a DW_TAG_variable with a DW_AT_const_value now? > > > > > > Yep, +1 to this. This is where the type normalization benefit would come > > from - no longer having this const value on the member declaration, but > > only on the definition. > > Makes sense. I'll create a separate PR for that, unless people are fine with > doing that as part of this change If it's not too much code might make sense to do it as part of this change - so the size impacts are more clear, for instance. https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ inline static data members (PR #70641)
https://github.com/clayborg approved this pull request. This will be great to get it (this PR and the related one). The tests LGTM. https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
@@ -614,6 +614,8 @@ class Process : public std::enable_shared_from_this, return error; } + virtual void DidLoadCore() {} clayborg wrote: We could avoid adding the DidLoadCore and re-use the existing Process DidAttach: ``` class Process { ... virtual void DidAttach(ArchSpec &process_arch) { process_arch.Clear(); } ``` https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
@@ -2668,7 +2655,23 @@ Status Process::LoadCore() { StateAsCString(state)); error.SetErrorString( "Did not get stopped event after loading the core file."); +} else { + DidLoadCore(); clayborg wrote: Call `DidAttach(...)` instead? https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
https://github.com/clayborg commented: Looks good, just a question if we want to use the existing Process::DidAttach() instead of adding a new Process::DidLoadCore() https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add FindGlobalVariables tests for C++ inline static data members (PR #70641)
https://github.com/JDevlieghere approved this pull request. LGTM modulo formatting https://github.com/llvm/llvm-project/pull/70641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)
JDevlieghere wrote: +1, if you can verify that Python 3.6 supports the `importlib` approach we should drop the fallback. https://github.com/llvm/llvm-project/pull/70443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
@@ -0,0 +1,87 @@ +// RUN: %clangxx -target arm64-apple-macosx11.0.0 -g %s -emit-llvm -S -o - | FileCheck --check-prefixes=CHECK %s + +enum class Enum : int { + VAL = -1 +}; + +struct Empty {}; + +constexpr auto func() { return 25; } + +struct Foo { +static constexpr int cexpr_int = func(); +static constexpr int cexpr_int2 = func() + 1; +static constexpr float cexpr_float = 2.0 + 1.0; +static constexpr Enum cexpr_enum = Enum::VAL; +static constexpr Empty cexpr_empty{}; +static inlineEnum inline_enum = Enum::VAL; + +template +static constexpr T cexpr_template{}; +}; + +int main() { +Foo f; + +// Force global variable definitions to be emitted. +(void)&Foo::cexpr_int; +(void)&Foo::cexpr_empty; + +return Foo::cexpr_int + Foo::cexpr_float + + (int)Foo::cexpr_enum + Foo::cexpr_template; +} + +// CHECK: @{{.*}}cexpr_int{{.*}} = +// CHECK-SAME: !dbg ![[INT_GLOBAL:[0-9]+]] + +// CHECK: @{{.*}}cexpr_empty{{.*}} = +// CHECK-SAME!dbg ![[EMPTY_GLOBAL:[0-9]+]] + +// CHECK: !DIGlobalVariableExpression(var: ![[INT_VAR:[0-9]+]], expr: !DIExpression()) Michael137 wrote: Because this one has a corresponding `llvm::GlobalVariable` which doesn't go down the code-path I added. We emit a `DW_AT_location` only for this. Should we be emitting both a location and constant in this case? https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)
@@ -54,22 +55,52 @@ void GPUToSPIRVPass::runOnOperation() { SmallVector gpuModules; OpBuilder builder(context); + + auto targetEnvSupportsKernelCapability = [](gpu::GPUModuleOp moduleOp) { +Operation *gpuModule = moduleOp.getOperation(); +auto targetAttr = spirv::lookupTargetEnvOrDefault(gpuModule); +spirv::TargetEnv targetEnv(targetAttr); +return targetEnv.allows(spirv::Capability::Kernel); + }; + module.walk([&](gpu::GPUModuleOp moduleOp) { // Clone each GPU kernel module for conversion, given that the GPU // launch op still needs the original GPU kernel module. -builder.setInsertionPoint(moduleOp.getOperation()); +// For Vulkan Shader capabilities, we insert the newly converted SPIR-V +// module right after the original GPU module, as that's the expectation of +// the in-tree Vulkan runner. +// For OpenCL Kernel capabilities, we insert the newly converted SPIR-V +// module inside the original GPU module, as that's the expectaion of the +// normal GPU compilation pipeline. +if (targetEnvSupportsKernelCapability(moduleOp)) { + builder.setInsertionPoint(moduleOp.getBody(), +moduleOp.getBody()->begin()); +} else { + builder.setInsertionPoint(moduleOp.getOperation()); +} gpuModules.push_back(builder.clone(*moduleOp.getOperation())); }); // Run conversion for each module independently as they can have different // TargetEnv attributes. for (Operation *gpuModule : gpuModules) { +spirv::TargetEnvAttr targetAttr = +spirv::lookupTargetEnvOrDefault(gpuModule); + // Map MemRef memory space to SPIR-V storage class first if requested. if (mapMemorySpace) { + spirv::TargetEnv targetEnv(targetAttr); + FailureOr memoryModel = + spirv::getMemoryModel(targetEnv); + if (failed(memoryModel)) +return signalPassFailure(); + std::unique_ptr target = spirv::getMemorySpaceToStorageClassTarget(*context); spirv::MemorySpaceToStorageClassMap memorySpaceMap = - spirv::mapMemorySpaceToVulkanStorageClass; + (memoryModel == spirv::MemoryModel::OpenCL) silee2 wrote: Done. https://github.com/llvm/llvm-project/pull/69941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)
@@ -108,6 +138,25 @@ void GPUToSPIRVPass::runOnOperation() { if (failed(applyFullConversion(gpuModule, *target, std::move(patterns return signalPassFailure(); } + + // For OpenCL, the gpu.func op in the original gpu.module op needs to be silee2 wrote: Keeping the original gpu.func causes legality check error later in the gpu compile pipeline. If target attr is set for a gpu.module, gpu-to-llvm pass doesn't lower gpu.launch_func Instead, it is replaced with another gpu.launch_func that has lowered argument types (llvm ptrs). If a gpu.func remains as an input to gpu-to-llvm pass, there is an argument mismatch between the new gpu.launch_func and the gpu.func. And a error is fired. The reason for putting a dummy func.func here is to work around that check. For func types other than gpu.func, argument types are not checked against gpu.launch_func. But a func.func is still need as there will be a symbol check. https://github.com/llvm/llvm-project/pull/69941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)
https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/69941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)
Michael137 wrote: > I use `bloaty` for this ( https://github.com/google/bloaty ) - though it's a > bit involved to do this to sum over all the object files - summing up the > results from per-object file, etc... ``` bloaty `find ./patched-build/lib -name *.o` │ bloaty `find ./no-patch-build/lib -name *.o ` FILE SIZEVM SIZE│FILE SIZEVM SIZE - -- │ -- -- 54.6% 2.02Gi 60.3% 2.02Gi,__debug_str │ 54.5% 2.01Gi 60.1% 2.01Gi,__debug_str 22.0% 835Mi 24.3% 835Mi,__debug_info │ 22.1% 831Mi 24.3% 831Mi,__debug_info 6.2% 236Mi 0.0% 0String Table │ 6.1% 228Mi 0.0% 0String Table 4.5% 170Mi 5.0% 170Mi,__text │ 4.5% 169Mi 5.0% 169Mi,__text 2.6% 97.6Mi 2.8% 97.6Mi,__debug_line │ 2.8% 104Mi 3.1% 104Mi,__debug_line 2.3% 88.0Mi 2.6% 88.0Mi,__apple_types│ 2.3% 87.8Mi 2.6% 87.8Mi,__apple_types 2.2% 83.1Mi 2.4% 83.1Mi,__apple_names│ 2.1% 81.0Mi 0.0% 0[Unmapped] 2.2% 81.8Mi 0.0% 0[Unmapped]│ 2.1% 78.5Mi 2.3% 78.5Mi,__apple_names 1.7% 65.6Mi 1.9% 65.6Mi,__compact_unwind │ 1.7% 65.4Mi 1.9% 65.4Mi,__compact_unwind 1.0% 39.2Mi 0.0% 0Symbol Table │ 1.0% 39.0Mi 0.0% 0Symbol Table 0.2% 8.05Mi 0.2% 8.05Mi,__const │ 0.2% 7.55Mi 0.2% 7.55Mi,__const 0.2% 7.91Mi 0.2% 7.91Mi,__cstring│ 0.2% 7.54Mi 0.2% 7.54Mi,__cstring 0.1% 5.24Mi 0.2% 5.24Mi,__debug_abbrev │ 0.1% 5.27Mi 0.2% 5.27Mi,__debug_abbrev 0.1% 2.31Mi 0.0% 0[Mach-O Headers] │ 0.1% 2.30Mi 0.0% 0[Mach-O Headers] 0.0% 1.38Mi 0.0% 1.38Mi,__debug_ranges │ 0.0% 1.38Mi 0.0% 1.38Mi,__debug_ranges 0.0% 994Ki 0.0% 994Ki,__apple_namespac │ 0.0% 949Ki 0.0% 949Ki,__apple_namespac 0.0% 0 0.0% 354Ki,__bss│ 0.0% 0 0.0% 354Ki,__bss 0.0% 324Ki 0.0% 324Ki,__data │ 0.0% 324Ki 0.0% 324Ki,__data 0.0% 283Ki 0.0% 283Ki,__StaticInit │ 0.0% 283Ki 0.0% 283Ki,__StaticInit 0.0% 31.3Ki 0.0% 61.4Ki[10 Others] │ 0.0% 31.9Ki 0.0% 62.0Ki[11 Others] 0.0% 58.6Ki 0.0% 58.6Ki,__apple_objc │ 0.0% 58.6Ki 0.0% 58.6Ki,__apple_objc 00.0% 3.71Gi 100.0% 3.35GiTOTAL │ 100.0% 3.68Gi 100.0% 3.33GiTOTAL ``` Probably the linkage names that contribute most? > That's a bit significant. Any chance you could get a per-section > breakdown/growth on that? (& exact flags - is this with compressed debug > info, for instance? Or not?) This is an example command line invocation (with some paths redacted) for one of the object files: ``` ./patched-build/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LIBCPP_ENABLE_HARDENED_MODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__ STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissin g-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstr ing-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -std=c++17 -arch arm64 -fno-exceptions -funwind-tables -fno-rtti" ``` https://github.com/llvm/llvm-project/pull/70639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)
@@ -108,6 +138,25 @@ void GPUToSPIRVPass::runOnOperation() { if (failed(applyFullConversion(gpuModule, *target, std::move(patterns return signalPassFailure(); } + + // For OpenCL, the gpu.func op in the original gpu.module op needs to be jungpark-mlir wrote: I think the problem is, the lack of spirv support in gpu dialect. For example, gpu.func needs to be able to wrap spirv.func so gpu-to-llvm pass (for the host code) can properly handle the relation between gpu.launch_func and spirv.func. Basically, using dummy `func.func` looks little hacky and it'd be also nice if the divergence between Vulkan/OpenCL IR structures could be avoided. However, considering the progress of this commit, we can discuss this later for the future enhancement. Really appreciate this work and look forward to seeing it merged. https://github.com/llvm/llvm-project/pull/69941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Also log the error output from xcrun, if it fails. (PR #70716)
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/70716 In the rare case that an Xcode installation is damaged, this output could contain clues to further diagnose the issue. rdar://117698630 >From 8a3b45751c033483266e91b30af22d5bd8d17e2c Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 30 Oct 2023 13:11:02 -0700 Subject: [PATCH] Also log the error output from xcrun, if it fails. In the rare case that an Xcode installation is damaged, this output could contain clues to further diagnose the issue. rdar://117698630 --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index e3506a01c606b78..f2a4d5729f29871 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -417,6 +417,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) { // xcrun didn't find a matching SDK. Not an error, we'll try // different spellings. LLDB_LOG(log, "xcrun returned exit code {0}", status); +if (!output_str.empty()) + LLDB_LOG(log, "xcrun output was:\n{0}", output_str); return ""; } if (output_str.empty()) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Also log the error output from xcrun, if it fails. (PR #70716)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Adrian Prantl (adrian-prantl) Changes In the rare case that an Xcode installation is damaged, this output could contain clues to further diagnose the issue. rdar://117698630 --- Full diff: https://github.com/llvm/llvm-project/pull/70716.diff 1 Files Affected: - (modified) lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm (+2) ``diff diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index e3506a01c606b78..f2a4d5729f29871 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -417,6 +417,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) { // xcrun didn't find a matching SDK. Not an error, we'll try // different spellings. LLDB_LOG(log, "xcrun returned exit code {0}", status); +if (!output_str.empty()) + LLDB_LOG(log, "xcrun output was:\n{0}", output_str); return ""; } if (output_str.empty()) { `` https://github.com/llvm/llvm-project/pull/70716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)
https://github.com/adrian-prantl closed https://github.com/llvm/llvm-project/pull/69991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
@@ -614,6 +614,8 @@ class Process : public std::enable_shared_from_this, return error; } + virtual void DidLoadCore() {} medismailben wrote: Good point! At least for core file process plugins, the `DidAttach` override shouldn't be implemented so we should be good. https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix misleading indentiation warning in ScriptInterpreterPython (NFC) (PR #70732)
https://github.com/medismailben created https://github.com/llvm/llvm-project/pull/70732 This should silence the "misleading indentiation" warnings introduced by b2929be, by ignoring the flag for that specific chunk of code, if the surrounding if-statement have been compiled out. >From 4b21aec8bb9866ae4061dfb837fdb4bab2dbe926 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 30 Oct 2023 14:51:07 -0700 Subject: [PATCH] [lldb] Fix misleading indentiation warning in ScriptInterpreterPython (NFC) This should silence the "misleading indentiation" warnings introduced by b2929be, by ignoring the flag for that specific chunk of code, if the surrounding if-statement have been compiled out. Signed-off-by: Med Ismail Bennani --- .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 5 + 1 file changed, 5 insertions(+) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 968cc8ca03001e5..dc68571d3c47a1a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -183,6 +183,9 @@ struct InitializePythonRAII { // Python 3.13. It has been returning `true` always since Python 3.7. #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3) if (PyEval_ThreadsInitialized()) { +#else +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmisleading-indentation" #endif Log *log = GetLog(LLDBLog::Script); @@ -199,6 +202,8 @@ struct InitializePythonRAII { // InitThreads acquires the GIL if it hasn't been called before. PyEval_InitThreads(); +#else +#pragma clang diagnostic pop #endif } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix misleading indentiation warning in ScriptInterpreterPython (NFC) (PR #70732)
medismailben wrote: The warning was introduced by #70445 (cc. @tuliom). https://github.com/llvm/llvm-project/pull/70732 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Support target names with dots in more utilities (PR #65812)
dankm wrote: Sounds good. Everything I want is in the pull request, I'm going to create a new pull request to update some tests as we discussed above. I'll update the description to be a bit more clear. Thanks for all help. https://github.com/llvm/llvm-project/pull/65812 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)
https://github.com/jimingham created https://github.com/llvm/llvm-project/pull/70734 This allows you to specify options and arguments and their definitions and then have lldb handle the completions, help, etc. in the same way that lldb does for its parsed commands internally. This feature has some design considerations as well as the code, so I've also set up an RFC, but I did this one first and will put the RFC address in here once I've pushed it... Note, the lldb "ParsedCommand interface" doesn't actually do all the work that it should. For instance, saying the type of an option that has a completer doesn't automatically hook up the completer, and ditto for argument values. We also do almost no work to verify that the arguments match their definition, or do auto-completion for them. This patch allows you to make a command that's bug-for-bug compatible with built-in ones, but I didn't want to stall it on getting the auto-command checking to work all the way correctly. As an overall design note, my primary goal here was to make an interface that worked well in the script language. For that I needed, for instance, to have a property-based way to get all the option values that were specified. It was much more convenient to do that by making a fairly bare-bones C interface to define the options and arguments of a command, and set their values, and then wrap that in a Python class (installed along with the other bits of the lldb python module) which you can then derive from to make your new command. This approach will also make it easier to experiment. See the file test_commands.py in the test case for examples of how this works. >From 7bb11d65e11329cdde801d04a1900a45b6cd6d19 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Mon, 30 Oct 2023 14:48:37 -0700 Subject: [PATCH] Add the ability to define a Python based command that uses the CommandObjectParsed way to specify options and arguments so that these commands can be "first class citizens" with build-in commands. --- lldb/bindings/python/CMakeLists.txt | 3 +- lldb/bindings/python/python-wrapper.swig | 31 + lldb/examples/python/parsed_cmd.py| 315 lldb/include/lldb/Interpreter/CommandObject.h | 5 +- .../lldb/Interpreter/ScriptInterpreter.h | 29 + .../source/Commands/CommandObjectCommands.cpp | 697 +- lldb/source/Commands/Options.td | 22 +- lldb/source/Interpreter/CommandObject.cpp | 16 + .../Python/PythonDataObjects.h| 2 + .../Python/SWIGPythonBridge.h | 7 + .../Python/ScriptInterpreterPython.cpp| 252 ++- .../Python/ScriptInterpreterPythonImpl.h | 21 + .../script/add/TestAddParsedCommand.py| 146 .../command/script/add/test_commands.py | 175 + .../Python/PythonTestSuite.cpp| 8 + 15 files changed, 1714 insertions(+), 15 deletions(-) create mode 100644 lldb/examples/python/parsed_cmd.py create mode 100644 lldb/test/API/commands/command/script/add/TestAddParsedCommand.py create mode 100644 lldb/test/API/commands/command/script/add/test_commands.py diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index c941f764dfc92ac..657fdd2c9590066 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -96,7 +96,8 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar ${lldb_python_target_dir} "utils" FILES "${LLDB_SOURCE_DIR}/examples/python/in_call_stack.py" - "${LLDB_SOURCE_DIR}/examples/python/symbolication.py") + "${LLDB_SOURCE_DIR}/examples/python/symbolication.py" + "${LLDB_SOURCE_DIR}/examples/python/parsed_cmd.py") create_python_package( ${swig_target} diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index 17bc7b1f2198709..47887491d0c552a 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -831,6 +831,37 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject( return true; } +bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject( +PyObject *implementor, lldb::DebuggerSP debugger, lldb_private::StructuredDataImpl &args_impl, +lldb_private::CommandReturnObject &cmd_retobj, +lldb::ExecutionContextRefSP exe_ctx_ref_sp) { + + PyErr_Cleaner py_err_cleaner(true); + + PythonObject self(PyRefType::Borrowed, implementor); + auto pfunc = self.ResolveName("__call__"); + + if (!pfunc.IsAllocated()) +return false; + + auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj); + + // FIXME: + // I wanted to do something like: + // size_t num_elem = args.size(); + // PythonList my_list(num_elem); + // for (const char *elem : args) + // my_list.append(PythonString(elem); + // + // and then pass my_list to the pfunc, but t
[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jimingham) Changes This allows you to specify options and arguments and their definitions and then have lldb handle the completions, help, etc. in the same way that lldb does for its parsed commands internally. This feature has some design considerations as well as the code, so I've also set up an RFC, but I did this one first and will put the RFC address in here once I've pushed it... Note, the lldb "ParsedCommand interface" doesn't actually do all the work that it should. For instance, saying the type of an option that has a completer doesn't automatically hook up the completer, and ditto for argument values. We also do almost no work to verify that the arguments match their definition, or do auto-completion for them. This patch allows you to make a command that's bug-for-bug compatible with built-in ones, but I didn't want to stall it on getting the auto-command checking to work all the way correctly. As an overall design note, my primary goal here was to make an interface that worked well in the script language. For that I needed, for instance, to have a property-based way to get all the option values that were specified. It was much more convenient to do that by making a fairly bare-bones C interface to define the options and arguments of a command, and set their values, and then wrap that in a Python class (installed along with the other bits of the lldb python module) which you can then derive from to make your new command. This approach will also make it easier to experiment. See the file test_commands.py in the test case for examples of how this works. --- Patch is 76.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/70734.diff 15 Files Affected: - (modified) lldb/bindings/python/CMakeLists.txt (+2-1) - (modified) lldb/bindings/python/python-wrapper.swig (+31) - (added) lldb/examples/python/parsed_cmd.py (+315) - (modified) lldb/include/lldb/Interpreter/CommandObject.h (+4-1) - (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+29) - (modified) lldb/source/Commands/CommandObjectCommands.cpp (+693-4) - (modified) lldb/source/Commands/Options.td (+14-8) - (modified) lldb/source/Interpreter/CommandObject.cpp (+16) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h (+2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h (+7) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+251-1) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h (+21) - (added) lldb/test/API/commands/command/script/add/TestAddParsedCommand.py (+146) - (added) lldb/test/API/commands/command/script/add/test_commands.py (+175) - (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (+8) ``diff diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index c941f764dfc92ac..657fdd2c9590066 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -96,7 +96,8 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar ${lldb_python_target_dir} "utils" FILES "${LLDB_SOURCE_DIR}/examples/python/in_call_stack.py" - "${LLDB_SOURCE_DIR}/examples/python/symbolication.py") + "${LLDB_SOURCE_DIR}/examples/python/symbolication.py" + "${LLDB_SOURCE_DIR}/examples/python/parsed_cmd.py") create_python_package( ${swig_target} diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index 17bc7b1f2198709..47887491d0c552a 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -831,6 +831,37 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject( return true; } +bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject( +PyObject *implementor, lldb::DebuggerSP debugger, lldb_private::StructuredDataImpl &args_impl, +lldb_private::CommandReturnObject &cmd_retobj, +lldb::ExecutionContextRefSP exe_ctx_ref_sp) { + + PyErr_Cleaner py_err_cleaner(true); + + PythonObject self(PyRefType::Borrowed, implementor); + auto pfunc = self.ResolveName("__call__"); + + if (!pfunc.IsAllocated()) +return false; + + auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj); + + // FIXME: + // I wanted to do something like: + // size_t num_elem = args.size(); + // PythonList my_list(num_elem); + // for (const char *elem : args) + // my_list.append(PythonString(elem); + // + // and then pass my_list to the pfunc, but that crashes somewhere + // deep in Python for reasons that aren't clear to me. + + pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), SWIGBridge::ToSWIGWrapper(args_impl), +SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd
[Lldb-commits] [lldb] Support target names containing dots in all utilities (PR #65812)
https://github.com/dankm edited https://github.com/llvm/llvm-project/pull/65812 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff a41b149f481e2bcba24e81f208a1938247f040e0 7bb11d65e11329cdde801d04a1900a45b6cd6d19 -- lldb/include/lldb/Interpreter/CommandObject.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Interpreter/CommandObject.cpp lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index c2f17f374fe5..c8084d9bbcf6 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -226,8 +226,8 @@ public: static bool IsPairType(ArgumentRepetitionType arg_repeat_type); - static std::optional -ArgRepetitionFromString(llvm::StringRef string); + static std::optional + ArgRepetitionFromString(llvm::StringRef string); bool ParseOptions(Args &args, CommandReturnObject &result); diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index 4dce5f40328d..2a7dcf73a429 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -476,11 +476,12 @@ public: return false; } - virtual bool RunScriptBasedParsedCommand( - StructuredData::GenericSP impl_obj_sp, Args& args, - ScriptedCommandSynchronicity synchronicity, - lldb_private::CommandReturnObject &cmd_retobj, Status &error, - const lldb_private::ExecutionContext &exe_ctx) { + virtual bool + RunScriptBasedParsedCommand(StructuredData::GenericSP impl_obj_sp, Args &args, + ScriptedCommandSynchronicity synchronicity, + lldb_private::CommandReturnObject &cmd_retobj, + Status &error, + const lldb_private::ExecutionContext &exe_ctx) { return false; } @@ -528,7 +529,7 @@ public: dest.clear(); return false; } - + virtual StructuredData::ObjectSP GetOptionsForCommandObject(StructuredData::GenericSP cmd_obj_sp) { return {}; @@ -538,15 +539,15 @@ public: GetArgumentsForCommandObject(StructuredData::GenericSP cmd_obj_sp) { return {}; } - + virtual bool SetOptionValueForCommandObject( - StructuredData::GenericSP cmd_obj_sp, ExecutionContext *exe_ctx, + StructuredData::GenericSP cmd_obj_sp, ExecutionContext *exe_ctx, llvm::StringRef long_option, llvm::StringRef value) { return false; } - virtual void OptionParsingStartedForCommandObject( - StructuredData::GenericSP cmd_obj_sp) { + virtual void + OptionParsingStartedForCommandObject(StructuredData::GenericSP cmd_obj_sp) { return; } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 1e7227767eb9..96d7455499f3 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1258,7 +1258,6 @@ private: CompletionType m_completion_type = eNoCompletion; }; - /// This command implements a lldb parsed scripted command. The command /// provides a definition of the options and arguments, and a option value /// setting callback, and then the command's execution function gets passed @@ -1270,22 +1269,22 @@ private: /// So I've also added a base class in Python that provides a table-driven /// way of defining the options and arguments, which automatically fills the /// option values, making them available as properties in Python. -/// +/// class CommandObjectScriptingObjectParsed : public CommandObjectParsed { -private: +private: class CommandOptions : public Options { public: -CommandOptions(CommandInterpreter &interpreter, -StructuredData::GenericSP cmd_obj_sp) : m_interpreter(interpreter), -m_cmd_obj_sp(cmd_obj_sp) {} +CommandOptions(CommandInterpreter &interpreter, + StructuredData::GenericSP cmd_obj_sp) +: m_interpreter(interpreter), m_cmd_obj_sp(cmd_obj_sp) {} ~CommandOptions() override = default; Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Status error; - ScriptInterpreter *scripter = -m_interpreter.GetDebugger().GetScriptInterpreter(); + ScriptInterpreter *scripter =
[Lldb-commits] [lldb] Support target names containing dots in all utilities (PR #65812)
https://github.com/dankm edited https://github.com/llvm/llvm-project/pull/65812 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)
tuliom wrote: Do you know what is the reason for requiring such an old Python version? I'm asking because it's been hard to find a distro that provides both Python 3.6 (released in 2016) and cmake 3.20 (released in 2021). For the record, Ubuntu 18.04 does have Python 3.6, but it has cmake 3.10. https://github.com/llvm/llvm-project/pull/70443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4b3cd37 - [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (#70392)
Author: Med Ismail Bennani Date: 2023-10-30T16:52:17-07:00 New Revision: 4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce URL: https://github.com/llvm/llvm-project/commit/4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce DIFF: https://github.com/llvm/llvm-project/commit/4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce.diff LOG: [lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392) This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. Signed-off-by: Med Ismail Bennani Added: lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h Modified: lldb/bindings/python/python-swigsafecast.swig lldb/bindings/python/python-wrapper.swig lldb/include/lldb/API/SBEvent.h lldb/include/lldb/API/SBStream.h lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/include/lldb/Target/ThreadPlanPython.h lldb/include/lldb/lldb-forward.h lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h lldb/source/Target/ThreadPlanPython.cpp lldb/test/API/functionalities/step_scripted/Steps.py lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Removed: diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig index d5ea5148727134d..fba3a77d8f2df44 100644 --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -37,10 +37,6 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) { return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError); } -PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr stream_sb) { - return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream); -} - PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr data_sb) { return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData); } @@ -115,9 +111,12 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) { SWIGTYPE_p_lldb__SBCommandReturnObject); } -ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) { - return ScopedPythonObject(new lldb::SBEvent(event), - SWIGTYPE_p_lldb__SBEvent); +PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) { + return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream); +} + +PythonObject SWIGBridge::ToSWIGWrapper(Event *event) { + return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent); } PythonObject SWIGBridge::ToSWIGWrapper( diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index 17bc7b1f2198709..5c28d652824073a 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -229,133 +229,6 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict); } -PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan( -const char *python_class_name, const char *session_dictionary_name, -const lldb_private::StructuredDataImpl &args_impl, -std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) { - if (python_class_name == NULL || python_class_name[0] == '\0' || - !session_dictionary_name) -return PythonObject(); - - PyErr_Cleaner py_err_cleaner(true); - - auto dict = PythonModule::MainModule().ResolveName( - session_dictionary_name); - auto pfunc = PythonObject::ResolveN
[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)
https://github.com/medismailben closed https://github.com/llvm/llvm-project/pull/70392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add the ability to get a C++ vtable ValueObject from another ValueObj… (PR #67599)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/67599 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7fbd427 - Add the ability to get a C++ vtable ValueObject from another ValueObj… (#67599)
Author: Greg Clayton Date: 2023-10-30T17:46:18-07:00 New Revision: 7fbd427f5ebea4a4ebf25747758851875bb7e173 URL: https://github.com/llvm/llvm-project/commit/7fbd427f5ebea4a4ebf25747758851875bb7e173 DIFF: https://github.com/llvm/llvm-project/commit/7fbd427f5ebea4a4ebf25747758851875bb7e173.diff LOG: Add the ability to get a C++ vtable ValueObject from another ValueObj… (#67599) Add the ability to get a C++ vtable ValueObject from another ValueObject. This patch adds the ability to ask a ValueObject for a ValueObject that represents the virtual function table for a C++ class. If the ValueObject is not a C++ class with a vtable, a valid ValueObject value will be returned that contains an appropriate error. If it is successful a valid ValueObject that represents vtable will be returned. The ValueObject that is returned will have a name that matches the demangled value for a C++ vtable mangled name like "vtable for ". It will have N children, one for each virtual function pointer. Each child's value is the function pointer itself, the summary is the symbolication of this function pointer, and the type will be a valid function pointer from the debug info if there is debug information corresponding to the virtual function pointer. The vtable SBValue will have the following: - SBValue::GetName() returns "vtable for " - SBValue::GetValue() returns a string representation of the vtable address - SBValue::GetSummary() returns NULL - SBValue::GetType() returns a type appropriate for a uintptr_t type for the current process - SBValue::GetLoadAddress() returns the address of the vtable adderess - SBValue::GetValueAsUnsigned(...) returns the vtable address - SBValue::GetNumChildren() returns the number of virtual function pointers in the vtable - SBValue::GetChildAtIndex(...) returns a SBValue that represents a virtual function pointer The child SBValue objects that represent a virtual function pointer has the following values: - SBValue::GetName() returns "[%u]" where %u is the vtable function pointer index - SBValue::GetValue() returns a string representation of the virtual function pointer - SBValue::GetSummary() returns a symbolicated respresentation of the virtual function pointer - SBValue::GetType() returns the function prototype type if there is debug info, or a generic funtion prototype if there is no debug info - SBValue::GetLoadAddress() returns the address of the virtual function pointer - SBValue::GetValueAsUnsigned(...) returns the virtual function pointer - SBValue::GetNumChildren() returns 0 - SBValue::GetChildAtIndex(...) returns invalid SBValue for any index Examples of using this API via python: ``` (lldb) script vtable = lldb.frame.FindVariable("shape_ptr").GetVTable() (lldb) script vtable vtable for Shape = 0x00014088 { [0] = 0x00013d20 a.out`Shape::~Shape() at main.cpp:3 [1] = 0x00013e4c a.out`Shape::~Shape() at main.cpp:3 [2] = 0x00013e7c a.out`Shape::area() at main.cpp:4 [3] = 0x00013e3c a.out`Shape::optional() at main.cpp:7 } (lldb) script c = vtable.GetChildAtIndex(0) (lldb) script c (void ()) [0] = 0x00013d20 a.out`Shape::~Shape() at main.cpp:3 ``` Added: lldb/include/lldb/Core/ValueObjectVTable.h lldb/source/Core/ValueObjectVTable.cpp lldb/test/API/functionalities/vtable/Makefile lldb/test/API/functionalities/vtable/TestVTableValue.py lldb/test/API/functionalities/vtable/main.cpp Modified: lldb/bindings/interface/SBTypeDocstrings.i lldb/include/lldb/API/SBValue.h lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectChild.h lldb/include/lldb/Symbol/Type.h lldb/include/lldb/Symbol/TypeSystem.h lldb/include/lldb/Target/LanguageRuntime.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBValue.cpp lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Core/CMakeLists.txt lldb/source/Core/ValueObject.cpp lldb/source/DataFormatters/CXXFunctionPointer.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/source/Symbol/Type.cpp Removed: diff --git a/lldb/bindings/interface/SBTypeDocstrings.i b/lldb/bindings/interface/SBTypeDocstrings.i index c49e9647ba0463c..b056354922094f7 100644 --- a/lldb/bindings/interface/SBTypeDocstrings.i +++ b/lldb/bindings/interface/SBTypeDocstrings.i @@ -139,19 +139,6 @@ SBType supports the eq/ne operator. For example,:: " ) lldb::SBType::IsReferenceType; -%feature("docstring", -"Returns true if this type is a function type. - -Language-specific behaviour: - -* C: Returns true for
[Lldb-commits] [lldb] Add the ability to get a C++ vtable ValueObject from another ValueObj… (PR #67599)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6eafe2cb7a3286c1b13eea7d8370374553fe81a9 f06cd76bd05f95277dced786ac3ca3e83f2e8779 -- lldb/include/lldb/Core/ValueObjectVTable.h lldb/source/Core/ValueObjectVTable.cpp lldb/test/API/functionalities/vtable/main.cpp lldb/include/lldb/API/SBValue.h lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectChild.h lldb/include/lldb/Symbol/Type.h lldb/include/lldb/Symbol/TypeSystem.h lldb/include/lldb/Target/LanguageRuntime.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBValue.cpp lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Core/ValueObject.cpp lldb/source/DataFormatters/CXXFunctionPointer.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/source/Symbol/Type.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index a2a9c0163..749f78170 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -78,9 +78,8 @@ public: virtual bool GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0; - struct VTableInfo { -Address addr; /// Address of the vtable's virtual function table +Address addr; /// Address of the vtable's virtual function table Symbol *symbol; /// The vtable symbol from the symbol table }; /// Get the vtable information for a given value. diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 34d01d759..8f6367da8 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -1038,9 +1038,9 @@ lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const { // IsValid means that the SBValue has a value in it. But that's not the // only time that ValueObjects are useful. We also want to return the value // if there's an error state in it. - if (!m_opaque_sp || (!m_opaque_sp->IsValid() - && (m_opaque_sp->GetRootSP() - && !m_opaque_sp->GetRootSP()->GetError().Fail( { + if (!m_opaque_sp || (!m_opaque_sp->IsValid() && + (m_opaque_sp->GetRootSP() && +!m_opaque_sp->GetRootSP()->GetError().Fail( { locker.GetError().SetErrorString("No value"); return ValueObjectSP(); } diff --git a/lldb/source/Core/ValueObjectVTable.cpp b/lldb/source/Core/ValueObjectVTable.cpp index 177ae4167..fb4dc7530 100644 --- a/lldb/source/Core/ValueObjectVTable.cpp +++ b/lldb/source/Core/ValueObjectVTable.cpp @@ -82,7 +82,6 @@ protected: return false; } - // Set our value to be the load address of the function pointer in memory // and our type to be the function pointer type. m_value.SetValueType(Value::ValueType::LoadAddress); @@ -107,7 +106,7 @@ protected: // the language from it correctly. ValueObject *val = parent->GetParent(); auto type_system = target_sp->GetScratchTypeSystemForLanguage( -val ? val->GetObjectRuntimeLanguage() : eLanguageTypeC_plus_plus); + val ? val->GetObjectRuntimeLanguage() : eLanguageTypeC_plus_plus); if (type_system) { m_value.SetCompilerType( (*type_system)->CreateGenericFunctionPrototype().GetPointerType()); @@ -122,7 +121,7 @@ protected: if (m_error.Success()) { const bool thread_and_frame_only_if_stopped = true; ExecutionContext exe_ctx( -GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped)); + GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped)); m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get()); } SetValueDidChange(true); @@ -257,7 +256,7 @@ bool ValueObjectVTable::UpdateValue() { m_value.SetValueType(Value::ValueType::LoadAddress); m_value.GetScalar() = parent->GetAddressOf(); auto type_system_or_err = -target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC_plus_plus); + target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC_plus_plus); if (type_system_or_err) { m_value.SetCompilerType( (*type_system_or_err)->GetBasicTypeFromAST(eBasicTypeUnsignedLong)); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 17c8b4357..eee70bf74 100644 --- a/lldb/source/Plugins/LanguageRuntime/
[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)
@@ -614,6 +614,8 @@ class Process : public std::enable_shared_from_this, return error; } + virtual void DidLoadCore() {} clayborg wrote: Yeah, I checked and none of the core file plug-ins currently override the DidAttach() (mach-o, ELF or minidump). https://github.com/llvm/llvm-project/pull/70351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,140 @@ +//===-- WatchpointResource.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H +#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H + +#include "lldb/Breakpoint/WatchpointCollection.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointResource +: public std::enable_shared_from_this { + +public: + // Constructors and Destructors + WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write); + + ~WatchpointResource(); + + void GetMemoryRange(lldb::addr_t &addr, size_t &size) const; + + lldb::addr_t GetAddress() const; + + size_t GetByteSize() const; + + void GetType(bool &read, bool &write) const; + + void SetType(bool read, bool write); + + /// The "Owners" are the watchpoints that share this resource. + /// The method adds the \a owner to this resource's owner list. + /// + /// \param[in] owner + ///\a owner is the Wachpoint to add. + void AddOwner(const lldb::WatchpointSP &owner); + + /// The method removes the owner at \a owner from this watchpoint + /// resource. + void RemoveOwner(lldb::WatchpointSP &owner); + + /// This method returns the number of Watchpoints currently using + /// watchpoint resource. + /// + /// \return + ///The number of owners. + size_t GetNumberOfOwners(); + + /// This method returns the Watchpoint at index \a index using this + /// Resource. The owners are listed ordinally from 0 to + /// GetNumberOfOwners() - 1 so you can use this method to iterate over the + /// owners. + /// + /// \param[in] idx + /// The index in the list of owners for which you wish the owner location. + /// + /// \return + ///The Watchpoint at that index. + lldb::WatchpointSP GetOwnerAtIndex(size_t idx); jasonmolenda wrote: Just getting back to the review comments. I remember writing something about this last week but we have some API to select specific BreakpointLocations that own the BreakpointSite and the code to do that is most naturally exposed as "GetAtIndex" style access. I'm trying to create the WatchpointResource class similar to BreakpointSite so I can follow the same coding style for these Watchpoints that own the WatchpointResources. I may end up being able to drop the GetAtIndex method later if it's natural go access it via an Owners method, but I'm starting with the assumption that this will be more natural. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,155 @@ +//===-- WatchpointResource.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H +#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H + +#include "lldb/Utility/Iterable.h" +#include "lldb/lldb-public.h" + +#include +#include + +namespace lldb_private { + +class WatchpointResource +: public std::enable_shared_from_this { + +public: + // Constructors and Destructors + WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write); + + ~WatchpointResource(); + + lldb::addr_t GetAddress() const; + + size_t GetByteSize() const; + + bool WatchpointResourceRead() const; + + bool WatchpointResourceWrite() const; + + void SetType(bool read, bool write); + + typedef std::vector WatchpointCollection; + typedef LockingAdaptedIterable + WatchpointIterable; + + /// Iterate over the watchpoint owners for this resource + /// + /// \return + /// An Iterable object which can be used to loop over the watchpoints + /// that are owners of this resource. + WatchpointIterable Owners() { +return WatchpointIterable(m_owners, m_owners_mutex); + } + + /// The "Owners" are the watchpoints that share this resource. + /// The method adds the \a owner to this resource's owner list. + /// + /// \param[in] owner + ///\a owner is the Wachpoint to add. + void AddOwner(const lldb::WatchpointSP &owner); + + /// The method removes the owner at \a owner from this watchpoint + /// resource. + void RemoveOwner(lldb::WatchpointSP &owner); + + /// This method returns the number of Watchpoints currently using + /// watchpoint resource. + /// + /// \return + ///The number of owners. + size_t GetNumberOfOwners(); + + /// This method returns the Watchpoint at index \a index using this + /// Resource. The owners are listed ordinally from 0 to + /// GetNumberOfOwners() - 1 so you can use this method to iterate over the + /// owners. + /// + /// \param[in] idx + /// The index in the list of owners for which you wish the owner location. + /// + /// \return + ///The Watchpoint at that index. + lldb::WatchpointSP GetOwnerAtIndex(size_t idx); + + /// Check if the owners includes a watchpoint. + /// + /// \param[in] wp_sp + /// The WatchpointSP to search for. + /// + /// \result + /// true if this resource's owners includes the watchpoint. + bool OwnersContains(lldb::WatchpointSP &wp_sp); + + /// Check if the owners includes a watchpoint. + /// + /// \param[in] wp + /// The Watchpoint to search for. + /// + /// \result + /// true if this resource's owners includes the watchpoint. + bool OwnersContains(const lldb_private::Watchpoint *wp); + + /// This method copies the watchpoint resource's owners into a new collection. + /// It does this while the owners mutex is locked. + /// + /// \param[out] out_collection + ///The BreakpointLocationCollection into which to put the owners + ///of this breakpoint site. + /// + /// \return + ///The number of elements copied into out_collection. + size_t CopyOwnersList(WatchpointCollection &out_collection); + + // The ID of the WatchpointResource is set by the WatchpointResourceList + // when the Resource has been set in the inferior and is being added + // to the List, in an attempt to match the hardware watchpoint register + // ordering. If a Process can correctly identify the hardware watchpoint + // register index when it has created the Resource, it may initialize it + // before it is inserted in the WatchpointResourceList. + void SetID(lldb::wp_resource_id_t); + + lldb::wp_resource_id_t GetID() const; + + bool Contains(lldb::addr_t addr); + +protected: + // The StopInfoWatchpoint knows when it is processing a hit for a thread for + // a site, so let it be the one to manage setting the location hit count once + // and only once. + friend class StopInfoWatchpoint; + + void BumpHitCounts(); + +private: + lldb::wp_resource_id_t m_id; + + // start address & size aligned & expanded to be a valid watchpoint + // memory granule on this target. + lldb::addr_t m_addr; + size_t m_size; + + bool m_watch_read; // true if we stop when the watched data is read from + bool m_watch_write; // true if we stop when the watched data is written to + + // The watchpoints using this WatchpointResource. + WatchpointCollection m_owners; + + std::recursive_mutex + m_owners_mutex; ///< This mutex protects the owners collection. jasonmolenda wrote: No, I was just copying BreakpointSite when I used that. https://github.com/llvm/llvm-project/pull/68845
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -266,33 +268,73 @@ void Watchpoint::Dump(Stream *s) const { // If prefix is nullptr, we display the watch id and ignore the prefix // altogether. -void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { - if (!prefix) { -s->Printf("\nWatchpoint %u hit:", GetID()); -prefix = ""; - } +bool Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { + bool printed_anything = false; jasonmolenda wrote: The convention for these methods seems to be to return a stream without a final end-of-line character. In StopInfo.cpp we call this method and check if it printed anything, and if so, print an EOL. In Watchpoint::DumpWithLevel we ignore the return type from DumpSnapshots, but that's only because every line it adds is assumed to end without an EOL. I don't really need a variable in this method, I could return false in the two places it is false and true in the one place it is true. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,146 @@ +//===-- WatchpointResourceList.h *- C++ -*-===// jasonmolenda wrote: I think it's the same except for the obvious BreakpointSite/WatchpointResource and BreakpointLocation/Watchpoint. It's a little tricky reading through BreakpointSiteList.h to tell if all of the arguments refer to BreakpointLocations (they do it by id values) or if they might refer to Breakpoints - they seem to all use the same `break_id_t`? (and `break_id_t` is also used for the BreakpointSite numbers); sometimes the arguments are called `bp_id` and sometimes they're called `BreakID` but I THINK they're always referring to BreakpointLocations. It'd be nice if BreakpointSite and WatchpointResource could inherit from the same base class and have the StopPointList work in terms of the base class methods, but I think there's enough difference between these two that this might not work very cleanly. Maybe a templated StopPointList could work though. I'll need to look at that. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang] [flang] [lldb] [libcxxabi] [mlir] [libcxx] [Clang][LoongArch] Support builtin functions for LSX and LASX (PR #70404)
https://github.com/yjijd closed https://github.com/llvm/llvm-project/pull/70404 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] On AArch64, reconfigure register context first (PR #70742)
@@ -1642,9 +1642,22 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( } ThreadGDBRemote *gdb_thread = static_cast(thread_sp.get()); - RegisterContextSP gdb_reg_ctx_sp(gdb_thread->GetRegisterContext()); + RegisterContextSP reg_ctx_sp(gdb_thread->GetRegisterContext()); - gdb_reg_ctx_sp->InvalidateIfNeeded(true); + reg_ctx_sp->InvalidateIfNeeded(true); + + // AArch64 SVE/SME specific code below updates SVE and ZA register sizes and + // offsets if value of VG or SVG registers has changed since last stop. + const ArchSpec &arch = GetTarget().GetArchitecture(); + if (arch.IsValid() && arch.GetTriple().isAArch64()) { medismailben wrote: I know this patch just moves code around but it feels a bit wrong that `ProcessGDBRemote` has some architecture dependent code ... May be we should do this special handling in `ABIAArch64` and call something like `GetABI().ReconfigureRegisters(DynamicRegisterInfo&)` instead. https://github.com/llvm/llvm-project/pull/70742 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits