[Lldb-commits] [lldb] a1ffabc - [lldb][riscv] Fix setting breakpoint for undecoded instruction (#90075)
Author: ita-sc Date: 2024-07-16T10:03:42+01:00 New Revision: a1ffabc403d4ce55ab2e665511b0b68a16d4850b URL: https://github.com/llvm/llvm-project/commit/a1ffabc403d4ce55ab2e665511b0b68a16d4850b DIFF: https://github.com/llvm/llvm-project/commit/a1ffabc403d4ce55ab2e665511b0b68a16d4850b.diff LOG: [lldb][riscv] Fix setting breakpoint for undecoded instruction (#90075) This patch adds an interface GetLastInstrSize to get information about the size of last tried to be decoded instruction and uses it to set software breakpoint if the memory can be decoded as instruction. RISC-V architecture instruction format specifies the length of instruction in first bits, so we can set a breakpoint for these cases. This is needed as RISCV have a lot of extensions, that are not supported by `EmulateInstructionRISCV`. Added: lldb/test/API/riscv/break-undecoded/Makefile lldb/test/API/riscv/break-undecoded/TestBreakpointIllegal.py lldb/test/API/riscv/break-undecoded/compressed.c lldb/test/API/riscv/break-undecoded/main.c Modified: lldb/include/lldb/Core/EmulateInstruction.h lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp Removed: diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index 93c16537adba1..b459476883fc5 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -369,6 +369,8 @@ class EmulateInstruction : public PluginInterface { virtual bool ReadInstruction() = 0; + virtual std::optional GetLastInstrSize() { return std::nullopt; } + virtual bool EvaluateInstruction(uint32_t evaluate_options) = 0; virtual InstructionCondition GetInstructionCondition() { diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 6c46618b337c2..3f61e011d620a 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -624,9 +624,26 @@ std::optional EmulateInstructionRISCV::Decode(uint32_t inst) { uint16_t try_rvc = uint16_t(inst & 0x); // check whether the compressed encode could be valid uint16_t mask = try_rvc & 0b11; - bool is_rvc = try_rvc != 0 && mask != 3; uint8_t inst_type = RV64; + // Try to get size of RISCV instruction. + // 1.2 Instruction Length Encoding + bool is_16b = (inst & 0b11) != 0b11; + bool is_32b = (inst & 0x1f) != 0x1f; + bool is_48b = (inst & 0x3f) != 0x1f; + bool is_64b = (inst & 0x7f) != 0x3f; + if (is_16b) +m_last_size = 2; + else if (is_32b) +m_last_size = 4; + else if (is_48b) +m_last_size = 6; + else if (is_64b) +m_last_size = 8; + else +// Not Valid +m_last_size = std::nullopt; + // if we have ArchSpec::eCore_riscv128 in the future, // we also need to check it here if (m_arch.GetCore() == ArchSpec::eCore_riscv32) @@ -638,8 +655,8 @@ std::optional EmulateInstructionRISCV::Decode(uint32_t inst) { LLDB_LOGF( log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was decoded to %s", __FUNCTION__, inst, m_addr, pat.name); - auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst); - return DecodeResult{decoded, inst, is_rvc, pat}; + auto decoded = is_16b ? pat.decode(try_rvc) : pat.decode(inst); + return DecodeResult{decoded, inst, is_16b, pat}; } } LLDB_LOGF(log, "EmulateInstructionRISCV::%s: inst(0x%x) was unsupported", diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h index 8bca73a7f589d..53ac11c2e1102 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h @@ -60,6 +60,7 @@ class EmulateInstructionRISCV : public EmulateInstruction { bool SetTargetTriple(const ArchSpec &arch) override; bool ReadInstruction() override; + std::optional GetLastInstrSize() override { return m_last_size; } bool EvaluateInstruction(uint32_t options) override; bool TestEmulation(Stream &out_stream, ArchSpec &arch, OptionValueDictionary *test_data) override; @@ -99,6 +100,8 @@ class EmulateInstructionRISCV : public EmulateInstruction { private: /// Last decoded instruction from m_opcode DecodeResult m_decoded; + /// Last decoded instruction size estimate. + std::optional m_last_size; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp inde
[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/90075 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] [CMake] added static libraries and LLDB packaging (PR #98829)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/98829 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 078cb7a - [lldb][RISC-V] Remove unused variable
Author: David Spickett Date: 2024-07-16T09:46:40Z New Revision: 078cb7a4a07582a39ecd2f2fba9e9b1add9ebff3 URL: https://github.com/llvm/llvm-project/commit/078cb7a4a07582a39ecd2f2fba9e9b1add9ebff3 DIFF: https://github.com/llvm/llvm-project/commit/078cb7a4a07582a39ecd2f2fba9e9b1add9ebff3.diff LOG: [lldb][RISC-V] Remove unused variable Added in a1ffabc403d4ce55ab2e665511b0b68a16d4850b. Added: Modified: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp Removed: diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 3f61e011d620a..e8014b1eeb378 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -622,8 +622,6 @@ std::optional EmulateInstructionRISCV::Decode(uint32_t inst) { Log *log = GetLog(LLDBLog::Unwind); uint16_t try_rvc = uint16_t(inst & 0x); - // check whether the compressed encode could be valid - uint16_t mask = try_rvc & 0b11; uint8_t inst_type = RV64; // Try to get size of RISCV instruction. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/99012 This is a follow-up to https://github.com/llvm/llvm-project/pull/98330 for the upcoming `__compressed_pair` refactor in https://github.com/llvm/llvm-project/issues/93069 This patch just adds the 2 new copies of `_LIBCPP_COMPRESSED_PAIR` layouts to the simulator tests. >From 242f78b67d6d6ef125b72c9c797fb2686cce280d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 10 Jul 2024 15:37:45 +0100 Subject: [PATCH] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests --- .../compressed_pair.h | 34 ++- .../TestDataFormatterLibcxxStringSimulator.py | 19 ++- .../libcxx-simulators/string/main.cpp | 33 +++--- ...stDataFormatterLibcxxUniquePtrSimulator.py | 14 ++-- .../libcxx-simulators/unique_ptr/main.cpp | 5 +++ 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h index 026e7183ab27a..f2c1b626bd46f 100644 --- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h +++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h @@ -7,7 +7,7 @@ namespace std { namespace __lldb { -// Post-c88580c layout +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout struct __value_init_tag {}; struct __default_init_tag {}; @@ -52,6 +52,38 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } }; +#elif COMPRESSED_PAIR_REV == 1 +template class __compressed_pair_padding { + char __padding_[(is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) + ? 0 + : sizeof(_ToPad) - __datasizeof(_ToPad)]; +}; + +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)), \ +__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; \ + [[no_unique_address]] T3 Initializer3; \ + [[no_unique_address]] __compressed_pair_padding __padding3_; +#elif COMPRESSED_PAIR_REV == 2 +#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2 + +#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2; \ + [[no_unique_address]] T3 Name3 +#endif } // namespace __lldb } // namespace std diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py index 3e5c493692c4f..0d4270ef58568 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py @@ -25,12 +25,13 @@ def _run_test(self, defines): for v in [None, "ALTERNATE_LAYOUT"]: for r in range(5): -name = "test_r%d" % r -defines = ["REVISION=%d" % r] -if v: -name += "_" + v -defines += [v] -f = functools.partialmethod( -LibcxxStringDataFormatterSimulatorTestCase._run_test, defines -) -setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f) +for c in range(3): +name = "test_r%d_c%d" % (r, c) +defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c] +if v: +name += "_" + v +defines += [v] +f = functools.partialmethod( +
[Lldb-commits] [lldb] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)
@@ -183,31 +183,40 @@ template class basic_string { }; }; +#if COMPRESSED_PAIR_REV == 0 std::__lldb::__compressed_pair<__rep, allocator_type> __r_; +#define __R_ __r_ Michael137 wrote: Probably more readable if I just replaced all the `__r_.first().XXX` accesses with calls to `setXXX` or something https://github.com/llvm/llvm-project/pull/99012 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)
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 27d961dab3caa89a78e68af094ddc8365d97dc91...242f78b67d6d6ef125b72c9c797fb2686cce280d lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py `` View the diff from darker here. ``diff --- unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py 2024-07-16 07:29:55.00 + +++ unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py 2024-07-16 10:08:14.898197 + @@ -23,10 +23,11 @@ self.expect("frame variable var_up", substrs=["deleter ="], matching=False) self.expect( "frame variable var_with_deleter_up", substrs=["pointer =", "deleter ="] ) + for r in range(3): name = "test_r%d" % r defines = ["COMPRESSED_PAIR_REV=%d" % r] f = functools.partialmethod( LibcxxUniquePtrDataFormatterSimulatorTestCase._run_test, defines `` https://github.com/llvm/llvm-project/pull/99012 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Make 'process load' take remote os path delimiter into account (PR #98690)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/98690 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the error `unable to launch a GDB server` in API tests (PR #98833)
DavidSpickett wrote: Did you consider making `AllowPort(0)` do nothing? My guess is that this port dance is complicated enough as it is, and `AllowPort(0)` doing nothing would be more implicit behaviour we have to pick apart later. https://github.com/llvm/llvm-project/pull/98833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/labath approved this pull request. Looks good. Third time's the charm. https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
@@ -1595,49 +1627,67 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { if (qualified_name.empty()) qualified_name.append("::"); - qualified_name.append(name); + qualified_name.append(unique_typename.GetCString()); qualified_name.append(GetDIEClassTemplateParams(die)); - return qualified_name; + unique_typename = ConstString(qualified_name); } TypeSP DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, - const DWARFDIE &decl_die, + const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs) { CompilerType clang_type; - const dw_tag_t tag = decl_die.Tag(); - SymbolFileDWARF *dwarf = decl_die.GetDWARF(); - LanguageType cu_language = SymbolFileDWARF::GetLanguage(*decl_die.GetCU()); + const dw_tag_t tag = die.Tag(); + SymbolFileDWARF *dwarf = die.GetDWARF(); + LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU()); Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - // UniqueDWARFASTType is large, so don't create a local variables on the - // stack, put it on the heap. This function is often called recursively and - // clang isn't good at sharing the stack space for variables in different - // blocks. - auto unique_ast_entry_up = std::make_unique(); - ConstString unique_typename(attrs.name); Declaration unique_decl(attrs.decl); + uint64_t byte_size = attrs.byte_size.value_or(0); + if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && + !die.HasChildren() && cu_language == eLanguageTypeObjC) { +// Work around an issue with clang at the moment where forward +// declarations for objective C classes are emitted as: +// DW_TAG_structure_type [2] +// DW_AT_name( "ForwardObjcClass" ) +// DW_AT_byte_size( 0x00 ) +// DW_AT_decl_file( "..." ) +// DW_AT_decl_line( 1 ) +// +// Note that there is no DW_AT_declaration and there are no children, +// and the byte size is zero. +attrs.is_forward_declaration = true; + } if (attrs.name) { -if (Language::LanguageIsCPlusPlus(cu_language)) { - // For C++, we rely solely upon the one definition rule that says - // only one thing can exist at a given decl context. We ignore the - // file and line that things are declared on. - std::string qualified_name = GetCPlusPlusQualifiedName(decl_die); - if (!qualified_name.empty()) -unique_typename = ConstString(qualified_name); - unique_decl.Clear(); -} - -if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, decl_die, unique_decl, -attrs.byte_size.value_or(-1), *unique_ast_entry_up)) { - if (TypeSP type_sp = unique_ast_entry_up->m_type_sp) { +GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename, +unique_decl); +if (UniqueDWARFASTType *unique_ast_entry_type = +dwarf->GetUniqueDWARFASTTypeMap().Find( +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration)) { + if (TypeSP type_sp = unique_ast_entry_type->m_type_sp) { +dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( -GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), -decl_die); +GetCachedClangDeclContextForDIE(unique_ast_entry_type->m_die), die); +// If the DIE being parsed in this function is a definition and the +// entry in the map is a declaration, then we need to update the entry +// to point to the definition DIE. +if (!attrs.is_forward_declaration && +unique_ast_entry_type->m_is_forward_declaration) { + unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size); + clang_type = type_sp->GetForwardCompilerType(); + + CompilerType compiler_type_no_qualifiers = + ClangUtil::RemoveFastQualifiers(clang_type); + auto result = dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace( + compiler_type_no_qualifiers.GetOpaqueQualType(), + *die.GetDIERef()); + if (!result.second) +result.first->second = *die.GetDIERef(); labath wrote: All this is just `dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(compiler_type_no_qualifiers.GetOpaqueQualType(), *die.GetDIERef())`, right? https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)
@@ -10,9 +10,10 @@ class TestDAP_stepInTargets(lldbdap_testcase.DAPTestCaseBase): -@skipIf( -archs=no_match(["x86_64"]) -) # InstructionControlFlowKind for ARM is not supported yet. +@skipIf +# InstructionControlFlowKind for ARM is not supported yet. +# On x86_64 lldb-dap seems to ignore targetId when stepping into functions. labath wrote: Great, that's exactly what I had in mind. Thanks. https://github.com/llvm/llvm-project/pull/96687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2ea4a03 - Fix test assertions in TestDAP_stepInTargets.py (#96687)
Author: Kendal Harland Date: 2024-07-16T12:59:08+02:00 New Revision: 2ea4a03c0f1be6dd11428e4c6eb840b745116ca2 URL: https://github.com/llvm/llvm-project/commit/2ea4a03c0f1be6dd11428e4c6eb840b745116ca2 DIFF: https://github.com/llvm/llvm-project/commit/2ea4a03c0f1be6dd11428e4c6eb840b745116ca2.diff LOG: Fix test assertions in TestDAP_stepInTargets.py (#96687) The strings this test is using seem to consistently fail to match against the expected values when built & run targeting Windows amd64. This PR updates them to the expected values. To fix the test and avoid over-specifying for a specific platform, use `assertIn(,...)` to see if we've got the correct target label instead of comparing the demangler output for an exact string match. - Co-authored-by: kendal Added: Modified: lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp Removed: diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py index 6296f6554d07e..07acfe07c9ffc 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py @@ -10,9 +10,11 @@ class TestDAP_stepInTargets(lldbdap_testcase.DAPTestCaseBase): -@skipIf( -archs=no_match(["x86_64"]) -) # InstructionControlFlowKind for ARM is not supported yet. +@expectedFailureAll(oslist=["windows"]) +@skipIf(archs=no_match(["x86_64"])) +# InstructionControlFlowKind for ARM is not supported yet. +# On Windows, lldb-dap seems to ignore targetId when stepping into functions. +# For more context, see https://github.com/llvm/llvm-project/issues/98509. def test_basic(self): """ Tests the basic stepping in targets with directly calls. @@ -55,14 +57,24 @@ def test_basic(self): self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets") # Verify the target names are correct. -self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()") -self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect bar2()") -self.assertEqual( -step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, int)" -) +# The order of funcA and funcB may change depending on the compiler ABI. +funcA_target = None +funcB_target = None +for target in step_in_targets[0:2]: +if "funcB" in target["label"]: +funcB_target = target +elif "funcA" in target["label"]: +funcA_target = target +else: +self.fail(f"Unexpected step in target: {target}") + +self.assertIsNotNone(funcA_target, "expect funcA") +self.assertIsNotNone(funcB_target, "expect funcB") +self.assertIn("foo", step_in_targets[2]["label"], "expect foo") -# Choose to step into second target and verify that we are in bar2() +# Choose to step into second target and verify that we are in the second target, +# be it funcA or funcB. self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], waitForStop=True) leaf_frame = self.dap_server.get_stackFrame() self.assertIsNotNone(leaf_frame, "expect a leaf frame") -self.assertEqual(leaf_frame["name"], "bar2()") +self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"]) diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp index d3c3dbcc139ef..a48b79af0c760 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp @@ -1,11 +1,11 @@ int foo(int val, int extra) { return val + extra; } -int bar() { return 22; } +int funcA() { return 22; } -int bar2() { return 54; } +int funcB() { return 54; } int main(int argc, char const *argv[]) { - foo(bar(), bar2()); // set breakpoint here + foo(funcA(), funcB()); // set breakpoint here return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/96687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)
github-actions[bot] wrote: @kendalharland Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/96687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/Michael137 approved this pull request. I like where we ended up with this. LGTM (with two minor nits) https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
@@ -1595,49 +1627,67 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { if (qualified_name.empty()) qualified_name.append("::"); - qualified_name.append(name); + qualified_name.append(unique_typename.GetCString()); qualified_name.append(GetDIEClassTemplateParams(die)); - return qualified_name; + unique_typename = ConstString(qualified_name); Michael137 wrote: Nit: I'd find it slightly clearer if we returned the new name like the old function did (probably don't even need the parameter to be a `ConstString`) https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
@@ -1659,128 +1709,56 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, default_accessibility = eAccessPrivate; } - if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && - !decl_die.HasChildren() && cu_language == eLanguageTypeObjC) { -// Work around an issue with clang at the moment where forward -// declarations for objective C classes are emitted as: -// DW_TAG_structure_type [2] -// DW_AT_name( "ForwardObjcClass" ) -// DW_AT_byte_size( 0x00 ) -// DW_AT_decl_file( "..." ) -// DW_AT_decl_line( 1 ) -// -// Note that there is no DW_AT_declaration and there are no children, -// and the byte size is zero. -attrs.is_forward_declaration = true; - } + if ((attrs.class_language == eLanguageTypeObjC || + attrs.class_language == eLanguageTypeObjC_plus_plus) && + !attrs.is_complete_objc_class && + die.Supports_DW_AT_APPLE_objc_complete_type()) { +// We have a valid eSymbolTypeObjCClass class symbol whose name +// matches the current objective C class that we are trying to find +// and this DIE isn't the complete definition (we checked +// is_complete_objc_class above and know it is false), so the real +// definition is in here somewhere +TypeSP type_sp = +dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.name, true); - if (attrs.class_language == eLanguageTypeObjC || - attrs.class_language == eLanguageTypeObjC_plus_plus) { -if (!attrs.is_complete_objc_class && -decl_die.Supports_DW_AT_APPLE_objc_complete_type()) { - // We have a valid eSymbolTypeObjCClass class symbol whose name - // matches the current objective C class that we are trying to find - // and this DIE isn't the complete definition (we checked - // is_complete_objc_class above and know it is false), so the real - // definition is in here somewhere - TypeSP type_sp = - dwarf->FindCompleteObjCDefinitionTypeForDIE(decl_die, attrs.name, true); - - if (!type_sp) { -SymbolFileDWARFDebugMap *debug_map_symfile = -dwarf->GetDebugMapSymfile(); -if (debug_map_symfile) { - // We weren't able to find a full declaration in this DWARF, - // see if we have a declaration anywhere else... - type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE( - decl_die, attrs.name, true); -} +if (!type_sp) { + SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); + if (debug_map_symfile) { +// We weren't able to find a full declaration in this DWARF, +// see if we have a declaration anywhere else... +type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE( +die, attrs.name, true); } +} - if (type_sp) { -if (log) { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, - "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an " - "incomplete objc type, complete type is {5:x8}", - static_cast(this), decl_die.GetOffset(), - DW_TAG_value_to_name(tag), tag, attrs.name.GetCString(), - type_sp->GetID()); -} -return type_sp; +if (type_sp) { + if (log) { +dwarf->GetObjectFile()->GetModule()->LogMessage( +log, +"SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an " +"incomplete objc type, complete type is {5:x8}", +static_cast(this), die.GetID(), DW_TAG_value_to_name(tag), +tag, attrs.name.GetCString(), type_sp->GetID()); } + return type_sp; } } - DWARFDIE def_die; if (attrs.is_forward_declaration) { -Progress progress(llvm::formatv( Michael137 wrote: Can we move this into `FindDefinitionDIE`? We previously put this here to keep track of when we call into `FindDefinitionDIE` during DWARF parsing https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/99012 >From 242f78b67d6d6ef125b72c9c797fb2686cce280d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 10 Jul 2024 15:37:45 +0100 Subject: [PATCH 1/2] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests --- .../compressed_pair.h | 34 ++- .../TestDataFormatterLibcxxStringSimulator.py | 19 ++- .../libcxx-simulators/string/main.cpp | 33 +++--- ...stDataFormatterLibcxxUniquePtrSimulator.py | 14 ++-- .../libcxx-simulators/unique_ptr/main.cpp | 5 +++ 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h index 026e7183ab27a..f2c1b626bd46f 100644 --- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h +++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h @@ -7,7 +7,7 @@ namespace std { namespace __lldb { -// Post-c88580c layout +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout struct __value_init_tag {}; struct __default_init_tag {}; @@ -52,6 +52,38 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } }; +#elif COMPRESSED_PAIR_REV == 1 +template class __compressed_pair_padding { + char __padding_[(is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) + ? 0 + : sizeof(_ToPad) - __datasizeof(_ToPad)]; +}; + +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)), \ +__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; \ + [[no_unique_address]] T3 Initializer3; \ + [[no_unique_address]] __compressed_pair_padding __padding3_; +#elif COMPRESSED_PAIR_REV == 2 +#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2 + +#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2; \ + [[no_unique_address]] T3 Name3 +#endif } // namespace __lldb } // namespace std diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py index 3e5c493692c4f..0d4270ef58568 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py @@ -25,12 +25,13 @@ def _run_test(self, defines): for v in [None, "ALTERNATE_LAYOUT"]: for r in range(5): -name = "test_r%d" % r -defines = ["REVISION=%d" % r] -if v: -name += "_" + v -defines += [v] -f = functools.partialmethod( -LibcxxStringDataFormatterSimulatorTestCase._run_test, defines -) -setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f) +for c in range(3): +name = "test_r%d_c%d" % (r, c) +defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c] +if v: +name += "_" + v +defines += [v] +f = functools.partialmethod( +LibcxxStringDataFormatterSimulatorTestCase._run_test, defines +) +setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main
[Lldb-commits] [lldb] d4a89af - [lldb][Docs] Move QEMU testing page into the developing lldb section
Author: David Spickett Date: 2024-07-16T13:08:04+01:00 New Revision: d4a89af5a8c52191797bed5ff7ff40a85435d3a0 URL: https://github.com/llvm/llvm-project/commit/d4a89af5a8c52191797bed5ff7ff40a85435d3a0 DIFF: https://github.com/llvm/llvm-project/commit/d4a89af5a8c52191797bed5ff7ff40a85435d3a0.diff LOG: [lldb][Docs] Move QEMU testing page into the developing lldb section Added: lldb/docs/resources/qemu-testing.rst Modified: lldb/docs/index.rst Removed: lldb/docs/use/qemu-testing.rst diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst index 3ce23beec2a5e..d9b8e589eb2ac 100644 --- a/lldb/docs/index.rst +++ b/lldb/docs/index.rst @@ -125,7 +125,6 @@ interesting areas to contribute to lldb. use/symbolication use/symbols use/remote - use/qemu-testing use/intel_pt use/ondemand use/aarch64-linux @@ -153,6 +152,7 @@ interesting areas to contribute to lldb. resources/contributing resources/build resources/test + resources/qemu-testing resources/debugging resources/fuzzing resources/sbapi diff --git a/lldb/docs/use/qemu-testing.rst b/lldb/docs/resources/qemu-testing.rst similarity index 100% rename from lldb/docs/use/qemu-testing.rst rename to lldb/docs/resources/qemu-testing.rst ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/99012 >From 242f78b67d6d6ef125b72c9c797fb2686cce280d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 10 Jul 2024 15:37:45 +0100 Subject: [PATCH 1/3] [WIP][lldb][test] Add a new __compressed_pair layout to libcxx simulator tests --- .../compressed_pair.h | 34 ++- .../TestDataFormatterLibcxxStringSimulator.py | 19 ++- .../libcxx-simulators/string/main.cpp | 33 +++--- ...stDataFormatterLibcxxUniquePtrSimulator.py | 14 ++-- .../libcxx-simulators/unique_ptr/main.cpp | 5 +++ 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h index 026e7183ab27a..f2c1b626bd46f 100644 --- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h +++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h @@ -7,7 +7,7 @@ namespace std { namespace __lldb { -// Post-c88580c layout +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout struct __value_init_tag {}; struct __default_init_tag {}; @@ -52,6 +52,38 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } }; +#elif COMPRESSED_PAIR_REV == 1 +template class __compressed_pair_padding { + char __padding_[(is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) + ? 0 + : sizeof(_ToPad) - __datasizeof(_ToPad)]; +}; + +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)), \ +__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding __padding1_; \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding __padding2_; \ + [[no_unique_address]] T3 Initializer3; \ + [[no_unique_address]] __compressed_pair_padding __padding3_; +#elif COMPRESSED_PAIR_REV == 2 +#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2 + +#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2; \ + [[no_unique_address]] T3 Name3 +#endif } // namespace __lldb } // namespace std diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py index 3e5c493692c4f..0d4270ef58568 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py @@ -25,12 +25,13 @@ def _run_test(self, defines): for v in [None, "ALTERNATE_LAYOUT"]: for r in range(5): -name = "test_r%d" % r -defines = ["REVISION=%d" % r] -if v: -name += "_" + v -defines += [v] -f = functools.partialmethod( -LibcxxStringDataFormatterSimulatorTestCase._run_test, defines -) -setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f) +for c in range(3): +name = "test_r%d_c%d" % (r, c) +defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c] +if v: +name += "_" + v +defines += [v] +f = functools.partialmethod( +LibcxxStringDataFormatterSimulatorTestCase._run_test, defines +) +setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main
[Lldb-commits] [lldb] 139df36 - [LLDB] Make 'process load' take remote os path delimiter into account (#98690)
Author: Vladislav Dzhidzhoev Date: 2024-07-16T15:21:06+02:00 New Revision: 139df36d89bd731b5180be3cac2b58d4b2082368 URL: https://github.com/llvm/llvm-project/commit/139df36d89bd731b5180be3cac2b58d4b2082368 DIFF: https://github.com/llvm/llvm-project/commit/139df36d89bd731b5180be3cac2b58d4b2082368.diff LOG: [LLDB] Make 'process load' take remote os path delimiter into account (#98690) Currently, if we execute 'process load' with remote debugging, it uses the host's path delimiter to look up files on a target machine. If we run remote debugging of Linux target on Windows and execute "process load C:\foo\a.so", lldb-server tries to load \foo\a.so instead of /foo/a.so on the remote. It affects several API tests. This commit fixes that error. Also, it contains minor fixes for TestLoadUnload.py for testing on Windows host and Linux target. Added: Modified: lldb/source/Commands/CommandObjectProcess.cpp lldb/test/API/functionalities/load_unload/TestLoadUnload.py Removed: diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 3587a8f529e4a..8685d5761557b 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -950,11 +950,13 @@ class CommandObjectProcessLoad : public CommandObjectParsed { ExecutionContext *execution_context) override { Status error; const int short_option = m_getopt_table[option_idx].val; + ArchSpec arch = + execution_context->GetProcessPtr()->GetSystemArchitecture(); switch (short_option) { case 'i': do_install = true; if (!option_arg.empty()) - install_path.SetFile(option_arg, FileSpec::Style::native); + install_path.SetFile(option_arg, arch.GetTriple()); break; default: llvm_unreachable("Unimplemented option"); diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py index e52fb8c87377f..cfbfaff10de3c 100644 --- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py @@ -62,7 +62,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False): for f in shlibs: err = lldb.remote_platform.Put( lldb.SBFileSpec(self.getBuildArtifact(f)), -lldb.SBFileSpec(os.path.join(wd, f)), +lldb.SBFileSpec(lldbutil.join_remote_paths(wd, f)), ) if err.Fail(): raise RuntimeError( @@ -71,7 +71,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False): if hidden_dir: shlib = "libloadunload_d." + ext hidden_dir = os.path.join(wd, "hidden") -hidden_file = os.path.join(hidden_dir, shlib) +hidden_file = lldbutil.join_remote_paths(hidden_dir, shlib) err = lldb.remote_platform.MakeDirectory(hidden_dir) if err.Fail(): raise RuntimeError( @@ -405,8 +405,10 @@ def run_step_over_load(self): # We can't find a breakpoint location for d_init before launching because # executable dependencies are resolved relative to the debuggers PWD. Bug? +# The remote lldb server resolves the executable dependencies correctly. @expectedFailureAll( -oslist=["freebsd", "linux", "netbsd"], triple=no_match("aarch64-.*-android") +oslist=["freebsd", "linux", "netbsd"], +remote=False, ) @expectedFailureAll(oslist=["windows"], archs=["aarch64"]) def test_static_init_during_load(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Make 'process load' take remote os path delimiter into account (PR #98690)
https://github.com/dzhidzhoev closed https://github.com/llvm/llvm-project/pull/98690 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] change .sbss section type to eSectionTypeZeroFill (PR #99044)
https://github.com/labath commented: I'm wondering if there's a more fundamental fix to be made here. Like perhaps treating treating any allocatable SHT_NOBITS section as ZeroFill. Basically to add `case SHT_NOBITS: if (H.sh_flags & SHF_ALLOC) return eSectionTypeZeroFill;` to `GetSectionType` (line 1716) https://github.com/llvm/llvm-project/pull/99044 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] IRMemoryMap zero address mapping fix (PR #99045)
DavidSpickett wrote: Is this something specific to risc-v or simply uncovered by testing against a certain risc-v target? Just wondering why we haven't had to do this before now. https://github.com/llvm/llvm-project/pull/99045 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
DavidSpickett wrote: The other ABI plugins use the dwarf indexes and I guess that has to be the case because the unwind plan's type is dwarf. Adding @jasonmolenda just in case there's anything more to it. https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: DavidSpickett wrote: Curious here what ` test_case.getArchitecture()` returns, is it exactly this string? I just remember that riscv can be configured all sorts of ways and I don't know if that ends up in this string. This is fine for this patch though, folks will find this code easily enough if it's a problem for them. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: DavidSpickett wrote: I guess `zero = 0x` would be fine for any `rv(32|64)` target. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the error `unable to launch a GDB server` in API tests (PR #98833)
slydiman wrote: > Did you consider making `AllowPort(0)` do nothing? GetNextAvailablePort() returns 0 in case of the empty map. LaunchGDBServer() does not update the map with the pid if the port is 0. So 0 is a special value which means `any`. Adding 0 to a map causes an unexpected behavior. https://github.com/llvm/llvm-project/pull/98833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
kevinfrei wrote: > @kevinfrei , I'm so sorry to tell you that I have reverted this patch. The > revert commit is > [27b2f4f](https://github.com/llvm/llvm-project/commit/27b2f4f861b8aeeabc4eb1a97649062de8fa3992) > and I left some notes there, which I also copy here: > > The patch #98344 causes a crash in LLDB when parsing some files like > `numpy.libs/libgfortran-daac5196.so.5.0.0` on graviton (you can download it > in > https://drive.google.com/file/d/12ygLjJwWpzdYsrzBPp1JGiFHxcgM0-XY/view?usp=drive_link > if you want to troubleshoot yourself). > > ``` > The assert that is hit is the following: > > ``` > llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2452: > std::pair lldb_private::AddressClass> > > ObjectFileELF::ParseSymbolTable(lldb_private::Symtab*, lldb::user_id_t, > lldb_private::Section*): Assertion `strtab->GetObjectFile() == this' failed. > ``` Reverted with a repro instead of some inscrutable "This didn't work on a build machine configured by someone 4 years ago who promptly forgot what they did and there's no documentation, but here's this log: good luck!" is glorious! I'll get on it- thanks 😃 https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
walter-erquinigo wrote: @kevinfrei , I'm glad I can be of help to you! Let me know if you want me to try out your next iteration of this PR on my device. https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the error `unable to launch a GDB server` in API tests (PR #98833)
slydiman wrote: The best solution is simply to remove all code related to gdb port mapping, because it does not work at all. Try to run `netstat` and you will be surprised. 1. lldb-server in gdbserver mode completely ignores the port from the url `tcp://[hostname]:port`. It binds to port 0 and it is hardcoded. 2. Currently lldb-server in platform mode always runs `lldb-server gdbserver tcp://[hostname]:0` because of the bug added 4 years ago and no one noticed this issue. If gdb port parameters specified, now it causes issues like #97537, but a random port will be used for connection anyway. If no gdb port parameters specified, the port map must be empty and must stay empty. AllowPort(0) makes the port map not empty and causes an unexpected behavior. This patch fixes this issue. https://github.com/llvm/llvm-project/pull/98833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/ZequanWu updated https://github.com/llvm/llvm-project/pull/98361 >From 37b6878b9125c314c75053f7d5b0ba520111e9a3 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Tue, 9 Jul 2024 15:28:19 -0700 Subject: [PATCH 1/5] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 279 -- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 67 +++-- .../SymbolFile/DWARF/SymbolFileDWARF.h| 15 +- .../DWARF/SymbolFileDWARFDebugMap.h | 9 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 2 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 3 +- .../SymbolFile/DWARF/UniqueDWARFASTType.cpp | 117 .../SymbolFile/DWARF/UniqueDWARFASTType.h | 36 +-- .../delayed-definition-die-searching.test | 36 +++ .../x86/simple-template-names-context.cpp | 4 +- 10 files changed, 301 insertions(+), 267 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 8e297141f4e13..7b93f6941ddda 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1603,41 +1603,74 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { TypeSP DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, - const DWARFDIE &decl_die, + const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs) { CompilerType clang_type; - const dw_tag_t tag = decl_die.Tag(); - SymbolFileDWARF *dwarf = decl_die.GetDWARF(); - LanguageType cu_language = SymbolFileDWARF::GetLanguage(*decl_die.GetCU()); + const dw_tag_t tag = die.Tag(); + SymbolFileDWARF *dwarf = die.GetDWARF(); + LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU()); Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - // UniqueDWARFASTType is large, so don't create a local variables on the - // stack, put it on the heap. This function is often called recursively and - // clang isn't good at sharing the stack space for variables in different - // blocks. - auto unique_ast_entry_up = std::make_unique(); - ConstString unique_typename(attrs.name); Declaration unique_decl(attrs.decl); + uint64_t byte_size = attrs.byte_size.value_or(0); + if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && + !die.HasChildren() && cu_language == eLanguageTypeObjC) { +// Work around an issue with clang at the moment where forward +// declarations for objective C classes are emitted as: +// DW_TAG_structure_type [2] +// DW_AT_name( "ForwardObjcClass" ) +// DW_AT_byte_size( 0x00 ) +// DW_AT_decl_file( "..." ) +// DW_AT_decl_line( 1 ) +// +// Note that there is no DW_AT_declaration and there are no children, +// and the byte size is zero. +attrs.is_forward_declaration = true; + } if (attrs.name) { if (Language::LanguageIsCPlusPlus(cu_language)) { // For C++, we rely solely upon the one definition rule that says // only one thing can exist at a given decl context. We ignore the // file and line that things are declared on. - std::string qualified_name = GetCPlusPlusQualifiedName(decl_die); + std::string qualified_name = GetCPlusPlusQualifiedName(die); if (!qualified_name.empty()) unique_typename = ConstString(qualified_name); unique_decl.Clear(); } -if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, decl_die, unique_decl, -attrs.byte_size.value_or(-1), *unique_ast_entry_up)) { - if (TypeSP type_sp = unique_ast_entry_up->m_type_sp) { +if (UniqueDWARFASTType *unique_ast_entry_type = +dwarf->GetUniqueDWARFASTTypeMap().Find( +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration)) { + if (TypeSP type_sp = unique_ast_entry_type->m_type_sp) { +dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( -GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), -decl_die); +GetCachedClangDeclContextForDIE(unique_ast_entry_type->m_die), die); +// If the DIE being parsed in this function is a definition and the +// entry in the map is a declaration, then we need to update the entry +// to point to the definition DIE. +if (!attrs.is_forward_declaration && +unique_ast_entry_type->m_is_forward_declaration) { + unique_ast_entry_type->m_die = die; + unique_ast_entry_type->m_byte_size = byte_size; + un
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
@@ -1595,49 +1627,67 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { if (qualified_name.empty()) qualified_name.append("::"); - qualified_name.append(name); + qualified_name.append(unique_typename.GetCString()); qualified_name.append(GetDIEClassTemplateParams(die)); - return qualified_name; + unique_typename = ConstString(qualified_name); ZequanWu wrote: This functions modifies both `unique_typename` and `decl_declaration` if it's c++, so there're two out values. Returning one out value while modifying another out value via reference parameter looks strange. https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
@@ -1659,128 +1709,56 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, default_accessibility = eAccessPrivate; } - if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && - !decl_die.HasChildren() && cu_language == eLanguageTypeObjC) { -// Work around an issue with clang at the moment where forward -// declarations for objective C classes are emitted as: -// DW_TAG_structure_type [2] -// DW_AT_name( "ForwardObjcClass" ) -// DW_AT_byte_size( 0x00 ) -// DW_AT_decl_file( "..." ) -// DW_AT_decl_line( 1 ) -// -// Note that there is no DW_AT_declaration and there are no children, -// and the byte size is zero. -attrs.is_forward_declaration = true; - } + if ((attrs.class_language == eLanguageTypeObjC || + attrs.class_language == eLanguageTypeObjC_plus_plus) && + !attrs.is_complete_objc_class && + die.Supports_DW_AT_APPLE_objc_complete_type()) { +// We have a valid eSymbolTypeObjCClass class symbol whose name +// matches the current objective C class that we are trying to find +// and this DIE isn't the complete definition (we checked +// is_complete_objc_class above and know it is false), so the real +// definition is in here somewhere +TypeSP type_sp = +dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.name, true); - if (attrs.class_language == eLanguageTypeObjC || - attrs.class_language == eLanguageTypeObjC_plus_plus) { -if (!attrs.is_complete_objc_class && -decl_die.Supports_DW_AT_APPLE_objc_complete_type()) { - // We have a valid eSymbolTypeObjCClass class symbol whose name - // matches the current objective C class that we are trying to find - // and this DIE isn't the complete definition (we checked - // is_complete_objc_class above and know it is false), so the real - // definition is in here somewhere - TypeSP type_sp = - dwarf->FindCompleteObjCDefinitionTypeForDIE(decl_die, attrs.name, true); - - if (!type_sp) { -SymbolFileDWARFDebugMap *debug_map_symfile = -dwarf->GetDebugMapSymfile(); -if (debug_map_symfile) { - // We weren't able to find a full declaration in this DWARF, - // see if we have a declaration anywhere else... - type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE( - decl_die, attrs.name, true); -} +if (!type_sp) { + SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); + if (debug_map_symfile) { +// We weren't able to find a full declaration in this DWARF, +// see if we have a declaration anywhere else... +type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE( +die, attrs.name, true); } +} - if (type_sp) { -if (log) { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, - "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an " - "incomplete objc type, complete type is {5:x8}", - static_cast(this), decl_die.GetOffset(), - DW_TAG_value_to_name(tag), tag, attrs.name.GetCString(), - type_sp->GetID()); -} -return type_sp; +if (type_sp) { + if (log) { +dwarf->GetObjectFile()->GetModule()->LogMessage( +log, +"SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an " +"incomplete objc type, complete type is {5:x8}", +static_cast(this), die.GetID(), DW_TAG_value_to_name(tag), +tag, attrs.name.GetCString(), type_sp->GetID()); } + return type_sp; } } - DWARFDIE def_die; if (attrs.is_forward_declaration) { -Progress progress(llvm::formatv( ZequanWu wrote: I moved it inside `FindDefinitionDIE` and changed the logging message to `Searching definition DIE in ...` as that function just do searching not parsing. https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
@@ -643,9 +644,9 @@ bool ABISysV_riscv::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { unwind_plan.Clear(); unwind_plan.SetRegisterKind(eRegisterKindDWARF); clayborg wrote: Since we specify here that we are using DWARF registers, then the change below is correct, https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
https://github.com/clayborg commented: LGTM https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
ZequanWu wrote: This buildkite seems got stuck somehow, no logging at all: https://buildkite.com/llvm-project/github-pull-requests/builds/81790#0190bca9-bde7-4fad-8478-9dffd4f669f7. Will merge without waiting for it to finish. https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b7b77b0 - Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (#98361)
Author: Zequan Wu Date: 2024-07-16T16:22:31-04:00 New Revision: b7b77b0fe878d5620b042818cf527267521e51f5 URL: https://github.com/llvm/llvm-project/commit/b7b77b0fe878d5620b042818cf527267521e51f5 DIFF: https://github.com/llvm/llvm-project/commit/b7b77b0fe878d5620b042818cf527267521e51f5.diff LOG: Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (#98361) This is a reapply of https://github.com/llvm/llvm-project/pull/92328 and https://github.com/llvm/llvm-project/pull/93839. It now passes the [test](https://github.com/llvm/llvm-project/commit/de3f1b6d68ab8a0e827db84b328803857a4f60df), which crashes with the original reverted changes. Added: lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test lldb/test/Shell/SymbolFile/DWARF/x86/type-definition-search.cpp Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h Removed: lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 8e297141f4e13..85c59a605c675 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -23,7 +23,6 @@ #include "Plugins/ExpressionParser/Clang/ClangUtil.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Progress.h" #include "lldb/Core/Value.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/CompileUnit.h" @@ -824,6 +823,34 @@ DWARFASTParserClang::GetDIEClassTemplateParams(const DWARFDIE &die) { return {}; } +void DWARFASTParserClang::MapDeclDIEToDefDIE( +const lldb_private::plugin::dwarf::DWARFDIE &decl_die, +const lldb_private::plugin::dwarf::DWARFDIE &def_die) { + LinkDeclContextToDIE(GetCachedClangDeclContextForDIE(decl_die), def_die); + SymbolFileDWARF *dwarf = def_die.GetDWARF(); + ParsedDWARFTypeAttributes decl_attrs(decl_die); + ParsedDWARFTypeAttributes def_attrs(def_die); + ConstString unique_typename(decl_attrs.name); + Declaration decl_declaration(decl_attrs.decl); + GetUniqueTypeNameAndDeclaration( + decl_die, SymbolFileDWARF::GetLanguage(*decl_die.GetCU()), + unique_typename, decl_declaration); + if (UniqueDWARFASTType *unique_ast_entry_type = + dwarf->GetUniqueDWARFASTTypeMap().Find( + unique_typename, decl_die, decl_declaration, + decl_attrs.byte_size.value_or(0), + decl_attrs.is_forward_declaration)) { +unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.decl, + def_attrs.byte_size.value_or(0)); + } else if (Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups)) { +const dw_tag_t tag = decl_die.Tag(); +LLDB_LOG(log, + "Failed to find {0:x16} {1} ({2}) type \"{3}\" in " + "UniqueDWARFASTTypeMap", + decl_die.GetID(), DW_TAG_value_to_name(tag), tag, unique_typename); + } +} + TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, const DWARFDIE &decl_die, ParsedDWARFTypeAttributes &attrs) { @@ -1546,13 +1573,17 @@ TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType( return type_sp; } -std::string -DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { - if (!die.IsValid()) -return ""; - const char *name = die.GetName(); - if (!name) -return ""; +void DWARFASTParserClang::GetUniqueTypeNameAndDeclaration( +const lldb_private::plugin::dwarf::DWARFDIE &die, +lldb::LanguageType language, lldb_private::ConstString &unique_typename, +lldb_private::Declaration &decl_declaration) { + // For C++, we rely solely upon the one definition rule that says + // only one thing can exist at a given decl context. We ignore the + // file and line that things are declared on. + if (!die.IsValid() || !Language::LanguageIsCPlusPlus(language) || + unique_typename.IsEmpty()) +return; + decl_declaration.Clear(); std::string qualified_name; DWARFDIE parent_decl_ctx_die = die.GetParentDeclContextDIE(); // TODO: change this to get the correct decl context parent @@ -1595,49 +1626,65 @@ DWARFASTParserClang::GetCPlusPlusQu
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/ZequanWu closed https://github.com/llvm/llvm-project/pull/98361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -191,9 +191,7 @@ class PluginManager { GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name); static Status SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, - llvm::StringRef plugin_name); + lldb_private::CoreDumpOptions &core_options); Jlalond wrote: If we do this then we will need to remove all the current mutation of style in `MachO, ELF, Minidump`. (Or keep them as local variables, but in that case then it's confusing that a plugin could mutate your options and you woudln't know. If we want to remove all the default settings per flavor in this patch let me know. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/98845 >From cead9ae6de627ee64fb58a829fa3485f526a0afc Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sun, 14 Jul 2024 16:59:51 -0700 Subject: [PATCH 1/4] [lldb] progressive progress reporting for darwin kernel/firmware When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. --- lldb/source/Core/DynamicLoader.cpp| 27 +++-- .../DynamicLoaderDarwinKernel.cpp | 39 --- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..a59136381c23b 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..93eb1e7b9dea9 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -757,6 +758,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +std::unique_ptr progress_up; +if (IsKernel()) { + StreamString prog_str; + // 'mach_kernel' is a fake name we make up to find kernels + // that were located by the local filesystem scan. + if (GetName() != "mach_kernel") +prog_str << GetName() << " "; + if (GetUUID().IsValid()) +prog_str << GetUUID().GetAsString() << " "; + if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(GetLoadAddress()); + } + progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); +} + // Search for the kext on the local filesystem via the UUID if (!m_module_sp && m_uuid.IsValid()) { ModuleSpec module_spec; @@ -1058,12 +1076,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { } } } - -if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) { - if (!m_kernel.LoadImageUsingMemoryModule(m_process)) { +if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) + if (!m_kernel.LoadImageUsingMemoryModule(m_process)) m_kernel.LoadImageAtFileAddress(m_process); - } -} // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
https://github.com/jasonmolenda approved this pull request. Agreed, this fix is correct, thanks for the PR. The register numbering in the UnwindPlan can be any eRegisterKind, but it does need to be self consistent, and this was not. Do you have permissions to merge this PR? I can do that for you if not. https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] IRMemoryMap zero address mapping fix (PR #99045)
jasonmolenda wrote: I don't think this change is correct, or I don't understand what it is trying to do. When we're connected to a stub that can allocate memory in the target, none of this code is executed. So lldb-server/debugserver will not hit this. We send `qMemoryRegionInfo` packets to look for a block of memory that is unallocated, or has permissions no-read+no-write+no-execute. The memory region scan starts at address 0 and moves up by the size of each memory region, looking for `size` bytes between allocated memory regions, and returns that address if it is found. So I'm guessing we have (1) a target that cannot allocate memory, (2) a target that supported `qMemoryRegionInfo`, a non-accessible block of memory at address 0? (did I read this right?) and in that case, we end up picking address 0 as our host-side virtual address+memory buffer for expression data storage. Can you show what your `qMemoryRegionInfo` results are for address 0 on this target, so I can confirm I didn't misread/misunderstand the situation here? https://github.com/llvm/llvm-project/pull/99045 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
@@ -2545,6 +2546,11 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, ModuleSP module_sp(new Module(file_spec, ArchSpec())); if (module_sp) { Status error; +std::unique_ptr progress_up; +if (!GetCoreFile()) clayborg wrote: Might be better to use the bool accessor function: ``` if (IsLiveDebugSession()) ``` https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
@@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at 0x"; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. clayborg wrote: My only concern here is this will spam the progress notifications and also be a bit misleading. The title says "Locating external symbol file" when what this is actually doing is loading the module from a module_spec. It _might_ end up locating an external symbol file. We know reading modules from memory is slow, so fine to make a progress for this, but It would be better to actually put this in the `DownloadObjectAndSymbolFile()` with this label, or change the label to something more like "Loading module" with the detail being the `prog_str` https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
@@ -2545,6 +2546,11 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, ModuleSP module_sp(new Module(file_spec, ArchSpec())); if (module_sp) { Status error; +std::unique_ptr progress_up; +if (!GetCoreFile()) jasonmolenda wrote: The name is a little misleading, `IsLiveDebugSession` is only false for `PostMortemProcess`. Maybe we should have a `Process::IsCorefileProcess` or something, or I could put a comment there about what I'm doing. https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/98845 >From cead9ae6de627ee64fb58a829fa3485f526a0afc Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sun, 14 Jul 2024 16:59:51 -0700 Subject: [PATCH 1/5] [lldb] progressive progress reporting for darwin kernel/firmware When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. --- lldb/source/Core/DynamicLoader.cpp| 27 +++-- .../DynamicLoaderDarwinKernel.cpp | 39 --- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..a59136381c23b 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..93eb1e7b9dea9 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -757,6 +758,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +std::unique_ptr progress_up; +if (IsKernel()) { + StreamString prog_str; + // 'mach_kernel' is a fake name we make up to find kernels + // that were located by the local filesystem scan. + if (GetName() != "mach_kernel") +prog_str << GetName() << " "; + if (GetUUID().IsValid()) +prog_str << GetUUID().GetAsString() << " "; + if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(GetLoadAddress()); + } + progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); +} + // Search for the kext on the local filesystem via the UUID if (!m_module_sp && m_uuid.IsValid()) { ModuleSpec module_spec; @@ -1058,12 +1076,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { } } } - -if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) { - if (!m_kernel.LoadImageUsingMemoryModule(m_process)) { +if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) + if (!m_kernel.LoadImageUsingMemoryModule(m_process)) m_kernel.LoadImageAtFileAddress(m_process); - } -} // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
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 efde640cdfede834fa79e0eea69f82fb769d6beb e3c60eea579d3948156ec5d16f0f429700e8112b --extensions cpp,h -- lldb/source/Core/DynamicLoader.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h lldb/source/Target/Process.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index e0db4d8105..7758a87403 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -223,8 +223,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( FileSpec name_filespec(name); if (uuid.IsValid()) { -Progress progress("Locating binary", - prog_str.GetString().str()); +Progress progress("Locating binary", prog_str.GetString().str()); // Has lldb already seen a module with this UUID? // Or have external lookup enabled in DebugSymbols on macOS. diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 29cc97b675..63d59d7132 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2548,7 +2548,7 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, Status error; std::unique_ptr progress_up; // Reading an ObjectFile from a local corefile is very fast, -// don't print a progress report. +// don't print a progress report. if (!GetCoreFile()) progress_up = std::make_unique( "Reading binary from memory", file_spec.GetFilename().GetString()); `` https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/98845 >From cead9ae6de627ee64fb58a829fa3485f526a0afc Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sun, 14 Jul 2024 16:59:51 -0700 Subject: [PATCH 1/6] [lldb] progressive progress reporting for darwin kernel/firmware When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. --- lldb/source/Core/DynamicLoader.cpp| 27 +++-- .../DynamicLoaderDarwinKernel.cpp | 39 --- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..a59136381c23b 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..93eb1e7b9dea9 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -757,6 +758,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +std::unique_ptr progress_up; +if (IsKernel()) { + StreamString prog_str; + // 'mach_kernel' is a fake name we make up to find kernels + // that were located by the local filesystem scan. + if (GetName() != "mach_kernel") +prog_str << GetName() << " "; + if (GetUUID().IsValid()) +prog_str << GetUUID().GetAsString() << " "; + if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(GetLoadAddress()); + } + progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); +} + // Search for the kext on the local filesystem via the UUID if (!m_module_sp && m_uuid.IsValid()) { ModuleSpec module_spec; @@ -1058,12 +1076,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { } } } - -if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) { - if (!m_kernel.LoadImageUsingMemoryModule(m_process)) { +if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) + if (!m_kernel.LoadImageUsingMemoryModule(m_process)) m_kernel.LoadImageAtFileAddress(m_process); - } -} // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
@@ -2545,6 +2546,11 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, ModuleSP module_sp(new Module(file_spec, ArchSpec())); if (module_sp) { Status error; +std::unique_ptr progress_up; +if (!GetCoreFile()) clayborg wrote: `PostMortemProcess` is what all of the core file processes (elf, mach-o and minidump) inherit from. That way all core file processes don't forget to override this function. I agree the name isn't the most clear. https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/98403 >From 4752adac6b8d39512bbfb46726205ceb2301d1c2 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 9 Jul 2024 13:30:46 -0700 Subject: [PATCH 1/4] Create CoreDumpOption class, and SB equivalent --- lldb/include/lldb/API/SBCoreDumpOptions.h | 37 +++ lldb/source/API/SBCoreDumpOptions.cpp | 16 .../Plugins/ObjectFile/CoreDumpOptions.cpp| 25 + .../Plugins/ObjectFile/CoreDumpOptions.h | 37 +++ 4 files changed, 115 insertions(+) create mode 100644 lldb/include/lldb/API/SBCoreDumpOptions.h create mode 100644 lldb/source/API/SBCoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.h diff --git a/lldb/include/lldb/API/SBCoreDumpOptions.h b/lldb/include/lldb/API/SBCoreDumpOptions.h new file mode 100644 index 0..523fa34c17f36 --- /dev/null +++ b/lldb/include/lldb/API/SBCoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- SBCoreDumpOptions.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_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions() {}; + SBStatisticsOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBExpressionOptions() = default; + + const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); + + void SetCoreDumpPluginName(const char* plugin); + const char* GetCoreDumpPluginName(); + + void SetCoreDumpStyle(const char* style); + const char* GetCoreDumpStyle(); + + void SetOutputFilePath(const char* path); + const char* GetOutputFilePath(); + +private: + std::unique_ptr m_opaque_up; +}; // SBCoreDumpOptions + +}; // namespace lldb + +#endif // LLDB_API_SBCOREDUMPOPTIONS_H diff --git a/lldb/source/API/SBCoreDumpOptions.cpp b/lldb/source/API/SBCoreDumpOptions.cpp new file mode 100644 index 0..d051c5b6bef6b --- /dev/null +++ b/lldb/source/API/SBCoreDumpOptions.cpp @@ -0,0 +1,16 @@ +//===-- SBCoreDumpOptions.cpp ---*- 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 +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" + +using namespace lldb; +using namespace lldb_private; + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + +}; diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp new file mode 100644 index 0..00333d1550790 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp @@ -0,0 +1,25 @@ +//===-- CoreDumpOptions.cpp -*- 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 +// +//===--===// + +#include "lldb/API/CoreDumpOptions.h" + +CoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_core_dump_plugin_name = name; +} + +CoreDumpOptions::GetCoreDumpPluginName() { return m_core_dump_plugin_name; } + +CoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_core_dump_style = style; +} + +CoreDumpOptions::GetCoreDumpStyle() { return m_core_dump_style; } + +CoreDumpOptions::SetCoreDumpFile(const char *file) { m_core_dump_file = file; } + +CoreDumpOptions::GetCoreDumpFile() { return m_core_dump_file; } diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h new file mode 100644 index 0..fe369b0490674 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- CoreDumpOptions.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_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include + +using namespace lldb; + +class CoreDumpOptions { + public: +
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
@@ -2545,6 +2546,11 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, ModuleSP module_sp(new Module(file_spec, ArchSpec())); if (module_sp) { Status error; +std::unique_ptr progress_up; +if (!GetCoreFile()) jasonmolenda wrote: Oh whoops, my bad on that one, thanks. I'll change to use this instead, it's clearer. https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: dlav-sc wrote: Yes, you are right. `rv64gc` is just my configuration (now `getArchitecture()` returns what I pass to `--arch` option running `dotest.py`). Maybe I can make more generic solution by adding a regexp or just simple `if arch.startswith("rv"): arch = "riscv"` in `getArchitecture()`. I think it would be enough for now, because `rv32` and `rv64` have the same register set and as you have noticed `zero = 0x` would be fine for any target, so there is no reasons to distinguish a bitness or configurations. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
@@ -633,171 +613,142 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( } break; + // [exc_type, exc_code, exc_sub_code, exc_sub_sub_code] + // + // Instruction step: + // [6, 1, 0] + // Intel KDP [6, 3, ??] + // armv7 [6, 0x102, ] Same as software breakpoint! + // + // Software breakpoint: + // x86 [6, 2, 0] + // Intel KDP [6, 2, ] + // arm64 [6, 1, ] + // armv7 [6, 0x102, ] Same as instruction step! + // + // Hardware breakpoint: + // x86 [6, 1, , 0] + // x86/Rosetta not implemented, see software breakpoint + // arm64 [6, 1, ] + // armv7 not implemented, see software breakpoint + // + // Hardware watchpoint: + // x86 [6, 1, , 0] (both Intel hw and Rosetta) + // arm64 [6, 0x102, , 0] + // armv7 [6, 0x102, , 0] + // + // arm64 BRK instruction (imm arg not reflected in the ME) + // [ 6, 1, ] + // + // In order of codes mach exceptions: + // [6, 1, 0] - instruction step + // [6, 1, ] - hardware breakpoint or watchpoint + // + // [6, 2, 0] - software breakpoint + // [6, 2, ] - software breakpoint + // + // [6, 3] - instruction step + // + // [6, 0x102, ] armv7 instruction step + // [6, 0x102, ] armv7 software breakpoint + // [6, 0x102, , 0] arm64/armv7 watchpoint case 6: // EXC_BREAKPOINT { -bool is_actual_breakpoint = false; -bool is_trace_if_actual_breakpoint_missing = false; -switch (cpu) { -case llvm::Triple::x86: -case llvm::Triple::x86_64: - if (exc_code == 1) // EXC_I386_SGL - { -if (!exc_sub_code) { - // This looks like a plain trap. - // Have to check if there is a breakpoint here as well. When you - // single-step onto a trap, the single step stops you not to trap. - // Since we also do that check below, let's just use that logic. - is_actual_breakpoint = true; - is_trace_if_actual_breakpoint_missing = true; -} else { - if (StopInfoSP stop_info = - GetStopInfoForHardwareBP(thread, target, exc_data_count, - exc_sub_code, exc_sub_sub_code)) -return stop_info; -} - } else if (exc_code == 2 || // EXC_I386_BPT - exc_code == 3) // EXC_I386_BPTFLT - { -// KDP returns EXC_I386_BPTFLT for trace breakpoints -if (exc_code == 3) - is_trace_if_actual_breakpoint_missing = true; - -is_actual_breakpoint = true; -if (!pc_already_adjusted) - pc_decrement = 1; - } - break; - -case llvm::Triple::arm: -case llvm::Triple::thumb: - if (exc_code == 0x102) // EXC_ARM_DA_DEBUG - { -// LWP_TODO: We need to find the WatchpointResource that matches -// the address, and evaluate its Watchpoints. - -// It's a watchpoint, then, if the exc_sub_code indicates a -// known/enabled data break address from our watchpoint list. -lldb::WatchpointSP wp_sp; -if (target) - wp_sp = target->GetWatchpointList().FindByAddress( - (lldb::addr_t)exc_sub_code); -if (wp_sp && wp_sp->IsEnabled()) { - return StopInfo::CreateStopReasonWithWatchpointID(thread, -wp_sp->GetID()); -} else { - is_actual_breakpoint = true; - is_trace_if_actual_breakpoint_missing = true; -} - } else if (exc_code == 1) // EXC_ARM_BREAKPOINT - { -is_actual_breakpoint = true; -is_trace_if_actual_breakpoint_missing = true; - } else if (exc_code == 0) // FIXME not EXC_ARM_BREAKPOINT but a kernel -// is currently returning this so accept it -// as indicating a breakpoint until the -// kernel is fixed - { -is_actual_breakpoint = true; -is_trace_if_actual_breakpoint_missing = true; - } - break; +bool stopped_by_hitting_breakpoint = false; +bool stopped_by_completing_stepi = false; +bool stopped_watchpoint = false; +std::optional value; + +// exc_code 1 +if (exc_code == 1 && exc_sub_code == 0) + stopped_by_completing_stepi = true; +if (exc_code == 1 && exc_sub_code != 0) { + stopped_by_hitting_breakpoint = true; + stopped_watchpoint = true; + value = exc_sub_code; +} -case llvm::Triple::aarch64_32: -case llvm::Triple::aarch64: { - // xnu describes three things with type EXC_BREAKPOINT: - // - // exc_code 0x102 [EXC_ARM_DA_DEBUG], exc_sub_code addr-of-insn - // Watchpoint access. exc_sub_code is the address of the - // instruction which trigged the watchpoint trap. - // debugserver may add the watchpoint number that was triggered - // in exc_sub_sub_code. - // - // exc_code 1 [EXC_ARM_BREAKPOI
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
@@ -633,171 +613,142 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( } break; + // [exc_type, exc_code, exc_sub_code, exc_sub_sub_code] + // + // Instruction step: + // [6, 1, 0] + // Intel KDP [6, 3, ??] + // armv7 [6, 0x102, ] Same as software breakpoint! + // + // Software breakpoint: + // x86 [6, 2, 0] + // Intel KDP [6, 2, ] + // arm64 [6, 1, ] + // armv7 [6, 0x102, ] Same as instruction step! + // + // Hardware breakpoint: + // x86 [6, 1, , 0] + // x86/Rosetta not implemented, see software breakpoint + // arm64 [6, 1, ] + // armv7 not implemented, see software breakpoint + // + // Hardware watchpoint: + // x86 [6, 1, , 0] (both Intel hw and Rosetta) + // arm64 [6, 0x102, , 0] + // armv7 [6, 0x102, , 0] + // + // arm64 BRK instruction (imm arg not reflected in the ME) + // [ 6, 1, ] + // + // In order of codes mach exceptions: + // [6, 1, 0] - instruction step + // [6, 1, ] - hardware breakpoint or watchpoint + // + // [6, 2, 0] - software breakpoint + // [6, 2, ] - software breakpoint + // + // [6, 3] - instruction step + // + // [6, 0x102, ] armv7 instruction step + // [6, 0x102, ] armv7 software breakpoint + // [6, 0x102, , 0] arm64/armv7 watchpoint case 6: // EXC_BREAKPOINT { -bool is_actual_breakpoint = false; -bool is_trace_if_actual_breakpoint_missing = false; -switch (cpu) { -case llvm::Triple::x86: -case llvm::Triple::x86_64: - if (exc_code == 1) // EXC_I386_SGL - { -if (!exc_sub_code) { - // This looks like a plain trap. - // Have to check if there is a breakpoint here as well. When you - // single-step onto a trap, the single step stops you not to trap. - // Since we also do that check below, let's just use that logic. - is_actual_breakpoint = true; - is_trace_if_actual_breakpoint_missing = true; -} else { - if (StopInfoSP stop_info = - GetStopInfoForHardwareBP(thread, target, exc_data_count, - exc_sub_code, exc_sub_sub_code)) -return stop_info; -} - } else if (exc_code == 2 || // EXC_I386_BPT - exc_code == 3) // EXC_I386_BPTFLT - { -// KDP returns EXC_I386_BPTFLT for trace breakpoints -if (exc_code == 3) - is_trace_if_actual_breakpoint_missing = true; - -is_actual_breakpoint = true; -if (!pc_already_adjusted) - pc_decrement = 1; - } - break; - -case llvm::Triple::arm: -case llvm::Triple::thumb: - if (exc_code == 0x102) // EXC_ARM_DA_DEBUG - { -// LWP_TODO: We need to find the WatchpointResource that matches -// the address, and evaluate its Watchpoints. - -// It's a watchpoint, then, if the exc_sub_code indicates a -// known/enabled data break address from our watchpoint list. -lldb::WatchpointSP wp_sp; -if (target) - wp_sp = target->GetWatchpointList().FindByAddress( - (lldb::addr_t)exc_sub_code); -if (wp_sp && wp_sp->IsEnabled()) { - return StopInfo::CreateStopReasonWithWatchpointID(thread, -wp_sp->GetID()); -} else { - is_actual_breakpoint = true; - is_trace_if_actual_breakpoint_missing = true; -} - } else if (exc_code == 1) // EXC_ARM_BREAKPOINT - { -is_actual_breakpoint = true; -is_trace_if_actual_breakpoint_missing = true; - } else if (exc_code == 0) // FIXME not EXC_ARM_BREAKPOINT but a kernel -// is currently returning this so accept it -// as indicating a breakpoint until the -// kernel is fixed - { -is_actual_breakpoint = true; -is_trace_if_actual_breakpoint_missing = true; - } - break; +bool stopped_by_hitting_breakpoint = false; +bool stopped_by_completing_stepi = false; +bool stopped_watchpoint = false; +std::optional value; + +// exc_code 1 +if (exc_code == 1 && exc_sub_code == 0) + stopped_by_completing_stepi = true; +if (exc_code == 1 && exc_sub_code != 0) { + stopped_by_hitting_breakpoint = true; + stopped_watchpoint = true; + value = exc_sub_code; +} -case llvm::Triple::aarch64_32: -case llvm::Triple::aarch64: { - // xnu describes three things with type EXC_BREAKPOINT: - // - // exc_code 0x102 [EXC_ARM_DA_DEBUG], exc_sub_code addr-of-insn - // Watchpoint access. exc_sub_code is the address of the - // instruction which trigged the watchpoint trap. - // debugserver may add the watchpoint number that was triggered - // in exc_sub_sub_code. - // - // exc_code 1 [EXC_ARM_BREAKPOI
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
dlav-sc wrote: > Agreed, this fix is correct, thanks for the PR. The register numbering in the > UnwindPlan can be any eRegisterKind, but it does need to be self consistent, > and this was not. Do you have permissions to merge this PR? I can do that for > you if not. Thanks for the review. I don't have permissions, please merge it yourself. https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev created https://github.com/llvm/llvm-project/pull/99266 These changes aim to support cross-compilation build on Windows host for Linux target for API tests execution. They're not final: changes will follow for refactoring and adjustments to make all tests pass. Chocolatey make is recommended since it is maintained better than GnuWin32 mentioned here https://lldb.llvm.org/resources/build.html#codesigning (latest GnuWin32 release dated by 2010) and helps to avoid problems with building tests (for example, GnuWin32 doesn't support long paths and there are some other failures with building for Linux with it). This commit contains the following changes: 1. Better SHELL detection on Windows host. 2. Paths are turned into POSIX-style since some tests and Unix utilities use them for manipulating files. It helps to avoid compiler/linker errors because of broken paths. 3. Compiler and linker flags are sorted out to enable cross-compilation. >From 7e79d7c7e7946debc8ec3066b6cd54f3d33b7c3d Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev Date: Mon, 15 Jul 2024 22:52:40 +0200 Subject: [PATCH] [LLDB][test] Update Makefile.rules to support Windows host+Linux target These changes are aimed to support cross compilation build on Windows host for Linux target for API tests execution. They're not final: changes will follow for refactoring and adjustments to make all tests passing. Chocolatey make is recommended to use, since it is maintained better than GnuWin32 recommended here https://lldb.llvm.org/resources/build.html#codesigning (it was updated last time in 2010) and helps to avoid problems with building tests (for example, GnuWin32 doesn't support long paths and there are some other failures with building for Linux with it). This commit contains following changes: 1. Better SHELL detection for make to use on Windows host. 2. Paths are turned into POSIX-style since some tests and Unix utilities use them for manipulating files. It helps to avoid compiler/linker errors because of broken paths. 3. Compiler and linker flags are cleaned up to enable cross-compilation. --- .../Python/lldbsuite/test/make/Makefile.rules | 124 +++--- .../settings/use_source_cache/Makefile| 2 +- .../breakpoint/comp_dir_symlink/Makefile | 2 +- .../inline-sourcefile/Makefile| 2 +- .../functionalities/multiple-slides/Makefile | 2 +- .../postmortem/netbsd-core/GNUmakefile| 4 +- .../step-avoids-no-debug/Makefile | 2 +- .../functionalities/valobj_errors/Makefile| 2 +- .../API/lang/cpp/operator-overload/Makefile | 2 +- .../API/lang/objcxx/class-name-clash/Makefile | 2 +- lldb/test/API/linux/add-symbols/Makefile | 2 +- lldb/test/API/linux/sepdebugsymlink/Makefile | 2 +- lldb/test/API/macosx/function-starts/Makefile | 2 +- lldb/test/API/macosx/posix_spawn/Makefile | 6 +- lldb/test/API/macosx/universal/Makefile | 8 +- lldb/test/API/macosx/universal64/Makefile | 8 +- lldb/test/API/source-manager/Makefile | 2 +- .../API/tools/lldb-dap/breakpoint/Makefile| 4 +- 18 files changed, 104 insertions(+), 74 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index d1a2de8b2478a..1474714ac4f5c 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -47,7 +47,8 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ .DEFAULT_GOAL := all #-- -# If OS is not defined, use 'uname -s' to determine the OS name. +# If OS or/and HOST_OS are not defined, use 'uname -s' to determine +# the OS name. # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments @@ -56,15 +57,12 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # inherited all the way down to the process spawned for make. #-- ifeq "$(HOST_OS)" "" - HOST_OS := $(shell uname -s) -endif - -ifneq (,$(findstring windows32,$(HOST_OS))) - HOST_OS := Windows_NT -endif - -ifneq (,$(findstring MSYS_NT,$(HOST_OS))) - HOST_OS := Windows_NT +HOST_OS := $(shell uname -s) +ifneq (,$(or \ +$(findstring windows32,$(HOST_OS)),\ +$(findstring MSYS_NT,$(HOST_OS +HOST_OS := Windows_NT +endif endif ifeq "$(OS)" "" @@ -80,9 +78,21 @@ endif # Also reset BUILDDIR value because "pwd" returns cygwin or msys path # which needs to be converted to windows path. #-- -ifeq "$(OS)" "Windows_NT" - SHELL = $(WINDIR)\system32\cmd.exe +path_wrapper = $(1) +ifeq "$(HOST_OS)" "Windows_NT" + # Windows 10 and later
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Vladislav Dzhidzhoev (dzhidzhoev) Changes These changes aim to support cross-compilation build on Windows host for Linux target for API tests execution. They're not final: changes will follow for refactoring and adjustments to make all tests pass. Chocolatey make is recommended since it is maintained better than GnuWin32 mentioned here https://lldb.llvm.org/resources/build.html#codesigning (latest GnuWin32 release dated by 2010) and helps to avoid problems with building tests (for example, GnuWin32 doesn't support long paths and there are some other failures with building for Linux with it). This commit contains the following changes: 1. Better SHELL detection on Windows host. 2. Paths are turned into POSIX-style since some tests and Unix utilities use them for manipulating files. It helps to avoid compiler/linker errors because of broken paths. 3. Compiler and linker flags are sorted out to enable cross-compilation. --- Full diff: https://github.com/llvm/llvm-project/pull/99266.diff 18 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+77-47) - (modified) lldb/test/API/commands/settings/use_source_cache/Makefile (+1-1) - (modified) lldb/test/API/functionalities/breakpoint/comp_dir_symlink/Makefile (+1-1) - (modified) lldb/test/API/functionalities/inline-sourcefile/Makefile (+1-1) - (modified) lldb/test/API/functionalities/multiple-slides/Makefile (+1-1) - (modified) lldb/test/API/functionalities/postmortem/netbsd-core/GNUmakefile (+2-2) - (modified) lldb/test/API/functionalities/step-avoids-no-debug/Makefile (+1-1) - (modified) lldb/test/API/functionalities/valobj_errors/Makefile (+1-1) - (modified) lldb/test/API/lang/cpp/operator-overload/Makefile (+1-1) - (modified) lldb/test/API/lang/objcxx/class-name-clash/Makefile (+1-1) - (modified) lldb/test/API/linux/add-symbols/Makefile (+1-1) - (modified) lldb/test/API/linux/sepdebugsymlink/Makefile (+1-1) - (modified) lldb/test/API/macosx/function-starts/Makefile (+1-1) - (modified) lldb/test/API/macosx/posix_spawn/Makefile (+3-3) - (modified) lldb/test/API/macosx/universal/Makefile (+4-4) - (modified) lldb/test/API/macosx/universal64/Makefile (+4-4) - (modified) lldb/test/API/source-manager/Makefile (+1-1) - (modified) lldb/test/API/tools/lldb-dap/breakpoint/Makefile (+2-2) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index d1a2de8b2478a..1474714ac4f5c 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -47,7 +47,8 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ .DEFAULT_GOAL := all #-- -# If OS is not defined, use 'uname -s' to determine the OS name. +# If OS or/and HOST_OS are not defined, use 'uname -s' to determine +# the OS name. # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments @@ -56,15 +57,12 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # inherited all the way down to the process spawned for make. #-- ifeq "$(HOST_OS)" "" - HOST_OS := $(shell uname -s) -endif - -ifneq (,$(findstring windows32,$(HOST_OS))) - HOST_OS := Windows_NT -endif - -ifneq (,$(findstring MSYS_NT,$(HOST_OS))) - HOST_OS := Windows_NT +HOST_OS := $(shell uname -s) +ifneq (,$(or \ +$(findstring windows32,$(HOST_OS)),\ +$(findstring MSYS_NT,$(HOST_OS +HOST_OS := Windows_NT +endif endif ifeq "$(OS)" "" @@ -80,9 +78,21 @@ endif # Also reset BUILDDIR value because "pwd" returns cygwin or msys path # which needs to be converted to windows path. #-- -ifeq "$(OS)" "Windows_NT" - SHELL = $(WINDIR)\system32\cmd.exe +path_wrapper = $(1) +ifeq "$(HOST_OS)" "Windows_NT" + # Windows 10 and later has the lower-case 'windir' env variable. + SHELL := $(or $(windir),$(WINDIR),C:\WINDOWS)\system32\cmd.exe BUILDDIR := $(shell echo %cd%) + + ifneq (,$(filter $(OS), Linux Android)) + path_wrapper = $(subst \,/,$(1)) + # Normalize base paths at the same time. + override SRCDIR := $(call path_wrapper,$(SRCDIR)) + override BUILDDIR := $(call path_wrapper,$(BUILDDIR)) + override MAKEFILE_RULES := $(call path_wrapper,$(MAKEFILE_RULES)) + override THIS_FILE_DIR := $(call path_wrapper,$(THIS_FILE_DIR)) + override LLDB_BASE_DIR := $(call path_wrapper,$(LLDB_BASE_DIR)) + endif endif #-- @@ -135,7 +145,7 @@ $(error "C compiler is not specified. Please run tests through lldb-dotest or li endif
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/98845 >From cead9ae6de627ee64fb58a829fa3485f526a0afc Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sun, 14 Jul 2024 16:59:51 -0700 Subject: [PATCH 1/7] [lldb] progressive progress reporting for darwin kernel/firmware When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. --- lldb/source/Core/DynamicLoader.cpp| 27 +++-- .../DynamicLoaderDarwinKernel.cpp | 39 --- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..a59136381c23b 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..93eb1e7b9dea9 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -757,6 +758,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +std::unique_ptr progress_up; +if (IsKernel()) { + StreamString prog_str; + // 'mach_kernel' is a fake name we make up to find kernels + // that were located by the local filesystem scan. + if (GetName() != "mach_kernel") +prog_str << GetName() << " "; + if (GetUUID().IsValid()) +prog_str << GetUUID().GetAsString() << " "; + if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(GetLoadAddress()); + } + progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); +} + // Search for the kext on the local filesystem via the UUID if (!m_module_sp && m_uuid.IsValid()) { ModuleSpec module_spec; @@ -1058,12 +1076,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { } } } - -if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) { - if (!m_kernel.LoadImageUsingMemoryModule(m_process)) { +if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) + if (!m_kernel.LoadImageUsingMemoryModule(m_process)) m_kernel.LoadImageAtFileAddress(m_process); - } -} // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits