[Lldb-commits] [lldb] [lldb] add missing cmake build type argument (PR #141427)
https://github.com/eronnen closed https://github.com/llvm/llvm-project/pull/141427 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ee9294f - [lldb] add missing cmake build type argument (#141427)
Author: Ely Ronnen Date: 2025-05-27T09:30:59+02:00 New Revision: ee9294f30007a1689ee01d627d575544d528b933 URL: https://github.com/llvm/llvm-project/commit/ee9294f30007a1689ee01d627d575544d528b933 DIFF: https://github.com/llvm/llvm-project/commit/ee9294f30007a1689ee01d627d575544d528b933.diff LOG: [lldb] add missing cmake build type argument (#141427) Necessary argument after https://github.com/llvm/llvm-project/commit/7dc7c155251c0008d5d59b84f0c9056365740f11 Added: Modified: lldb/utils/lldb-dotest/lldb-dotest.in Removed: diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index 9688b94d91842..c959c389f8a85 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -21,6 +21,7 @@ has_libcxx = @LLDB_HAS_LIBCXX@ libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@" libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@" libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@" +cmake_build_type = "@CMAKE_BUILD_TYPE@" if __name__ == '__main__': wrapper_args = sys.argv[1:] @@ -52,6 +53,7 @@ if __name__ == '__main__': if lldb_build_intel_pt == "1": cmd.extend(['--enable-plugin', 'intel-pt']) cmd.extend(['--lldb-obj-root', lldb_obj_root]) +cmd.extend(['--cmake-build-type', cmake_build_type]) cmd.extend(wrapper_args) # Invoke dotest.py and return exit code. print(' '.join(cmd)) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -1731,8 +1737,12 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() { DataVisualization::Categories::GetCategory(ConstString(GetPluginName()), g_category); if (g_category) { - LoadLibStdcppFormatters(g_category); + // NOTE: the libstdcpp formatters are loaded after libcxx formatters + // because we don't want to the libcxx formatters to match the potential + // `__debug` inline namespace that libstdcpp may use. since LLDB Michael137 wrote: ```suggestion // `__debug` inline namespace that libstdcpp may use. LLDB ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on arm 32 architecture (PR #141407)
DavidSpickett wrote: The reasoning is fine but I'm pretty sure there's an existing way to write this skipif, let me look for it. https://github.com/llvm/llvm-project/pull/141407 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dapSupport breakpoint info bytes (PR #141122)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/141122 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Support breakpoint info bytes (PR #141122)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/141122 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f30a85b - [lldb][test] Skip unamed symbol test on Arm
Author: David Spickett Date: 2025-05-27T11:39:50Z New Revision: f30a85b7005cb332b88d91dfe9ef094ef6249bd9 URL: https://github.com/llvm/llvm-project/commit/f30a85b7005cb332b88d91dfe9ef094ef6249bd9 DIFF: https://github.com/llvm/llvm-project/commit/f30a85b7005cb332b88d91dfe9ef094ef6249bd9.diff LOG: [lldb][test] Skip unamed symbol test on Arm Same purpose as https://github.com/llvm/llvm-project/pull/141407, comitting this directly to get the bot green sooner. Co-authored-by: Ely Ronnen Added: Modified: lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py Removed: diff --git a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py index c0438f77fb1d1..34a6cabd5d2c1 100644 --- a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py +++ b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py @@ -10,6 +10,8 @@ # --keep-symbol causes error on Windows: llvm-strip.exe: error: option is not supported for COFF @skipIfWindows +# Unnamed symbols don't get into the .eh_frame section on ARM, so LLDB can't find them. +@skipIf(archs=["arm"]) class TestUnnamedSymbolLookup(TestBase): def test_unnamed_symbol_lookup(self): """Test looking up unnamed symbol synthetic name""" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on arm 32 architecture (PR #141407)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/141407 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make AddressRange dump easier on the eye (PR #141062)
@@ -11,7 +11,7 @@ image show-unwind -n func0 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes. # CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no. # CHECK-NEXT: This UnwindPlan is for a trap handler function: no. -# CHECK-NEXT: Address range of this UnwindPlan: [stack-cfi-parsing.out..module_image + 0-0x0002) +# CHECK-NEXT: Address range of this UnwindPlan: [stack-cfi-parsing.out..module_image + 0-2) DavidSpickett wrote: Got it. Well this is nic*er* than it was, so it's fine. https://github.com/llvm/llvm-project/pull/141062 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make AddressRange dump easier on the eye (PR #141062)
https://github.com/DavidSpickett approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/141062 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)
frederick-vs-ja wrote: > I'm a bit confused why this test is special and would be the only one > manually setting `disableASLR=False`. I changed the default in #113593 Would it be a good idea to change here instead in order to restore `disableASLR=False`? https://github.com/llvm/llvm-project/blob/bf6cd24aaadd8310408d733c944f0d5f9cc14c0a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py#L409-L417 https://github.com/llvm/llvm-project/pull/141543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF ParseSymtab handling (PR #141577)
https://github.com/DhruvSrivastavaX created https://github.com/llvm/llvm-project/pull/141577 This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 **Description:** Adding ParseSymtab logic after creating sections. It is able to handle both 32 and 64 bit symbols, without the need to add template logic. This is an incremental PR on top of my previous couple of XCOFF support commits. >From a62cd7b510f3cf74ee356a95a26e0f9922f4b39c Mon Sep 17 00:00:00 2001 From: DhruvSrivastavaX Date: Tue, 27 May 2025 05:44:55 -0500 Subject: [PATCH] Added XCOFF ParseSymtab handling --- .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 66 ++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp index e629355cd40b9..7dfe6c362add4 100644 --- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp @@ -188,7 +188,71 @@ AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) { return AddressClass::eUnknown; } -void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {} +lldb::SymbolType MapSymbolType(llvm::object::SymbolRef::Type sym_type) { + if (sym_type == llvm::object::SymbolRef::ST_Function) +return lldb::eSymbolTypeCode; + else if (sym_type == llvm::object::SymbolRef::ST_Data) +return lldb::eSymbolTypeData; + else if (sym_type == llvm::object::SymbolRef::ST_File) +return lldb::eSymbolTypeSourceFile; + return lldb::eSymbolTypeInvalid; +} + +void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) { + SectionList *sectionList = GetSectionList(); + + for (const auto &symbol_ref : m_binary->symbols()) { +llvm::object::XCOFFSymbolRef xcoff_sym_ref(symbol_ref); +llvm::Expected name_or_err = xcoff_sym_ref.getName(); +if (!name_or_err) { + consumeError(name_or_err.takeError()); + continue; +} +llvm::StringRef symbolName = name_or_err.get(); +// Remove the dot prefix for demangle +llvm::StringRef symbol_name = +symbolName.starts_with(".") ? symbolName.drop_front() : symbolName; +auto storageClass = xcoff_sym_ref.getStorageClass(); +if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") { + if (xcoff_sym_ref.getNumberOfAuxEntries() != 1) +continue; + auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef(); + if (!aux_csect_or_err) { +consumeError(aux_csect_or_err.takeError()); +continue; + } + const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get(); + if (csect_aux.getStorageMappingClass() != XCOFF::XMC_PR || + (m_binary->is64Bit() ? (csect_aux.getAuxType64() != XCOFF::AUX_CSECT) + : false)) +continue; +} + +Symbol symbol; +symbol.GetMangled().SetValue(ConstString(symbol_name)); + +int16_t sectionNumber = xcoff_sym_ref.getSectionNumber(); +size_t sectionIndex = static_cast(sectionNumber - 1); +if (sectionNumber > 0 && sectionIndex < sectionList->GetSize()) { + lldb::SectionSP section_sp = + sectionList->GetSectionAtIndex(sectionNumber - 1); + if (!section_sp || section_sp->GetFileAddress() == LLDB_INVALID_ADDRESS) +continue; + lldb::addr_t file_addr = section_sp->GetFileAddress(); + lldb::addr_t symbolValue = xcoff_sym_ref.getValue(); + if (symbolValue < file_addr) +continue; + symbol.GetAddressRef() = Address(section_sp, symbolValue - file_addr); +} + +Expected sym_type_or_err = +symbol_ref.getType(); +symbol.SetType(MapSymbolType(sym_type_or_err.get())); +printf("%s %d\n", symbol.GetName(), *sym_type_or_err); + +lldb_symtab.AddSymbol(symbol); + } +} bool ObjectFileXCOFF::IsStripped() { return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF ParseSymtab handling (PR #141577)
DhruvSrivastavaX wrote: Hi @labath @DavidSpickett I have added the logic for ParseSymtab, but while trying to modify my test cases, I noticed that lldb-test cannot emit Symbol data. Is there any other way that i can use to add test for this code? Although I did verify via prompt, that my symbols are getting added in the symtab. https://github.com/llvm/llvm-project/pull/141577 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Support breakpoint info bytes (PR #141122)
@@ -16,12 +15,61 @@ namespace lldb_dap { +static llvm::Expected +HandleDataBreakpointBytes(DAP &dap, + const protocol::DataBreakpointInfoArguments &args) { + llvm::StringRef address = args.name; + + unsigned long long load_addr = LLDB_INVALID_ADDRESS; + if (llvm::getAsUnsignedInteger(address, 0, load_addr)) { +return llvm::make_error(llvm::formatv("invalid address"), + llvm::inconvertibleErrorCode(), false); + } + + lldb::SBAddress sb_addr(load_addr, dap.target); + if (!sb_addr.IsValid()) { +return llvm::make_error( +llvm::formatv("address {:x} does not exist in the debuggee", load_addr), +llvm::inconvertibleErrorCode(), false); + } + + const uint32_t byte_size = + args.bytes.value_or(dap.target.GetAddressByteSize()); + + protocol::DataBreakpointInfoResponseBody response; + response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size); + + lldb::SBMemoryRegionInfo region; + lldb::SBError err = + dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); + // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this DavidSpickett wrote: This API can return information about regions that are not mapped, you can check that with: ``` /// Check if this memory address is mapped into the process address /// space. /// /// \return /// true if this memory address is in the process address space. bool IsMapped(); ``` Though, I would assume an unmapped region would be neither readable nor writeable, so it may not be relevant whether it's mapped or not. In theory memory can be mapped and not readable, though I don't know how Linux presents it. Execute only memory you can fetch from but not load from. If you were using lldb-dap with an embedded target, it could be a concern. I don't know if any of that is a concern for this code specifically though. https://github.com/llvm/llvm-project/pull/141122 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Support breakpoint info bytes (PR #141122)
@@ -16,12 +15,61 @@ namespace lldb_dap { +static llvm::Expected +HandleDataBreakpointBytes(DAP &dap, + const protocol::DataBreakpointInfoArguments &args) { + llvm::StringRef address = args.name; + + unsigned long long load_addr = LLDB_INVALID_ADDRESS; + if (llvm::getAsUnsignedInteger(address, 0, load_addr)) { +return llvm::make_error(llvm::formatv("invalid address"), + llvm::inconvertibleErrorCode(), false); + } + + lldb::SBAddress sb_addr(load_addr, dap.target); + if (!sb_addr.IsValid()) { +return llvm::make_error( +llvm::formatv("address {:x} does not exist in the debuggee", load_addr), +llvm::inconvertibleErrorCode(), false); + } + + const uint32_t byte_size = + args.bytes.value_or(dap.target.GetAddressByteSize()); + + protocol::DataBreakpointInfoResponseBody response; + response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size); + + lldb::SBMemoryRegionInfo region; + lldb::SBError err = + dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); + // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this + // request if SBProcess::GetMemoryRegionInfo returns error. + if (err.Success() && !(region.IsReadable() || region.IsWritable())) { +response.description = llvm::formatv( +"memory region for address {} has no read or write permissions", +load_addr); + + } else { +response.description = +llvm::formatv("{} bytes at {:x}", byte_size, load_addr); +response.accessTypes = {protocol::eDataBreakpointAccessTypeRead, DavidSpickett wrote: Internally we use a yes/no/don't know enum to represent the region properties. The SBI API converts yes to bool true: ``` bool SBMemoryRegionInfo::IsReadable() { LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetReadable() == MemoryRegionInfo::eYes; } ``` Maybe that helps? I lldb couldn't read memory region info and returned you an incomplete object, it would return false for a lot of these properties because it doesn't know either way. https://github.com/llvm/llvm-project/pull/141122 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/cmake] Don't call llvm_process_sources (PR #141217)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/141217 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)
DavidSpickett wrote: I see the magic exit value listed in https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55. I wondered if we could say "exited with NTSTATUS ", but I'm not sure if all exit codes in this scenario would be NTSATUS or only a subset. Not a big deal though, googling "windows exit code 0xC135" gets you pretty close to what it means. https://github.com/llvm/llvm-project/pull/141290 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)
https://github.com/labath commented: I'm not sure this change is beneficial in the cases where it causes an increase in the level of indentation (due to separating the check for TargetSP from other validity checks). What would you say to using the c++17 init-statement, plus condition? https://github.com/llvm/llvm-project/pull/141284 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Support breakpoint info bytes (PR #141122)
@@ -16,12 +15,61 @@ namespace lldb_dap { +static llvm::Expected +HandleDataBreakpointBytes(DAP &dap, + const protocol::DataBreakpointInfoArguments &args) { + llvm::StringRef address = args.name; + + unsigned long long load_addr = LLDB_INVALID_ADDRESS; + if (llvm::getAsUnsignedInteger(address, 0, load_addr)) { +return llvm::make_error(llvm::formatv("invalid address"), + llvm::inconvertibleErrorCode(), false); + } + + lldb::SBAddress sb_addr(load_addr, dap.target); + if (!sb_addr.IsValid()) { +return llvm::make_error( +llvm::formatv("address {:x} does not exist in the debuggee", load_addr), +llvm::inconvertibleErrorCode(), false); + } + + const uint32_t byte_size = + args.bytes.value_or(dap.target.GetAddressByteSize()); + + protocol::DataBreakpointInfoResponseBody response; + response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size); + + lldb::SBMemoryRegionInfo region; + lldb::SBError err = + dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); + // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this DavidSpickett wrote: The existing comment though is partially correct. Debugserver does implement it too, I've never seen anything GDB derived implement it. https://github.com/llvm/llvm-project/pull/141122 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/141284 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)
@@ -0,0 +1,22 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MissingDllTestCase(TestBase): +@skipUnlessWindows +def test(self): DavidSpickett wrote: Add a docstring to explain the purpose, such as: ``` """ Test that lldb reports the application's NTSTATUS exit code, rather than trying to treat it as a Win32 error number. """ ``` https://github.com/llvm/llvm-project/pull/141290 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)
https://github.com/labath commented: This PR also contains clang and compiler-rt changes. You'll have better luck finding someone to approve your PR if you split it along subproject boundaries. Also, what's up with the extra blank line after the first header you are adding everywhere? I don't think we have that as a convention. https://github.com/llvm/llvm-project/pull/141478 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727 >From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 18 May 2025 09:55:25 +0100 Subject: [PATCH 1/4] [lldb] optionally match the `__debug` namespace for libstdc++ containers. If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++ .../TestDataFormatterCategories.py| 4 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..e98eef49f501a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$", + eFormatterMatchRegex, Synt
[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF ParseSymtab handling (PR #141577)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/141577 >From a62cd7b510f3cf74ee356a95a26e0f9922f4b39c Mon Sep 17 00:00:00 2001 From: DhruvSrivastavaX Date: Tue, 27 May 2025 05:44:55 -0500 Subject: [PATCH 1/2] Added XCOFF ParseSymtab handling --- .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 66 ++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp index e629355cd40b9..7dfe6c362add4 100644 --- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp @@ -188,7 +188,71 @@ AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) { return AddressClass::eUnknown; } -void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {} +lldb::SymbolType MapSymbolType(llvm::object::SymbolRef::Type sym_type) { + if (sym_type == llvm::object::SymbolRef::ST_Function) +return lldb::eSymbolTypeCode; + else if (sym_type == llvm::object::SymbolRef::ST_Data) +return lldb::eSymbolTypeData; + else if (sym_type == llvm::object::SymbolRef::ST_File) +return lldb::eSymbolTypeSourceFile; + return lldb::eSymbolTypeInvalid; +} + +void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) { + SectionList *sectionList = GetSectionList(); + + for (const auto &symbol_ref : m_binary->symbols()) { +llvm::object::XCOFFSymbolRef xcoff_sym_ref(symbol_ref); +llvm::Expected name_or_err = xcoff_sym_ref.getName(); +if (!name_or_err) { + consumeError(name_or_err.takeError()); + continue; +} +llvm::StringRef symbolName = name_or_err.get(); +// Remove the dot prefix for demangle +llvm::StringRef symbol_name = +symbolName.starts_with(".") ? symbolName.drop_front() : symbolName; +auto storageClass = xcoff_sym_ref.getStorageClass(); +if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") { + if (xcoff_sym_ref.getNumberOfAuxEntries() != 1) +continue; + auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef(); + if (!aux_csect_or_err) { +consumeError(aux_csect_or_err.takeError()); +continue; + } + const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get(); + if (csect_aux.getStorageMappingClass() != XCOFF::XMC_PR || + (m_binary->is64Bit() ? (csect_aux.getAuxType64() != XCOFF::AUX_CSECT) + : false)) +continue; +} + +Symbol symbol; +symbol.GetMangled().SetValue(ConstString(symbol_name)); + +int16_t sectionNumber = xcoff_sym_ref.getSectionNumber(); +size_t sectionIndex = static_cast(sectionNumber - 1); +if (sectionNumber > 0 && sectionIndex < sectionList->GetSize()) { + lldb::SectionSP section_sp = + sectionList->GetSectionAtIndex(sectionNumber - 1); + if (!section_sp || section_sp->GetFileAddress() == LLDB_INVALID_ADDRESS) +continue; + lldb::addr_t file_addr = section_sp->GetFileAddress(); + lldb::addr_t symbolValue = xcoff_sym_ref.getValue(); + if (symbolValue < file_addr) +continue; + symbol.GetAddressRef() = Address(section_sp, symbolValue - file_addr); +} + +Expected sym_type_or_err = +symbol_ref.getType(); +symbol.SetType(MapSymbolType(sym_type_or_err.get())); +printf("%s %d\n", symbol.GetName(), *sym_type_or_err); + +lldb_symtab.AddSymbol(symbol); + } +} bool ObjectFileXCOFF::IsStripped() { return false; } >From 3b425c933a8d9c9128ba1741ca5e3d24ec463cc9 Mon Sep 17 00:00:00 2001 From: Dhruv Srivastava Date: Tue, 27 May 2025 16:33:08 +0530 Subject: [PATCH 2/2] cleanup --- lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp index 7dfe6c362add4..f19100ea6963c 100644 --- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp @@ -248,7 +248,6 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) { Expected sym_type_or_err = symbol_ref.getType(); symbol.SetType(MapSymbolType(sym_type_or_err.get())); -printf("%s %d\n", symbol.GetName(), *sym_type_or_err); lldb_symtab.AddSymbol(symbol); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF ParseSymtab handling (PR #141577)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dhruv Srivastava (DhruvSrivastavaX) Changes This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 **Description:** Adding ParseSymtab logic after creating sections. It is able to handle both 32 and 64 bit symbols, without the need to add template logic. This is an incremental PR on top of my previous couple of XCOFF support commits. --- Full diff: https://github.com/llvm/llvm-project/pull/141577.diff 1 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp (+65-1) ``diff diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp index e629355cd40b9..7dfe6c362add4 100644 --- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp @@ -188,7 +188,71 @@ AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) { return AddressClass::eUnknown; } -void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {} +lldb::SymbolType MapSymbolType(llvm::object::SymbolRef::Type sym_type) { + if (sym_type == llvm::object::SymbolRef::ST_Function) +return lldb::eSymbolTypeCode; + else if (sym_type == llvm::object::SymbolRef::ST_Data) +return lldb::eSymbolTypeData; + else if (sym_type == llvm::object::SymbolRef::ST_File) +return lldb::eSymbolTypeSourceFile; + return lldb::eSymbolTypeInvalid; +} + +void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) { + SectionList *sectionList = GetSectionList(); + + for (const auto &symbol_ref : m_binary->symbols()) { +llvm::object::XCOFFSymbolRef xcoff_sym_ref(symbol_ref); +llvm::Expected name_or_err = xcoff_sym_ref.getName(); +if (!name_or_err) { + consumeError(name_or_err.takeError()); + continue; +} +llvm::StringRef symbolName = name_or_err.get(); +// Remove the dot prefix for demangle +llvm::StringRef symbol_name = +symbolName.starts_with(".") ? symbolName.drop_front() : symbolName; +auto storageClass = xcoff_sym_ref.getStorageClass(); +if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") { + if (xcoff_sym_ref.getNumberOfAuxEntries() != 1) +continue; + auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef(); + if (!aux_csect_or_err) { +consumeError(aux_csect_or_err.takeError()); +continue; + } + const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get(); + if (csect_aux.getStorageMappingClass() != XCOFF::XMC_PR || + (m_binary->is64Bit() ? (csect_aux.getAuxType64() != XCOFF::AUX_CSECT) + : false)) +continue; +} + +Symbol symbol; +symbol.GetMangled().SetValue(ConstString(symbol_name)); + +int16_t sectionNumber = xcoff_sym_ref.getSectionNumber(); +size_t sectionIndex = static_cast(sectionNumber - 1); +if (sectionNumber > 0 && sectionIndex < sectionList->GetSize()) { + lldb::SectionSP section_sp = + sectionList->GetSectionAtIndex(sectionNumber - 1); + if (!section_sp || section_sp->GetFileAddress() == LLDB_INVALID_ADDRESS) +continue; + lldb::addr_t file_addr = section_sp->GetFileAddress(); + lldb::addr_t symbolValue = xcoff_sym_ref.getValue(); + if (symbolValue < file_addr) +continue; + symbol.GetAddressRef() = Address(section_sp, symbolValue - file_addr); +} + +Expected sym_type_or_err = +symbol_ref.getType(); +symbol.SetType(MapSymbolType(sym_type_or_err.get())); +printf("%s %d\n", symbol.GetName(), *sym_type_or_err); + +lldb_symtab.AddSymbol(symbol); + } +} bool ObjectFileXCOFF::IsStripped() { return false; } `` https://github.com/llvm/llvm-project/pull/141577 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on arm 32 architecture (PR #141407)
DavidSpickett wrote: I've pushed it directly to get the bot green: https://github.com/llvm/llvm-project/commit/f30a85b7005cb332b88d91dfe9ef094ef6249bd9 Thanks for figuring out the reason for the failure. https://github.com/llvm/llvm-project/pull/141407 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727 >From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 18 May 2025 09:55:25 +0100 Subject: [PATCH 1/5] [lldb] optionally match the `__debug` namespace for libstdc++ containers. If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++ .../TestDataFormatterCategories.py| 4 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..e98eef49f501a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$", + eFormatterMatchRegex, Synt
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,8 +19,17 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command("", {}) Michael137 wrote: ```suggestion self.with_run_command() ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727 >From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 18 May 2025 09:55:25 +0100 Subject: [PATCH 1/6] [lldb] optionally match the `__debug` namespace for libstdc++ containers. If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++ .../TestDataFormatterCategories.py| 4 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..e98eef49f501a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$", + eFormatterMatchRegex, Synt
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,8 +19,17 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command("", {}) da-viper wrote: Mb, Sometimes I don't notice them till I pul https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)
frederick-vs-ja wrote: There're many TSan and MSan errors seemingly related to ASLR. But it's curious that how did they happen when `TestDAP_subtleFrames.py` hasn't been executed. https://github.com/llvm/llvm-project/pull/141543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 052c704 - [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (#141220)
Author: Michael Buch Date: 2025-05-27T09:29:31+01:00 New Revision: 052c70451afb7323ef72f321f3b0b5abb024b302 URL: https://github.com/llvm/llvm-project/commit/052c70451afb7323ef72f321f3b0b5abb024b302 DIFF: https://github.com/llvm/llvm-project/commit/052c70451afb7323ef72f321f3b0b5abb024b302.diff LOG: [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (#141220) `parseAndLoadModuleMapFile` returns `true` on error. This seems to have always been an issue? This is now preventing me from fixing a different modules related issue. So this patch checks the return value correctly. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index eb62cb618f254..c99ed9dd0a68d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -330,7 +330,7 @@ bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module, auto file = HS.lookupModuleMapFile(*dir, is_framework); if (!file) return error(); - if (!HS.parseAndLoadModuleMapFile(*file, is_system)) + if (HS.parseAndLoadModuleMapFile(*file, is_system)) return error(); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (PR #141220)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/141220 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)
Michael137 wrote: I'm a bit confused why this test is special and would be the only one manually setting `disableASLR=False`. I changed the default in https://github.com/llvm/llvm-project/pull/113593 @JDevlieghere @ashgti why did we switch the default back to `disableASLR=False`? https://github.com/llvm/llvm-project/pull/141543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,9 +19,23 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command("", {}) + +@add_test_categories(["libstdcxx"]) +@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") +def test_with_run_command_debug(self): +build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} +self.with_run_command("__debug::", build_args) + +def with_run_command(self, namespace: str, dictionary: dict): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) +self.build(dictionary=dictionary) +artifact_name = dictionary.get("EXE", "a.out") +self.runCmd( +"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET Michael137 wrote: ```suggestion self.runCmd( "file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,9 +19,21 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command({}) + +@add_test_categories(["libstdcxx"]) +@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") +def test_with_run_command_debug(self): +build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} +self.with_run_command(build_args) + +def with_run_command(self, dictionary: dict): Michael137 wrote: Same applies to the other tests https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -47,8 +61,9 @@ def cleanup(): self.runCmd("frame variable ii --show-types") +match = f"std::{namespace}map<" Michael137 wrote: ```suggestion ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,9 +19,21 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command({}) + +@add_test_categories(["libstdcxx"]) +@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") +def test_with_run_command_debug(self): +build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} +self.with_run_command(build_args) + +def with_run_command(self, dictionary: dict): Michael137 wrote: Lets make it a default argument so the other function doesn't need to pass `{}` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,9 +19,21 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command({}) + +@add_test_categories(["libstdcxx"]) +@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") +def test_with_run_command_debug(self): +build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} +self.with_run_command(build_args) + +def with_run_command(self, dictionary: dict): """Test that that file and class static variables display correctly.""" -self.build() -self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) +self.build(dictionary=dictionary) +artifact_name = "a.out" +self.runCmd( +"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET Michael137 wrote: Same applies to the other tests https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -19,9 +19,21 @@ def setUp(self): @add_test_categories(["libstdcxx"]) @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") def test_with_run_command(self): +self.with_run_command({}) + +@add_test_categories(["libstdcxx"]) +@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") +def test_with_run_command_debug(self): +build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} +self.with_run_command(build_args) + +def with_run_command(self, dictionary: dict): """Test that that file and class static variables display correctly.""" -self.build() -self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) +self.build(dictionary=dictionary) +artifact_name = "a.out" +self.runCmd( +"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET Michael137 wrote: ```suggestion self.runCmd( "file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/Michael137 approved this pull request. LGTM (once latest round of comments is addressed) https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -47,8 +61,9 @@ def cleanup(): self.runCmd("frame variable ii --show-types") +match = f"std::{namespace}map<" self.runCmd( -'type summary add -x "std::map<" --summary-string "map has ${svar%#} items" -e' +f'type summary add -x "{match}" --summary-string "map has ${{svar%#}} items" -e' Michael137 wrote: ```suggestion f'type summary add -x "std::{namespace}map<" --summary-string "map has ${{svar%#}} items" -e' ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)
Michael137 wrote: Looks like https://github.com/llvm/llvm-project/pull/140107 refactored this stuff and as @frederick-vs-ja points out, my fix in https://github.com/llvm/llvm-project/pull/113593 essentially got reverted. @ashgti is there some default config for tests that we could stick `disableASLR=False` into? https://github.com/llvm/llvm-project/pull/141543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/140762 >From cc3c6d1c86ae0ed579c4f325778ee1b4cd90d6be Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Tue, 20 May 2025 17:45:20 +0100 Subject: [PATCH 1/4] refactor demangler range tracking --- lldb/include/lldb/Core/DemangledNameInfo.h | 18 +- lldb/include/lldb/Core/FormatEntity.h | 1 + lldb/source/Core/FormatEntity.cpp | 3 +++ lldb/source/Core/Mangled.cpp | 2 ++ .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 4 ++-- lldb/unittests/Core/CMakeLists.txt | 2 +- ...{MangledTest.cpp => ItaniumMangledTest.cpp} | 13 +++-- 7 files changed, 33 insertions(+), 10 deletions(-) rename lldb/unittests/Core/{MangledTest.cpp => ItaniumMangledTest.cpp} (98%) diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h b/lldb/include/lldb/Core/DemangledNameInfo.h index 11d3bb58871b8..76cf8908fcbe6 100644 --- a/lldb/include/lldb/Core/DemangledNameInfo.h +++ b/lldb/include/lldb/Core/DemangledNameInfo.h @@ -39,7 +39,7 @@ struct DemangledNameInfo { /// \endcode std::pair ScopeRange; - /// Indicates the [start, end) of the function argument lits. + /// Indicates the [start, end) of the function argument list. /// E.g., /// \code{.cpp} ///int (*getFunc(float, double))(int, int) @@ -59,11 +59,27 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's prefix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair PrefixRange; + + /// Indicates the [start, end) of the function's suffix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair SuffixRange; + /// Returns \c true if this object holds a valid basename range. bool hasBasename() const { return BasenameRange.second > BasenameRange.first && BasenameRange.second > 0; } + + /// Returns \c true if this object holds a valid arguments range. + bool hasArguments() const { +return ArgumentsRange.second > ArgumentsRange.first && + ArgumentsRange.second > 0; + } }; /// An OutputBuffer which keeps a record of where certain parts of a diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index 6acf6fbe43239..1aed3c6ff9e9d 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -88,6 +88,7 @@ struct Entry { FunctionNameWithArgs, FunctionNameNoArgs, FunctionMangledName, +FunctionPrefix, FunctionScope, FunctionBasename, FunctionTemplateArguments, diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 4f2d39873c7fb..4dcfa43a7bb04 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = { Definition("initial-function", EntryType::FunctionInitial), Definition("changed", EntryType::FunctionChanged), Definition("is-optimized", EntryType::FunctionIsOptimized), +Definition("prefix", EntryType::FunctionPrefix), Definition("scope", EntryType::FunctionScope), Definition("basename", EntryType::FunctionBasename), Definition("template-arguments", EntryType::FunctionTemplateArguments), @@ -385,6 +386,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) { ENUM_TO_CSTR(FunctionNameWithArgs); ENUM_TO_CSTR(FunctionNameNoArgs); ENUM_TO_CSTR(FunctionMangledName); +ENUM_TO_CSTR(FunctionPrefix); ENUM_TO_CSTR(FunctionScope); ENUM_TO_CSTR(FunctionBasename); ENUM_TO_CSTR(FunctionTemplateArguments); @@ -1835,6 +1837,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, return true; } + case Entry::Type::FunctionPrefix: case Entry::Type::FunctionScope: case Entry::Type::FunctionBasename: case Entry::Type::FunctionTemplateArguments: diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index ce4db4e0daa8b..e6f7d198d7316 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -172,6 +172,8 @@ GetItaniumDemangledStr(const char *M) { TrackingOutputBuffer OB(demangled_cstr, demangled_size); demangled_cstr = ipd.finishDemangle(&OB); +OB.NameInfo.SuffixRange.first = OB.NameInfo.QualifiersRange.second; +OB.NameInfo.SuffixRange.second = std::string(demangled_cstr).length(); info = std::move(OB.NameInfo); assert(demangled_cstr && diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..f45b4fb816b3b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -401,8 +401,8 @@ GetDemangledFun
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
@@ -59,10 +59,24 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's prefix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair PrefixRange; + + /// Indicates the [start, end) of the function's suffix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair SuffixRange; + /// Returns \c true if this object holds a valid basename range. bool hasBasename() const { -return BasenameRange.second > BasenameRange.first && - BasenameRange.second > 0; +return BasenameRange.second > BasenameRange.first; charles-zablit wrote: It was not needed but since I added the `hasArguments` method I wanted to remove the redundant `>0` check. Since the start and end range are unsigned, if `end > start`, then `end` is always greater than `0`, which is why I removed the second check. I might be missing something. https://github.com/llvm/llvm-project/pull/140762 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
@@ -59,10 +59,24 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's prefix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair PrefixRange; + + /// Indicates the [start, end) of the function's suffix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair SuffixRange; + /// Returns \c true if this object holds a valid basename range. bool hasBasename() const { -return BasenameRange.second > BasenameRange.first && - BasenameRange.second > 0; +return BasenameRange.second > BasenameRange.first; + } + + /// Returns \c true if this object holds a valid arguments range. + bool hasArguments() const { charles-zablit wrote: Yes, it's only used in the Apple fork, I have removed the change now. https://github.com/llvm/llvm-project/pull/140762 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727 >From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 18 May 2025 09:55:25 +0100 Subject: [PATCH 1/8] [lldb] optionally match the `__debug` namespace for libstdc++ containers. If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++ .../TestDataFormatterCategories.py| 4 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..e98eef49f501a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$", + eFormatterMatchRegex, Synt
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
@@ -6,7 +6,7 @@ add_lldb_unittest(LLDBCoreTests DumpDataExtractorTest.cpp DumpRegisterInfoTest.cpp FormatEntityTest.cpp - MangledTest.cpp + ItaniumMangledTest.cpp charles-zablit wrote: The rename was to separate the Swift tests from the Itanium tests. But as you said, it does not make much sense here. I will instead rename the tests to SwiftTests in the Apple fork. https://github.com/llvm/llvm-project/pull/140762 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
@@ -88,6 +88,7 @@ struct Entry { FunctionNameWithArgs, FunctionNameNoArgs, FunctionMangledName, +FunctionPrefix, charles-zablit wrote: Fixed, thanks 👍 https://github.com/llvm/llvm-project/pull/140762 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (PR #141610)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/141610 This is still leftover from the days when the libc++ and libstdc++ formatters were both written in python and in separate categories. Since then we group libstdc++ and libc++ formatters into the same cateogry. This patch removes references to the obsolete `gnu-libstdc++` category from the docs (and a test). See [this thread](https://github.com/llvm/llvm-project/pull/140761#discussion_r2099762155) for more context >From 012023ef991140b773a81b73c6b22f9ddff719d9 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 27 May 2025 15:29:58 +0100 Subject: [PATCH] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category This is still leftover from the days when the libc++ and libstdc++ formatters were both written in python and in separate categories. Since then we group libstdc++ and libc++ formatters into the same cateogry. This patch removes references to the obsolete `gnu-libstdc++` category from the docs (and a test). See [this thread](https://github.com/llvm/llvm-project/pull/140761#discussion_r2099762155) for more context --- lldb/docs/use/variable.rst | 14 ++ .../TestDataFormatterDisabling.py | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index 22c1fd64c4a96..c9bf76b0d4964 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -1209,16 +1209,15 @@ Categories -- Categories are a way to group related formatters. For instance, LLDB itself -groups the formatters for the libstdc++ types in a category named -gnu-libstdc++. Basically, categories act like containers in which to store -formatters for a same library or OS release. +groups the formatters for STL types in a category named cpluspus. Basically, +categories act like containers in which to store formatters for a same library +or OS release. By default, several categories are created in LLDB: - default: this is the category where every formatter ends up, unless another category is specified - objc: formatters for basic and common Objective-C types that do not specifically depend on macOS -- gnu-libstdc++: formatters for std::string, std::vector, std::list and std::map as implemented by libstdcpp -- libcxx: formatters for std::string, std::vector, std::list and std::map as implemented by libcxx +- cplusplus: formatters for STL types (currently only libc++ and libstdc++ are supported). Enabled when debugging C++ targets. - system: truly basic types for which a formatter is required - AppKit: Cocoa classes - CoreFoundation: CF classes @@ -1246,12 +1245,11 @@ that the search order is: - AppKit - CoreServices - CoreGraphics -- gnu-libstdc++ -- libcxx +- cplusplus - VectorTypes - system -As said, gnu-libstdc++ and libcxx contain formatters for C++ STL data types. +As said, cplusplus contain formatters for C++ STL data types. system contains formatters for char* and char[], which reflect the behavior of older versions of LLDB which had built-in formatters for these types. Because now these are formatters, you can even replace them with your own if so you diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py index e4214f17fb642..20f49e02adcea 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py @@ -46,8 +46,6 @@ def cleanup(): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) -# self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False) - self.expect( "type category list", substrs=[ ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (PR #141610)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/141610 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (PR #141610)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This is still leftover from the days when the libc++ and libstdc++ formatters were both written in python and in separate categories. Since then we group libstdc++ and libc++ formatters into the same cateogry. This patch removes references to the obsolete `gnu-libstdc++` category from the docs (and a test). See [this thread](https://github.com/llvm/llvm-project/pull/140761#discussion_r2099762155) for more context --- Full diff: https://github.com/llvm/llvm-project/pull/141610.diff 2 Files Affected: - (modified) lldb/docs/use/variable.rst (+6-8) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py (-2) ``diff diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index 22c1fd64c4a96..c9bf76b0d4964 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -1209,16 +1209,15 @@ Categories -- Categories are a way to group related formatters. For instance, LLDB itself -groups the formatters for the libstdc++ types in a category named -gnu-libstdc++. Basically, categories act like containers in which to store -formatters for a same library or OS release. +groups the formatters for STL types in a category named cpluspus. Basically, +categories act like containers in which to store formatters for a same library +or OS release. By default, several categories are created in LLDB: - default: this is the category where every formatter ends up, unless another category is specified - objc: formatters for basic and common Objective-C types that do not specifically depend on macOS -- gnu-libstdc++: formatters for std::string, std::vector, std::list and std::map as implemented by libstdcpp -- libcxx: formatters for std::string, std::vector, std::list and std::map as implemented by libcxx +- cplusplus: formatters for STL types (currently only libc++ and libstdc++ are supported). Enabled when debugging C++ targets. - system: truly basic types for which a formatter is required - AppKit: Cocoa classes - CoreFoundation: CF classes @@ -1246,12 +1245,11 @@ that the search order is: - AppKit - CoreServices - CoreGraphics -- gnu-libstdc++ -- libcxx +- cplusplus - VectorTypes - system -As said, gnu-libstdc++ and libcxx contain formatters for C++ STL data types. +As said, cplusplus contain formatters for C++ STL data types. system contains formatters for char* and char[], which reflect the behavior of older versions of LLDB which had built-in formatters for these types. Because now these are formatters, you can even replace them with your own if so you diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py index e4214f17fb642..20f49e02adcea 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py @@ -46,8 +46,6 @@ def cleanup(): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) -# self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False) - self.expect( "type category list", substrs=[ `` https://github.com/llvm/llvm-project/pull/141610 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (PR #141610)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/141610 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)
https://github.com/labath approved this pull request. Okay, looks good then. Thanks for your patience. https://github.com/llvm/llvm-project/pull/140150 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
@@ -16,10 +17,19 @@ def setUp(self): # Find the line number to break at. self.line = line_number("main.cpp", "// Set break point at this line.") +@skip @add_test_categories(["libstdcxx"]) def test_with_run_command(self): +self.with_run_command({}) Michael137 wrote: ```suggestion self.with_run_command() ``` https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/138687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)
@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) { ASSERT_THAT(exit_status.get_future().get(), 0); } +TEST(Host, FindProcesses) { + SubsystemRAII subsystems; + + if (test_arg != 0) +exit(0); + + ProcessLaunchInfo info; + ProcessInstanceInfoList processes; + ProcessInstanceInfoMatch match(TestMainArgv0, NameMatch::Equals); + info.SetExecutableFile(FileSpec(TestMainArgv0), + /*add_exe_file_as_first_arg=*/true); + info.GetArguments().AppendArgument("--gtest_filter=Host.FindProcesses"); + info.GetArguments().AppendArgument("--test-arg=48"); + std::promise exit_status; + info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) { +exit_status.set_value(status); + }); + ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded()); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + ASSERT_TRUE(Host::FindProcesses(match, processes)); + ASSERT_EQ(processes[0].GetArg0(), TestMainArgv0); labath wrote: Find the process in the list (in theory, this could find more than one instance) with the expected PID, and then check that it's GetExecutableFile() matches the one from the launch info (better not check for argv0, as not all implementations may be able to obtain that). https://github.com/llvm/llvm-project/pull/138687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (PR #141610)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/141610 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)
@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) { ASSERT_THAT(exit_status.get_future().get(), 0); } +TEST(Host, FindProcesses) { + SubsystemRAII subsystems; + + if (test_arg != 0) +exit(0); labath wrote: ```suggestion if (test_arg != 0) { // Give the parent time to retrieve information about us. It will kill us when it is done. std::this_thread::sleep_for(std::chrono::seconds(10)); exit(0); } ``` https://github.com/llvm/llvm-project/pull/138687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727 >From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 18 May 2025 09:55:25 +0100 Subject: [PATCH 1/7] [lldb] optionally match the `__debug` namespace for libstdc++ containers. If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++ .../TestDataFormatterCategories.py| 4 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..e98eef49f501a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$", + eFormatterMatchRegex, Synt
[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on arm 32 architecture (PR #141407)
https://github.com/JDevlieghere commented: Skipping the test is fine, but we don't need a new decorator for this. You can do this with: ``` @skipIf(archs=["arm"]) ``` If we thought this was important enough or a dedicated decorator, it should be implemented in terms of the generic one. @eronnen can you please revert this part of the change and update the decorator? https://github.com/llvm/llvm-project/pull/141407 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)
petrhosek wrote: We also saw a build failure on our Linux builders: ``` /b/s/w/ir/x/w/rc/cxx-rbew3r8iaxj/reclient-cxx-wrapper.sh /b/s/w/ir/x/w/cipd/clang/bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML_STATIC -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm_build/tools/lldb/source/Plugins/Process/Utility -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/include -I/b/s/w/ir/x/w/llvm_build/include -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include -I/b/s/w/ir/x/w/install-cpython-x86_64-linux-gnu/include/python3.11 -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/../clang/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/../clang/include -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/source -I/b/s/w/ir/x/w/llvm_build/tools/lldb/source -isystem /b/s/w/ir/x/w/install-zlib-x86_64-linux-gnu/include -isystem /b/s/w/ir/x/w/install-zstd-x86_64-linux-gnu/include -isystem /b/s/w/ir/x/w/install-libxml2-x86_64-linux-gnu/include/libxml2 -isystem /b/s/w/ir/x/w/install-libedit-x86_64-linux-gnu/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wno-unnecessary-virtual-specifier -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -MD -MT tools/lldb/source/Plugins/Process/Utility/CMakeFiles/lldbPluginProcessUtility.dir/LinuxSignals.cpp.o -MF tools/lldb/source/Plugins/Process/Utility/CMakeFiles/lldbPluginProcessUtility.dir/LinuxSignals.cpp.o.d -o tools/lldb/source/Plugins/Process/Utility/CMakeFiles/lldbPluginProcessUtility.dir/LinuxSignals.cpp.o -c /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:73:3: error: use of undeclared identifier 'SI_DETHREAD'; did you mean 'SIGEV_THREAD'? 73 | ADD_LINUX_SIGNAL(1, "SIGHUP", false,true, true, "hangup"); | ^~~~ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:57:29: note: expanded from macro 'ADD_LINUX_SIGNAL' 57 | ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, \ | ^~~ /b/s/w/ir/x/w/cipd/linux/usr/include/x86_64-linux-gnu/bits/siginfo.h:340:3: note: 'SIGEV_THREAD' declared here 340 | SIGEV_THREAD, /* Deliver via thread creation. */ | ^ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:73:3: error: static assertion failed due to requirement 'SIGEV_THREAD == -7': Value mismatch for signal code SI_DETHREAD 73 | ADD_LINUX_SIGNAL(1, "SIGHUP", false,true, true, "hangup"); | ^~~~ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:57:29: note: expanded from macro 'ADD_LINUX_SIGNAL' 57 | ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, \ | ~~^~~~ 58 | "sent by execve() killing subsidiary threads", \ | ~~ 59 | SignalCodePrintOption::Sender); \ | ~~ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:34:17: note: expanded from macro 'ADD_SIGCODE' 34 | static_assert(code_name == code_value, \ | ^~~ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:73:3: note: expression evaluates to '2 == -7' 73 | ADD_LINUX_SIGNAL(1, "SIGHUP", false,true, true, "hangup"); | ^~~~ /b/s/w/ir/x/w/llvm-llvm-project/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:57:3: note: expanded from macro 'ADD_LINUX_SIGNAL' 57 | ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, \ | ^~
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138032 >From b6edf90f106ee2b339a162e13058167899f2ee21 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 14:24:03 -0700 Subject: [PATCH] [lldb[RPC] Upstream RPC server interface emitters This commit upstreams the LLDB RPC server interface emitters. These emitters generate the server-side API interfaces for RPC, which communicate directly with liblldb itself out of process using the SB API. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- .../Inputs/Server/CheckBasicIncludesEmit.h| 6 + .../Inputs/Server/CheckConstCharPointer.h | 14 + .../Tests/Server/CheckBasicIncludesEmit.test | 14 + .../Tests/Server/CheckConstCharPointer.test | 10 + .../server/RPCServerHeaderEmitter.cpp | 75 +++ .../server/RPCServerHeaderEmitter.h | 47 ++ .../server/RPCServerSourceEmitter.cpp | 584 ++ .../server/RPCServerSourceEmitter.h | 81 +++ 8 files changed, 831 insertions(+) create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.h create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.h diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h new file mode 100644 index 0..77394aba12f7a --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h @@ -0,0 +1,6 @@ +// This ia a basic header file used to check that the server-side emitter +// for rpc-gen emits an expected set of includes in a generated source file. +#ifndef LLDB_API_SBRPC_CHECKBASICINCLUDE_H +#define LLDB_API_SBRPC_CHECKBASICINCLUDE_H + +#endif // LLDB_API_SBRPC_CHECKBASICINCLUDE_H diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h new file mode 100644 index 0..37121cd445267 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h @@ -0,0 +1,14 @@ +#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H +#define LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H + +namespace lldb { +class LLDB_API SBRPC_CHECKCONSTCHARPOINTER { +public: + // const char * parameters must decoded as rpc_common::ConstCharPointer in server side + // source files. + int CheckConstCharPointer(char *string); + +}; // class SBRPC_CHECKCONSTCHARPOINTER +} // namespace lldb + +#endif // LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test new file mode 100644 index 0..535d31886df6e --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test @@ -0,0 +1,14 @@ +UNSUPPORTED: target=* +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckBasicIncludesEmit.h + +RUN: cat %t/lib/CheckBasicIncludesEmit.cpp | FileCheck %s + +# All server-side source files must have these includes at the top of their files. +CHECK: #include "RPCUserServer.h" +CHECK: #include "SBAPI.h" +CHECK: #include +CHECK: #include +CHECK: #include +CHECK: #include diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test new file mode 100644 index 0..e3d92fa583431 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test @@ -0,0 +1,10 @@ +UNSUPPORTED: target=* +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckConstCharPointer.h + +RUN: cat %t/lib/CheckConstCharPointer.cpp | FileCheck %s + +# const char * pointers must be decoded as rpc_common::ConstCharPointer objects +# in server side source files. +CHECK: rpc_common::ConstCharPointer string diff --git a/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp b/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp new file mode 100644 index 0..30a18e3c7044b --- /dev/null +++ b/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp @@ -0,0 +1,75 @@ +//===-- RPCServerHeaderEmitter.cpp ===// +// +// Part of the LLVM Project
[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)
https://github.com/frederick-vs-ja edited https://github.com/llvm/llvm-project/pull/141543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
chelcassanova wrote: I added some small shell tests to this patch that check the output of the emitter mainly for sanity checking. @bulbazord I think having basic tests like what I added would be good for the server-side emitter, but if there's anything other thing you can think of test here please let me know! https://github.com/llvm/llvm-project/pull/138032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
@@ -0,0 +1,592 @@ +//===-- RPCServerSourceEmitter.cpp ===// +// +// 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 "RPCServerSourceEmitter.h" +#include "RPCCommon.h" + +#include "clang/AST/AST.h" +#include "clang/Frontend/CompilerInstance.h" + +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ToolOutputFile.h" +#include "llvm/Support/raw_ostream.h" + +#include + +using namespace clang; +using namespace lldb_rpc_gen; + +// For methods with pointer return types, it's important that we know how big +// the type of the pointee is. We must correctly size a buffer (in the form of a +// Bytes object) before we can actually use it. +static const std::map MethodsWithPointerReturnTypes = { +{"_ZN4lldb12SBModuleSpec12GetUUIDBytesEv", 16}, // sizeof(uuid_t) -> 16 +{"_ZNK4lldb8SBModule12GetUUIDBytesEv", 16}, // sizeof(uuid_t) -> 16 +}; + +void RPCServerSourceEmitter::EmitMethod(const Method &method) { + if (method.ContainsFunctionPointerParameter) +EmitCallbackFunction(method); + + EmitCommentHeader(method); + EmitFunctionHeader(method); + EmitFunctionBody(method); + EmitFunctionFooter(); +} + +void RPCServerSourceEmitter::EmitCommentHeader(const Method &method) { + std::string CommentLine; + llvm::raw_string_ostream CommentStream(CommentLine); + + CommentStream << "// " << method.QualifiedName << "(" +<< method.CreateParamListAsString(eServer) << ")"; + if (method.IsConst) +CommentStream << " const"; + + EmitLine("//"); + EmitLine(CommentLine); + EmitLine("//"); +} + +void RPCServerSourceEmitter::EmitFunctionHeader(const Method &method) { + std::string FunctionHeader; + llvm::raw_string_ostream FunctionHeaderStream(FunctionHeader); + FunctionHeaderStream + << "bool rpc_server::" << method.MangledName + << "::HandleRPCCall(rpc_common::Connection &connection, RPCStream " + "&send, RPCStream &response) {"; + EmitLine(FunctionHeader); + IndentLevel++; +} + +void RPCServerSourceEmitter::EmitFunctionBody(const Method &method) { + EmitLine("// 1) Make local storage for incoming function arguments"); + EmitStorageForParameters(method); + EmitLine("// 2) Decode all function arguments"); + EmitDecodeForParameters(method); + EmitLine("// 3) Call the method and encode the return value"); + EmitMethodCallAndEncode(method); +} + +void RPCServerSourceEmitter::EmitFunctionFooter() { + EmitLine("return true;"); + IndentLevel--; + EmitLine("}"); +} + +void RPCServerSourceEmitter::EmitStorageForParameters(const Method &method) { + // If we have an instance method and it isn't a constructor, we'll need to + // emit a "this" pointer. + if (method.IsInstance && !method.IsCtor) +EmitStorageForOneParameter(method.ThisType, "this_ptr", method.Policy, + /* IsFollowedByLen = */ false); + for (auto Iter = method.Params.begin(); Iter != method.Params.end(); Iter++) { +EmitStorageForOneParameter(Iter->Type, Iter->Name, method.Policy, + Iter->IsFollowedByLen); +// Skip over the length parameter, we don't emit it. +if (!lldb_rpc_gen::TypeIsConstCharPtrPtr(Iter->Type) && +Iter->IsFollowedByLen) + Iter++; + } +} + +void RPCServerSourceEmitter::EmitStorageForOneParameter( +QualType ParamType, const std::string &ParamName, +const PrintingPolicy &Policy, bool IsFollowedByLen) { + // First, we consider `const char *`, `const char **`. They have special + // server-side types. + if (TypeIsConstCharPtr(ParamType)) { +EmitLine("rpc_common::ConstCharPointer " + ParamName + ";"); +return; + } else if (TypeIsConstCharPtrPtr(ParamType)) { +EmitLine("rpc_common::StringList " + ParamName + ";"); +return; + } + + QualType UnderlyingType = + lldb_rpc_gen::GetUnqualifiedUnderlyingType(ParamType); + const bool IsSBClass = lldb_rpc_gen::TypeIsSBClass(UnderlyingType); + + if (ParamType->isPointerType() && !IsSBClass) { +// Void pointer with no length is usually a baton for a callback. We're +// going to hold onto the pointer value so we can send it back to the +// client-side when we implement callbacks. +if (ParamType->isVoidPointerType() && !IsFollowedByLen) { + EmitLine("void * " + ParamName + " = nullptr;"); + return; +} + +if (!ParamType->isFunctionPointerType()) { + EmitLine("Bytes " + ParamName + ";"); + return; +} + +assert(ParamType->isFunctionPointerType() && "Unhandled pointer type"); +EmitLine("rpc_common::function_ptr_t " + Pa
[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138028 >From 2b6f460e1e2a358aafef80354010cbad87ac5134 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 13:37:15 -0700 Subject: [PATCH] [lldb][RPC] Upstream Python scripts As part of upstreaming LLDB RPC, this commit adds python scripts that are used by LLDB RPC to modify the public lldb header files for use with RPC. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- .../convert-lldb-header-to-rpc-header.py | 71 +++ lldb/scripts/framework-header-include-fix.py | 46 .../TestConvertScript/CheckLLDBDefines.test | 23 ++ .../CheckLLDBEnumerations.test| 21 ++ .../TestConvertScript/CheckLLDBTypes.test | 25 +++ .../TestConvertScript/CheckSBDefines.test | 23 ++ .../TestConvertScript/Inputs/SBDefines.h | 22 ++ .../TestConvertScript/Inputs/lldb-defines.h | 23 ++ .../Inputs/lldb-enumerations.h| 17 + .../TestConvertScript/Inputs/lldb-types.h | 23 ++ .../CheckLLDBDefines.test | 9 +++ .../CheckLLDBTypes.test | 9 +++ .../CheckSBClass.test | 11 +++ .../CheckSBDefines.test | 12 .../Inputs/SBDefines.h| 9 +++ .../Inputs/SBRPC-FrameworkFix.h | 10 +++ .../Inputs/lldb-rpc-defines.h | 7 ++ .../Inputs/lldb-rpc-types.h | 7 ++ 18 files changed, 368 insertions(+) create mode 100755 lldb/scripts/convert-lldb-header-to-rpc-header.py create mode 100755 lldb/scripts/framework-header-include-fix.py create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBTypes.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-defines.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h create mode 100644 lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h diff --git a/lldb/scripts/convert-lldb-header-to-rpc-header.py b/lldb/scripts/convert-lldb-header-to-rpc-header.py new file mode 100755 index 0..a7fd4733af56f --- /dev/null +++ b/lldb/scripts/convert-lldb-header-to-rpc-header.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +""" +Usage: convert-lldb-header-to-rpc-header.py + +This scripts takes common LLDB headers (such as lldb-defines.h) and replaces references to LLDB +with those for RPC. This happens for: +- namespace definitions +- namespace usage +- version string macros +- ifdef/ifndef lines +""" +# Usage: convert-lldb-header-to-rpc-header.py + +import argparse +import os +import re + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("input") +parser.add_argument("output") +args = parser.parse_args() +input_path = str(args.input) +output_path = str(args.output) +with open(input_path, "r") as input_file: +lines = input_file.readlines() + +with open(output_path, "w") as output_file: +for line in lines: +# NOTE: We do not use lldb-forward.h or lldb-versioning.h in RPC, so remove +# all includes that are found for these files. +if re.match( +r'#include "lldb/lldb-forward|#include "lldb/lldb-versioning', line +): +continue +# For lldb-rpc-defines.h, replace the ifndef LLDB_LLDB_ portion with LLDB_RPC_ as we're not +# using LLDB private definitions in RPC. +elif re.match(r".+LLDB_LLDB_", line): +output_file.write(re.sub(r"LLDB_LLDB_", r"LLDB_RPC_", line)) +# Similarly to lldb-rpc-defines.h, replace the ifndef for LLDB_API in SBDefines.h to LLDB_
[Lldb-commits] [lldb] 04f9fac - [lldb] optionally match the `__debug` namespace for libstdc++ containers. (#140727)
Author: Ebuka Ezike Date: 2025-05-27T20:52:51+01:00 New Revision: 04f9fac62238a4af2755e40b8020c64b3055c19a URL: https://github.com/llvm/llvm-project/commit/04f9fac62238a4af2755e40b8020c64b3055c19a DIFF: https://github.com/llvm/llvm-project/commit/04f9fac62238a4af2755e40b8020c64b3055c19a.diff LOG: [lldb] optionally match the `__debug` namespace for libstdc++ containers. (#140727) If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`. The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added. Fixes #60841 Added: Modified: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..b178e06a975cd 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -592,7 +592,7 @@ class NodeAllocator { public: void reset() { Alloc.Reset(); } - template T *makeNode(Args &&... args) { + template T *makeNode(Args &&...args) { return new (Alloc.Allocate(sizeof(T), alignof(T))) T(std::forward(args)...); } @@ -614,7 +614,7 @@ class ManglingSubstitutor ManglingSubstitutor() : Base(nullptr, nullptr) {} template - ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) { + ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) { this->getDerived().reset(Mangled, std::forward(Vals)...); return substituteImpl(Mangled); } @@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_deref_flags.SetFrontEndWantsDereference(); cpp_category_sp->AddTypeSynthetic( - "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex, + "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex, + "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$", + eFormatterMatchRegex, SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->AddTypeSynthetic( - "^s
[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/140727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)
HighCommander4 wrote: > Any update about the issue that I reported above? You may want to open a new issue to track that, so it can get annotated with the appropriate labels (e.g. `rejects-valid`) and get more attention by showing up on issues lists / dashboards that people may be watching. https://github.com/llvm/llvm-project/pull/132401 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)
JDevlieghere wrote: @Nerixyz Do you need someone to merge this on your behalf? https://github.com/llvm/llvm-project/pull/141290 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138032 >From c209f358c0a897499bfd93508bc72d52baa25d07 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 14:24:03 -0700 Subject: [PATCH] [lldb[RPC] Upstream RPC server interface emitters This commit upstreams the LLDB RPC server interface emitters. These emitters generate the server-side API interfaces for RPC, which communicate directly with liblldb itself out of process using the SB API. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- .../Inputs/Server/CheckBasicIncludesEmit.h| 6 + .../Inputs/Server/CheckConstCharPointer.h | 14 + .../Tests/Server/CheckBasicIncludesEmit.test | 15 + .../Tests/Server/CheckConstCharPointer.test | 11 + .../server/RPCServerHeaderEmitter.cpp | 75 +++ .../server/RPCServerHeaderEmitter.h | 47 ++ .../server/RPCServerSourceEmitter.cpp | 584 ++ .../server/RPCServerSourceEmitter.h | 81 +++ 8 files changed, 833 insertions(+) create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.h create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.h diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h new file mode 100644 index 0..77394aba12f7a --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h @@ -0,0 +1,6 @@ +// This ia a basic header file used to check that the server-side emitter +// for rpc-gen emits an expected set of includes in a generated source file. +#ifndef LLDB_API_SBRPC_CHECKBASICINCLUDE_H +#define LLDB_API_SBRPC_CHECKBASICINCLUDE_H + +#endif // LLDB_API_SBRPC_CHECKBASICINCLUDE_H diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h new file mode 100644 index 0..37121cd445267 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h @@ -0,0 +1,14 @@ +#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H +#define LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H + +namespace lldb { +class LLDB_API SBRPC_CHECKCONSTCHARPOINTER { +public: + // const char * parameters must decoded as rpc_common::ConstCharPointer in server side + // source files. + int CheckConstCharPointer(char *string); + +}; // class SBRPC_CHECKCONSTCHARPOINTER +} // namespace lldb + +#endif // LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test new file mode 100644 index 0..2283fe8c66530 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test @@ -0,0 +1,15 @@ +# Disabling until the lldb-rpc-gen tool lands. +UNSUPPORTED: system-windows, system-linux, system-darwin +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckBasicIncludesEmit.h + +RUN: cat %t/lib/CheckBasicIncludesEmit.cpp | FileCheck %s + +# All server-side source files must have these includes at the top of their files. +CHECK: #include "RPCUserServer.h" +CHECK: #include "SBAPI.h" +CHECK: #include +CHECK: #include +CHECK: #include +CHECK: #include diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test new file mode 100644 index 0..77eadd2fed132 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test @@ -0,0 +1,11 @@ +# Disabling until the lldb-rpc-gen tool lands. +UNSUPPORTED: system-windows, system-linux, system-darwin +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckConstCharPointer.h + +RUN: cat %t/lib/CheckConstCharPointer.cpp | FileCheck %s + +# const char * pointers must be decoded as rpc_common::ConstCharPointer objects +# in server side source files. +CHECK: rpc_common::ConstCharPointer string diff --git a/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp b/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp new file mode 100644 index 0..30a18e3c7044b --- /dev/null +++ b/lldb/tools/lldb-rpc/lldb-rpc-gen/
[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)
https://github.com/DavidSpickett approved this pull request. LGTM. This is a nice improvement thanks for working on it. https://github.com/llvm/llvm-project/pull/141290 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e3e5bd1 - [lldb/cmake] Don't call llvm_process_sources (#141217)
Author: Pavel Labath Date: 2025-05-27T14:32:16+02:00 New Revision: e3e5bd1cb1511403f4f74746efdde9a5429c7088 URL: https://github.com/llvm/llvm-project/commit/e3e5bd1cb1511403f4f74746efdde9a5429c7088 DIFF: https://github.com/llvm/llvm-project/commit/e3e5bd1cb1511403f4f74746efdde9a5429c7088.diff LOG: [lldb/cmake] Don't call llvm_process_sources (#141217) It's already called in llvm_add_library. Added: Modified: lldb/cmake/modules/AddLLDB.cmake Removed: diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 2956cdb7f9c8a..3a9dcb79629b4 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -45,7 +45,6 @@ function(add_lldb_library name) "INSTALL_PREFIX;ENTITLEMENTS" "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS" ${ARGN}) - llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS}) list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS}) if(PARAM_NO_INTERNAL_DEPENDENCIES) @@ -77,7 +76,6 @@ function(add_lldb_library name) list(GET split_path -1 dir) file(GLOB_RECURSE headers ../../include/lldb${dir}/*.h) -set(srcs ${srcs} ${headers}) endif() if (PARAM_MODULE) set(libkind MODULE) @@ -101,7 +99,8 @@ function(add_lldb_library name) set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH) endif() - llvm_add_library(${name} ${libkind} ${srcs} + llvm_add_library(${name} ${libkind} ${headers} +${PARAM_UNPARSED_ARGUMENTS} LINK_LIBS ${PARAM_LINK_LIBS} DEPENDS ${PARAM_DEPENDS} ${pass_ENTITLEMENTS} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)
https://github.com/Nerixyz updated https://github.com/llvm/llvm-project/pull/141290 >From 339bae7cd6bae4a701c74a6b93e5dfdb75166a7c Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 23 May 2025 21:47:40 +0200 Subject: [PATCH] [LLDB] Show exit code on Windows if process can't launch --- .../Windows/Common/ProcessDebugger.cpp| 3 ++- .../API/windows/launch/missing-dll/Makefile | 5 .../launch/missing-dll/TestMissingDll.py | 27 +++ .../windows/launch/missing-dll/dummy_dll.c| 1 + .../API/windows/launch/missing-dll/main.c | 6 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/windows/launch/missing-dll/Makefile create mode 100644 lldb/test/API/windows/launch/missing-dll/TestMissingDll.py create mode 100644 lldb/test/API/windows/launch/missing-dll/dummy_dll.c create mode 100644 lldb/test/API/windows/launch/missing-dll/main.c diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp index bde72d61b0fee..a0f622fd69902 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp @@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) { // of the error otherwise WaitForDebuggerConnection() will be blocked. // An example of this issue is when a process fails to load a dependent DLL. if (m_session_data && !m_session_data->m_initial_stop_received) { -Status error(exit_code, eErrorTypeWin32); +Status error = Status::FromErrorStringWithFormatv( +"Process prematurely exited with {0:x}", exit_code); OnDebuggerError(error, 0); } } diff --git a/lldb/test/API/windows/launch/missing-dll/Makefile b/lldb/test/API/windows/launch/missing-dll/Makefile new file mode 100644 index 0..43e02d1d8f22b --- /dev/null +++ b/lldb/test/API/windows/launch/missing-dll/Makefile @@ -0,0 +1,5 @@ +C_SOURCES := main.c +DYLIB_C_SOURCES := dummy_dll.c +DYLIB_NAME := dummy_dll + +include Makefile.rules diff --git a/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py new file mode 100644 index 0..b8a9d77db648c --- /dev/null +++ b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py @@ -0,0 +1,27 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MissingDllTestCase(TestBase): +@skipUnlessWindows +def test(self): +""" +Test that lldb reports the application's exit code (STATUS_DLL_NOT_FOUND), +rather than trying to treat it as a Win32 error number. +""" + +self.build() +exe = self.getBuildArtifact("a.out") +dll = self.getBuildArtifact("dummy_dll.dll") +self.assertTrue(remove_file(dll)) +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +launch_info = lldb.SBLaunchInfo(None) +launch_info.SetWorkingDirectory(self.get_process_working_directory()) + +error = lldb.SBError() +target.Launch(launch_info, error) +self.assertFailure(error, "Process prematurely exited with 0xc135") diff --git a/lldb/test/API/windows/launch/missing-dll/dummy_dll.c b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c new file mode 100644 index 0..61bde26534966 --- /dev/null +++ b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c @@ -0,0 +1 @@ +__declspec(dllexport) void SomeFunction(void) {} diff --git a/lldb/test/API/windows/launch/missing-dll/main.c b/lldb/test/API/windows/launch/missing-dll/main.c new file mode 100644 index 0..bf773cd945819 --- /dev/null +++ b/lldb/test/API/windows/launch/missing-dll/main.c @@ -0,0 +1,6 @@ +__declspec(dllimport) void SomeFunction(void); + +int main(void) { + SomeFunction(); + return 0; +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] DisassembleRequestHandler: use a better invalid instruction (PR #141463)
https://github.com/ashgti approved this pull request. https://github.com/llvm/llvm-project/pull/141463 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/140762 >From cc3c6d1c86ae0ed579c4f325778ee1b4cd90d6be Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Tue, 20 May 2025 17:45:20 +0100 Subject: [PATCH 1/7] refactor demangler range tracking --- lldb/include/lldb/Core/DemangledNameInfo.h | 18 +- lldb/include/lldb/Core/FormatEntity.h | 1 + lldb/source/Core/FormatEntity.cpp | 3 +++ lldb/source/Core/Mangled.cpp | 2 ++ .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 4 ++-- lldb/unittests/Core/CMakeLists.txt | 2 +- ...{MangledTest.cpp => ItaniumMangledTest.cpp} | 13 +++-- 7 files changed, 33 insertions(+), 10 deletions(-) rename lldb/unittests/Core/{MangledTest.cpp => ItaniumMangledTest.cpp} (98%) diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h b/lldb/include/lldb/Core/DemangledNameInfo.h index 11d3bb58871b8..76cf8908fcbe6 100644 --- a/lldb/include/lldb/Core/DemangledNameInfo.h +++ b/lldb/include/lldb/Core/DemangledNameInfo.h @@ -39,7 +39,7 @@ struct DemangledNameInfo { /// \endcode std::pair ScopeRange; - /// Indicates the [start, end) of the function argument lits. + /// Indicates the [start, end) of the function argument list. /// E.g., /// \code{.cpp} ///int (*getFunc(float, double))(int, int) @@ -59,11 +59,27 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's prefix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair PrefixRange; + + /// Indicates the [start, end) of the function's suffix. This is a + /// catch-all range for anything that is not tracked by the rest of + /// the pairs. + std::pair SuffixRange; + /// Returns \c true if this object holds a valid basename range. bool hasBasename() const { return BasenameRange.second > BasenameRange.first && BasenameRange.second > 0; } + + /// Returns \c true if this object holds a valid arguments range. + bool hasArguments() const { +return ArgumentsRange.second > ArgumentsRange.first && + ArgumentsRange.second > 0; + } }; /// An OutputBuffer which keeps a record of where certain parts of a diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index 6acf6fbe43239..1aed3c6ff9e9d 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -88,6 +88,7 @@ struct Entry { FunctionNameWithArgs, FunctionNameNoArgs, FunctionMangledName, +FunctionPrefix, FunctionScope, FunctionBasename, FunctionTemplateArguments, diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 4f2d39873c7fb..4dcfa43a7bb04 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = { Definition("initial-function", EntryType::FunctionInitial), Definition("changed", EntryType::FunctionChanged), Definition("is-optimized", EntryType::FunctionIsOptimized), +Definition("prefix", EntryType::FunctionPrefix), Definition("scope", EntryType::FunctionScope), Definition("basename", EntryType::FunctionBasename), Definition("template-arguments", EntryType::FunctionTemplateArguments), @@ -385,6 +386,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) { ENUM_TO_CSTR(FunctionNameWithArgs); ENUM_TO_CSTR(FunctionNameNoArgs); ENUM_TO_CSTR(FunctionMangledName); +ENUM_TO_CSTR(FunctionPrefix); ENUM_TO_CSTR(FunctionScope); ENUM_TO_CSTR(FunctionBasename); ENUM_TO_CSTR(FunctionTemplateArguments); @@ -1835,6 +1837,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, return true; } + case Entry::Type::FunctionPrefix: case Entry::Type::FunctionScope: case Entry::Type::FunctionBasename: case Entry::Type::FunctionTemplateArguments: diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index ce4db4e0daa8b..e6f7d198d7316 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -172,6 +172,8 @@ GetItaniumDemangledStr(const char *M) { TrackingOutputBuffer OB(demangled_cstr, demangled_size); demangled_cstr = ipd.finishDemangle(&OB); +OB.NameInfo.SuffixRange.first = OB.NameInfo.QualifiersRange.second; +OB.NameInfo.SuffixRange.second = std::string(demangled_cstr).length(); info = std::move(OB.NameInfo); assert(demangled_cstr && diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 542f13bef23e7..f45b4fb816b3b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -401,8 +401,8 @@ GetDemangledFun
[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/141284 >From 2735f5ad08bd6ac5bdf31104af452f6a1abf0920 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 23 May 2025 12:20:52 -0700 Subject: [PATCH] [lldb] Use if-with-initializer pattern in SBTarget (NFC) Use the if statement with an initializer pattern that's very common in LLVM in SBTarget. Every time someone adds a new method to SBTarget, I want to encourage using this pattern, but I don't because it would be inconsistent with the rest of the file. This solves that problem by switching over the whole file. --- lldb/source/API/SBTarget.cpp | 801 --- 1 file changed, 360 insertions(+), 441 deletions(-) diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index cd8a770a0ec04..2a28a5367b7c1 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -166,8 +166,7 @@ SBProcess SBTarget::GetProcess() { SBProcess sb_process; ProcessSP process_sp; - TargetSP target_sp(GetSP()); - if (target_sp) { + if (TargetSP target_sp = GetSP()) { process_sp = target_sp->GetProcessSP(); sb_process.SetSP(process_sp); } @@ -178,22 +177,19 @@ SBProcess SBTarget::GetProcess() { SBPlatform SBTarget::GetPlatform() { LLDB_INSTRUMENT_VA(this); - TargetSP target_sp(GetSP()); - if (!target_sp) -return SBPlatform(); - - SBPlatform platform; - platform.m_opaque_sp = target_sp->GetPlatform(); - - return platform; + if (TargetSP target_sp = GetSP()) { +SBPlatform platform; +platform.m_opaque_sp = target_sp->GetPlatform(); +return platform; + } + return SBPlatform(); } SBDebugger SBTarget::GetDebugger() const { LLDB_INSTRUMENT_VA(this); SBDebugger debugger; - TargetSP target_sp(GetSP()); - if (target_sp) + if (TargetSP target_sp = GetSP()) debugger.reset(target_sp->GetDebugger().shared_from_this()); return debugger; } @@ -208,41 +204,38 @@ SBStructuredData SBTarget::GetStatistics(SBStatisticsOptions options) { LLDB_INSTRUMENT_VA(this); SBStructuredData data; - TargetSP target_sp(GetSP()); - if (!target_sp) + if (TargetSP target_sp = GetSP()) { +std::string json_str = +llvm::formatv("{0:2}", DebuggerStats::ReportStatistics( + target_sp->GetDebugger(), target_sp.get(), + options.ref())) +.str(); +data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str)); return data; - std::string json_str = - llvm::formatv("{0:2}", DebuggerStats::ReportStatistics( - target_sp->GetDebugger(), target_sp.get(), - options.ref())) - .str(); - data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str)); + } return data; } void SBTarget::ResetStatistics() { LLDB_INSTRUMENT_VA(this); - TargetSP target_sp(GetSP()); - if (target_sp) + + if (TargetSP target_sp = GetSP()) DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get()); } void SBTarget::SetCollectingStats(bool v) { LLDB_INSTRUMENT_VA(this, v); - TargetSP target_sp(GetSP()); - if (!target_sp) -return; - return DebuggerStats::SetCollectingStats(v); + if (TargetSP target_sp = GetSP()) +DebuggerStats::SetCollectingStats(v); } bool SBTarget::GetCollectingStats() { LLDB_INSTRUMENT_VA(this); - TargetSP target_sp(GetSP()); - if (!target_sp) -return false; - return DebuggerStats::GetCollectingStats(); + if (TargetSP target_sp = GetSP()) +return DebuggerStats::GetCollectingStats(); + return false; } SBProcess SBTarget::LoadCore(const char *core_file) { @@ -256,8 +249,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { LLDB_INSTRUMENT_VA(this, core_file, error); SBProcess sb_process; - TargetSP target_sp(GetSP()); - if (target_sp) { + if (TargetSP target_sp = GetSP()) { FileSpec filespec(core_file); FileSystem::Instance().Resolve(filespec); ProcessSP process_sp(target_sp->CreateProcess( @@ -303,8 +295,7 @@ SBError SBTarget::Install() { LLDB_INSTRUMENT_VA(this); SBError sb_error; - TargetSP target_sp(GetSP()); - if (target_sp) { + if (TargetSP target_sp = GetSP()) { std::lock_guard guard(target_sp->GetAPIMutex()); sb_error.ref() = target_sp->Install(nullptr); } @@ -323,9 +314,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, SBProcess sb_process; ProcessSP process_sp; - TargetSP target_sp(GetSP()); - - if (target_sp) { + if (TargetSP target_sp = GetSP()) { std::lock_guard guard(target_sp->GetAPIMutex()); if (stop_at_entry) @@ -400,9 +389,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { LLDB_INSTRUMENT_VA(this, sb_launch_info, error); SBProcess sb_process; - TargetSP target_sp(GetSP()); - - if (target_sp) { + if (TargetSP target_
[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)
JDevlieghere wrote: > @felipepiovezan I am indeed the problem here. I'm confused how they're > passing on Linux but failing on Mac. I'll investigate. If you think this might take a while, can we revert this in the meantime? https://github.com/llvm/llvm-project/pull/140150 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141645)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/141645 Reverts llvm/llvm-project#140150 Broke the Darwin tests, but they pass on Linux. Reverting to make the build healthy while I investigate >From 8da155e11c3d168d8f8ad59d4691156e57549d57 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 27 May 2025 10:55:30 -0700 Subject: [PATCH] Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (#140150)" This reverts commit ff7bb17c88328276323603809d5d4549ca8bd22b. --- lldb/include/lldb/Target/Platform.h | 3 - lldb/include/lldb/Target/UnixSignals.h| 6 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 105 .../Plugins/Platform/Linux/PlatformLinux.h| 2 - .../Plugins/Process/Utility/LinuxSignals.cpp | 154 -- .../Process/elf-core/ProcessElfCore.cpp | 20 ++- .../Process/elf-core/ThreadElfCore.cpp| 136 +++- .../Plugins/Process/elf-core/ThreadElfCore.h | 75 ++--- lldb/source/Target/UnixSignals.cpp| 15 +- lldb/unittests/Signals/UnixSignalsTest.cpp| 9 - 10 files changed, 230 insertions(+), 295 deletions(-) diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 35ffdabf907e7..a702abb540fd9 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -21,7 +21,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Options.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -961,8 +960,6 @@ class Platform : public PluginInterface { virtual CompilerType GetSiginfoType(const llvm::Triple &triple); - virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; } - virtual Args GetExtraStartupCommands(); typedef std::function code = std::nullopt, std::optional addr = std::nullopt, std::optional lower = std::nullopt, - std::optional upper = std::nullopt, - std::optional pid = std::nullopt, - std::optional uid = std::nullopt) const; + std::optional upper = std::nullopt) const; bool SignalIsValid(int32_t signo) const; @@ -107,7 +105,7 @@ class UnixSignals { llvm::StringRef description, llvm::StringRef alias = llvm::StringRef()); - enum SignalCodePrintOption { None, Address, Bounds, Sender }; + enum SignalCodePrintOption { None, Address, Bounds }; // Instead of calling this directly, use a ADD_SIGCODE macro to get compile // time checks when on the native platform. diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index cb60caf1cb422..9db2c83acc125 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -14,7 +14,6 @@ #include #endif -#include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -481,107 +480,3 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } - -static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { - if (!siginfo_sp) -return ""; - - lldb_private::LinuxSignals linux_signals; - int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); - int signo = - siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); - - auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); - if (!sifields) -return linux_signals.GetSignalDescription(signo, code); - - // declare everything that we can populate later. - std::optional addr; - std::optional upper; - std::optional lower; - std::optional pid; - std::optional uid; - - // The negative si_codes are special and mean this signal was sent from user - // space not the kernel. These take precedence because they break some of the - // invariants around kernel sent signals. Such as SIGSEGV won't have an - // address. - if (code < 0) { -auto sikill = sifields->GetChildMemberWithName("_kill"); -if (sikill) { - auto pid_sp = sikill->GetChildMemberWithName("si_pid"); - if (pid_sp) -pid = pid_sp->GetValueAsUnsigned(-1); - auto uid_sp = sikill->GetChildMemberWithName("si_uid"); - if (uid_sp) -uid = uid_sp->GetValueAsUnsigned(-1); -} - } else { - -switch (signo) { -case SIGILL: -case SIGFPE: -case SIGBUS: { - auto sigfault = sifields->GetChildMemberWithName("_sigfault"); - if (!sigfault) -break; - - auto addr_sp = sigfault->GetChildMemberWi
[Lldb-commits] [lldb] 9d33b92 - Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (#141645)
Author: Jacob Lalonde Date: 2025-05-27T10:55:59-07:00 New Revision: 9d33b9291318c117429ab461c2119c108abd6ed2 URL: https://github.com/llvm/llvm-project/commit/9d33b9291318c117429ab461c2119c108abd6ed2 DIFF: https://github.com/llvm/llvm-project/commit/9d33b9291318c117429ab461c2119c108abd6ed2.diff LOG: Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (#141645) Reverts llvm/llvm-project#140150 Broke the Darwin tests, but they pass on Linux. Reverting to make the build healthy while I investigate Added: Modified: lldb/include/lldb/Target/Platform.h lldb/include/lldb/Target/UnixSignals.h lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/source/Plugins/Platform/Linux/PlatformLinux.h lldb/source/Plugins/Process/Utility/LinuxSignals.cpp lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp lldb/source/Plugins/Process/elf-core/ThreadElfCore.h lldb/source/Target/UnixSignals.cpp lldb/unittests/Signals/UnixSignalsTest.cpp Removed: diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 35ffdabf907e7..a702abb540fd9 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -21,7 +21,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Options.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -961,8 +960,6 @@ class Platform : public PluginInterface { virtual CompilerType GetSiginfoType(const llvm::Triple &triple); - virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; } - virtual Args GetExtraStartupCommands(); typedef std::function code = std::nullopt, std::optional addr = std::nullopt, std::optional lower = std::nullopt, - std::optional upper = std::nullopt, - std::optional pid = std::nullopt, - std::optional uid = std::nullopt) const; + std::optional upper = std::nullopt) const; bool SignalIsValid(int32_t signo) const; @@ -107,7 +105,7 @@ class UnixSignals { llvm::StringRef description, llvm::StringRef alias = llvm::StringRef()); - enum SignalCodePrintOption { None, Address, Bounds, Sender }; + enum SignalCodePrintOption { None, Address, Bounds }; // Instead of calling this directly, use a ADD_SIGCODE macro to get compile // time checks when on the native platform. diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index cb60caf1cb422..9db2c83acc125 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -14,7 +14,6 @@ #include #endif -#include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -481,107 +480,3 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } - -static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { - if (!siginfo_sp) -return ""; - - lldb_private::LinuxSignals linux_signals; - int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); - int signo = - siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); - - auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); - if (!sifields) -return linux_signals.GetSignalDescription(signo, code); - - // declare everything that we can populate later. - std::optional addr; - std::optional upper; - std::optional lower; - std::optional pid; - std::optional uid; - - // The negative si_codes are special and mean this signal was sent from user - // space not the kernel. These take precedence because they break some of the - // invariants around kernel sent signals. Such as SIGSEGV won't have an - // address. - if (code < 0) { -auto sikill = sifields->GetChildMemberWithName("_kill"); -if (sikill) { - auto pid_sp = sikill->GetChildMemberWithName("si_pid"); - if (pid_sp) -pid = pid_sp->GetValueAsUnsigned(-1); - auto uid_sp = sikill->GetChildMemberWithName("si_uid"); - if (uid_sp) -uid = uid_sp->GetValueAsUnsigned(-1); -} - } else { - -switch (signo) { -case SIGILL: -case SIGFPE: -case SIGBUS: { - auto sigfault = sifields->GetChildMemberWithName("_sigfault"); - if (!sigfault) -break; - - auto addr_sp = sigfault->GetChildMemberWithName("si_addr")
[Lldb-commits] [lldb] Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141645)
https://github.com/Jlalond closed https://github.com/llvm/llvm-project/pull/141645 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141645)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes Reverts llvm/llvm-project#140150 Broke the Darwin tests, but they pass on Linux. Reverting to make the build healthy while I investigate --- Patch is 38.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/141645.diff 10 Files Affected: - (modified) lldb/include/lldb/Target/Platform.h (-3) - (modified) lldb/include/lldb/Target/UnixSignals.h (+2-4) - (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (-105) - (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.h (-2) - (modified) lldb/source/Plugins/Process/Utility/LinuxSignals.cpp (+66-88) - (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+11-9) - (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+92-44) - (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.h (+53-22) - (modified) lldb/source/Target/UnixSignals.cpp (+6-9) - (modified) lldb/unittests/Signals/UnixSignalsTest.cpp (-9) ``diff diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 35ffdabf907e7..a702abb540fd9 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -21,7 +21,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Options.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -961,8 +960,6 @@ class Platform : public PluginInterface { virtual CompilerType GetSiginfoType(const llvm::Triple &triple); - virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; } - virtual Args GetExtraStartupCommands(); typedef std::function code = std::nullopt, std::optional addr = std::nullopt, std::optional lower = std::nullopt, - std::optional upper = std::nullopt, - std::optional pid = std::nullopt, - std::optional uid = std::nullopt) const; + std::optional upper = std::nullopt) const; bool SignalIsValid(int32_t signo) const; @@ -107,7 +105,7 @@ class UnixSignals { llvm::StringRef description, llvm::StringRef alias = llvm::StringRef()); - enum SignalCodePrintOption { None, Address, Bounds, Sender }; + enum SignalCodePrintOption { None, Address, Bounds }; // Instead of calling this directly, use a ADD_SIGCODE macro to get compile // time checks when on the native platform. diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index cb60caf1cb422..9db2c83acc125 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -14,7 +14,6 @@ #include #endif -#include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -481,107 +480,3 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } - -static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { - if (!siginfo_sp) -return ""; - - lldb_private::LinuxSignals linux_signals; - int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); - int signo = - siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); - - auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); - if (!sifields) -return linux_signals.GetSignalDescription(signo, code); - - // declare everything that we can populate later. - std::optional addr; - std::optional upper; - std::optional lower; - std::optional pid; - std::optional uid; - - // The negative si_codes are special and mean this signal was sent from user - // space not the kernel. These take precedence because they break some of the - // invariants around kernel sent signals. Such as SIGSEGV won't have an - // address. - if (code < 0) { -auto sikill = sifields->GetChildMemberWithName("_kill"); -if (sikill) { - auto pid_sp = sikill->GetChildMemberWithName("si_pid"); - if (pid_sp) -pid = pid_sp->GetValueAsUnsigned(-1); - auto uid_sp = sikill->GetChildMemberWithName("si_uid"); - if (uid_sp) -uid = uid_sp->GetValueAsUnsigned(-1); -} - } else { - -switch (signo) { -case SIGILL: -case SIGFPE: -case SIGBUS: { - auto sigfault = sifields->GetChildMemberWithName("_sigfault"); - if (!sigfault) -break; - - auto addr_sp = sigfault->GetChildMemberWithName("si_addr"); - if (addr_sp) -addr = addr_sp->GetValueAsUnsigned(-1); - break; -
[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)
Jlalond wrote: @JDevlieghere reverted while I investigate https://github.com/llvm/llvm-project/pull/140150 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141670)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/141670 After some debugging, I found out ProcessELFCore never updates the platform. I've updated ProcessElfCore to set the arch and platform before we parse the Notes. >From 048cc769d6380bcb899bbcc5acf7f9349b51c5d3 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 27 May 2025 13:40:40 -0700 Subject: [PATCH 1/2] Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (#141645) This reverts commit 9d33b9291318c117429ab461c2119c108abd6ed2. --- lldb/include/lldb/Target/Platform.h | 3 + lldb/include/lldb/Target/UnixSignals.h| 6 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 105 .../Plugins/Platform/Linux/PlatformLinux.h| 2 + .../Plugins/Process/Utility/LinuxSignals.cpp | 154 ++ .../Process/elf-core/ProcessElfCore.cpp | 20 +-- .../Process/elf-core/ThreadElfCore.cpp| 136 +--- .../Plugins/Process/elf-core/ThreadElfCore.h | 75 +++-- lldb/source/Target/UnixSignals.cpp| 15 +- lldb/unittests/Signals/UnixSignalsTest.cpp| 9 + 10 files changed, 295 insertions(+), 230 deletions(-) diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index a702abb540fd9..35ffdabf907e7 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -21,6 +21,7 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Target/StopInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -960,6 +961,8 @@ class Platform : public PluginInterface { virtual CompilerType GetSiginfoType(const llvm::Triple &triple); + virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; } + virtual Args GetExtraStartupCommands(); typedef std::function code = std::nullopt, std::optional addr = std::nullopt, std::optional lower = std::nullopt, - std::optional upper = std::nullopt) const; + std::optional upper = std::nullopt, + std::optional pid = std::nullopt, + std::optional uid = std::nullopt) const; bool SignalIsValid(int32_t signo) const; @@ -105,7 +107,7 @@ class UnixSignals { llvm::StringRef description, llvm::StringRef alias = llvm::StringRef()); - enum SignalCodePrintOption { None, Address, Bounds }; + enum SignalCodePrintOption { None, Address, Bounds, Sender }; // Instead of calling this directly, use a ADD_SIGCODE macro to get compile // time checks when on the native platform. diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 9db2c83acc125..cb60caf1cb422 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -14,6 +14,7 @@ #include #endif +#include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -480,3 +481,107 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } + +static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { + if (!siginfo_sp) +return ""; + + lldb_private::LinuxSignals linux_signals; + int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); + int signo = + siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); + + auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); + if (!sifields) +return linux_signals.GetSignalDescription(signo, code); + + // declare everything that we can populate later. + std::optional addr; + std::optional upper; + std::optional lower; + std::optional pid; + std::optional uid; + + // The negative si_codes are special and mean this signal was sent from user + // space not the kernel. These take precedence because they break some of the + // invariants around kernel sent signals. Such as SIGSEGV won't have an + // address. + if (code < 0) { +auto sikill = sifields->GetChildMemberWithName("_kill"); +if (sikill) { + auto pid_sp = sikill->GetChildMemberWithName("si_pid"); + if (pid_sp) +pid = pid_sp->GetValueAsUnsigned(-1); + auto uid_sp = sikill->GetChildMemberWithName("si_uid"); + if (uid_sp) +uid = uid_sp->GetValueAsUnsigned(-1); +} + } else { + +switch (signo) { +case SIGILL: +case SIGFPE: +case SIGBUS: { + auto sigfault = sifields->GetChildMemberWithName("_sigfault"); + if (!sigfault) +break; + + auto addr_sp
[Lldb-commits] [lldb] Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141670)
Jlalond wrote: @JDevlieghere Is there a way to trigger GreenDragon/Mac CI for this? https://github.com/llvm/llvm-project/pull/141670 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (PR #141670)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes After some debugging, I found out ProcessELFCore never updates the platform. I've updated ProcessElfCore to set the arch and platform before we parse the Notes. --- Patch is 39.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/141670.diff 10 Files Affected: - (modified) lldb/include/lldb/Target/Platform.h (+3) - (modified) lldb/include/lldb/Target/UnixSignals.h (+4-2) - (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (+105) - (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.h (+2) - (modified) lldb/source/Plugins/Process/Utility/LinuxSignals.cpp (+88-66) - (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+20-22) - (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+44-92) - (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.h (+22-53) - (modified) lldb/source/Target/UnixSignals.cpp (+9-6) - (modified) lldb/unittests/Signals/UnixSignalsTest.cpp (+9) ``diff diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index a702abb540fd9..35ffdabf907e7 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -21,6 +21,7 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Target/StopInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -960,6 +961,8 @@ class Platform : public PluginInterface { virtual CompilerType GetSiginfoType(const llvm::Triple &triple); + virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; } + virtual Args GetExtraStartupCommands(); typedef std::function code = std::nullopt, std::optional addr = std::nullopt, std::optional lower = std::nullopt, - std::optional upper = std::nullopt) const; + std::optional upper = std::nullopt, + std::optional pid = std::nullopt, + std::optional uid = std::nullopt) const; bool SignalIsValid(int32_t signo) const; @@ -105,7 +107,7 @@ class UnixSignals { llvm::StringRef description, llvm::StringRef alias = llvm::StringRef()); - enum SignalCodePrintOption { None, Address, Bounds }; + enum SignalCodePrintOption { None, Address, Bounds, Sender }; // Instead of calling this directly, use a ADD_SIGCODE macro to get compile // time checks when on the native platform. diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 9db2c83acc125..cb60caf1cb422 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -14,6 +14,7 @@ #include #endif +#include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -480,3 +481,107 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->CompleteTagDeclarationDefinition(siginfo_type); return siginfo_type; } + +static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { + if (!siginfo_sp) +return ""; + + lldb_private::LinuxSignals linux_signals; + int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); + int signo = + siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); + + auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); + if (!sifields) +return linux_signals.GetSignalDescription(signo, code); + + // declare everything that we can populate later. + std::optional addr; + std::optional upper; + std::optional lower; + std::optional pid; + std::optional uid; + + // The negative si_codes are special and mean this signal was sent from user + // space not the kernel. These take precedence because they break some of the + // invariants around kernel sent signals. Such as SIGSEGV won't have an + // address. + if (code < 0) { +auto sikill = sifields->GetChildMemberWithName("_kill"); +if (sikill) { + auto pid_sp = sikill->GetChildMemberWithName("si_pid"); + if (pid_sp) +pid = pid_sp->GetValueAsUnsigned(-1); + auto uid_sp = sikill->GetChildMemberWithName("si_uid"); + if (uid_sp) +uid = uid_sp->GetValueAsUnsigned(-1); +} + } else { + +switch (signo) { +case SIGILL: +case SIGFPE: +case SIGBUS: { + auto sigfault = sifields->GetChildMemberWithName("_sigfault"); + if (!sigfault) +break; + + auto addr_sp = sigfault->GetChildMemberWithName("si_addr"); + if (addr_sp) +addr = addr_sp->GetValueAsUnsigned
[Lldb-commits] [lldb] [lldb] Correcting an error message. (PR #141696)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/141696 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7c471e1 - [lldb][NFC] This test is marked expectedfail for macos version
Author: Jason Molenda Date: 2025-05-27T21:50:56-07:00 New Revision: 7c471e12c80f86ba089fb5951ece4d516996d9a1 URL: https://github.com/llvm/llvm-project/commit/7c471e12c80f86ba089fb5951ece4d516996d9a1 DIFF: https://github.com/llvm/llvm-project/commit/7c471e12c80f86ba089fb5951ece4d516996d9a1.diff LOG: [lldb][NFC] This test is marked expectedfail for macos version less-than-14.4. Our CI bot is running macOS 14.1 but I still see FAILs from this text in the CI logs? It may be that the CI is really seeing TestTemplateWithSameArg.py fail and is highlighting this XFAIL test even though it's expected. But I'm not interested enough, I'll try just skipping it altogether on < macOS 14.4. This does mean I'm skipping it on intel where the kernel never had the issue involved. Added: Modified: lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py Removed: diff --git a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py index 199a066f30016..8179d5288ce8e 100644 --- a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py +++ b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py @@ -19,11 +19,8 @@ def get_to_start(self, bkpt_text): return (target, process, thread, frame, read_watchpoint) @add_test_categories(["basic_process"]) -@expectedFailureAll( -macos_version=["<", "14.4"], -archs=["aarch64", "arm$"], -bugnumber="", -) +# kernel disables wp's over instruction step, fixed in macOS 14.4. +@skipIf(macos_version=["<", "14.4"]) def test_step_over_read_watchpoint(self): self.build() target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( @@ -62,11 +59,8 @@ def test_step_over_read_watchpoint(self): self.step_inst_for_watchpoint(1) @add_test_categories(["basic_process"]) -@expectedFailureAll( -macos_version=["<", "14.4"], -archs=["aarch64", "arm$"], -bugnumber="", -) +# kernel disables wp's over instruction step, fixed in macOS 14.4. +@skipIf(macos_version=["<", "14.4"]) def test_step_over_write_watchpoint(self): self.build() target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
@@ -58,6 +59,9 @@ class LLDB_API SBAddress { // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)". lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope); + lldb::SBSymbolContext GetSymbolContext(const SBTarget &target, + uint32_t resolve_scope); eronnen wrote: The `SBAdress::GetLineEntry` is not sufficient because it doesn't apply source maps, so I added a version that can use the target context https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)
https://github.com/akashagrwl updated https://github.com/llvm/llvm-project/pull/141478 >From 72ce442847fe03dd489938eff0eee06c65f53e90 Mon Sep 17 00:00:00 2001 From: Akash Agrawal Date: Mon, 26 May 2025 16:54:21 +0530 Subject: [PATCH 1/3] [LLVM] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files Change-Id: I50d7df02e2dc4f493c46c4044a4e7a4ca7e03355 --- clang/lib/InstallAPI/FileList.cpp | 2 +- compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp | 1 - lldb/source/API/SBInstruction.cpp | 2 +- lldb/source/API/SBPlatform.cpp | 2 +- lldb/source/Core/Telemetry.cpp | 2 +- lldb/source/Interpreter/CommandObject.cpp | 1 - .../DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp | 3 --- .../Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp | 2 -- .../Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp | 1 - lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp | 1 - lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp | 1 - lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 - lldb/source/Target/ScriptedThreadPlan.cpp | 1 - lldb/source/ValueObject/ValueObject.cpp| 1 - lldb/tools/debugserver/source/RNBRemote.cpp| 1 - 15 files changed, 4 insertions(+), 18 deletions(-) diff --git a/clang/lib/InstallAPI/FileList.cpp b/clang/lib/InstallAPI/FileList.cpp index 65610903840af..27e8a2c5b2556 100644 --- a/clang/lib/InstallAPI/FileList.cpp +++ b/clang/lib/InstallAPI/FileList.cpp @@ -7,8 +7,8 @@ //===--===// #include "clang/InstallAPI/FileList.h" + #include "clang/Basic/DiagnosticFrontend.h" -#include "clang/InstallAPI/FileList.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Error.h" #include "llvm/Support/JSON.h" diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp index ca37df348580a..7566d438d60df 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp @@ -13,7 +13,6 @@ #include "sanitizer_flag_parser.h" #include "sanitizer_common.h" -#include "sanitizer_flag_parser.h" #include "sanitizer_flags.h" #include "sanitizer_libc.h" diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 30703eea6fa6c..5d21b92b3607e 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -7,13 +7,13 @@ //===--===// #include "lldb/API/SBInstruction.h" + #include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFile.h" -#include "lldb/API/SBInstruction.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" #include "lldb/Core/Disassembler.h" diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index 394268b77aa21..95d5fa5b14d0e 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -7,13 +7,13 @@ //===--===// #include "lldb/API/SBPlatform.h" + #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBModuleSpec.h" -#include "lldb/API/SBPlatform.h" #include "lldb/API/SBProcessInfoList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBUnixSignals.h" diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index a819d5366cedc..c87581761c45e 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -6,8 +6,8 @@ // //===--===// #include "lldb/Core/Telemetry.h" + #include "lldb/Core/Debugger.h" -#include "lldb/Core/Telemetry.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/UUID.h" diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 72dd546dd6523..129646ebddb94 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -32,7 +32,6 @@ #include "lldb/Target/Language.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandOptionArgumentTable.h" #include "lldb/Interpreter/CommandReturnObject.h" using namespace lldb; diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp index d2bf2586cd82b..
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
@@ -250,14 +252,16 @@ protocol::Source CreateSource(const lldb::SBFileSpec &file); /// Create a "Source" JSON object as described in the debug adapter definition. /// -/// \param[in] line_entry -/// The LLDB line table to use when populating out the "Source" -/// object +/// \param[in] address +/// The address to use when populating out the "Source" object. +/// +/// \param[in] target +/// The target that has the address. /// /// \return /// A "Source" JSON object that follows the formal JSON /// definition outlined by Microsoft. -protocol::Source CreateSource(const lldb::SBLineEntry &line_entry); +protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target); eronnen wrote: the `SBTarget` is not saved there, it's only used in the constructor to parse the load address https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
@@ -252,4 +252,11 @@ std::string GetSBFileSpecPath(const lldb::SBFileSpec &file_spec) { return path; } +lldb::SBLineEntry GetLineEntryForAddress(lldb::SBTarget &target, + lldb::SBAddress &address) { + lldb::SBSymbolContext sc = + address.GetSymbolContext(target, lldb::eSymbolContextLineEntry); + return sc.GetLineEntry(); eronnen wrote: Same reason as above, the current `SBAdress::GetLineEntry` don't apply source maps because it doesn't have the target information https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
@@ -558,28 +558,38 @@ protocol::Source CreateAssemblySource(const lldb::SBTarget &target, return source; } -bool ShouldDisplayAssemblySource( -const lldb::SBLineEntry &line_entry, -lldb::StopDisassemblyType stop_disassembly_display) { - if (stop_disassembly_display == lldb::eStopDisassemblyTypeNever) -return false; - - if (stop_disassembly_display == lldb::eStopDisassemblyTypeAlways) -return true; - - // A line entry of 0 indicates the line is compiler generated i.e. no source - // file is associated with the frame. - auto file_spec = line_entry.GetFileSpec(); - if (!file_spec.IsValid() || line_entry.GetLine() == 0 || - line_entry.GetLine() == LLDB_INVALID_LINE_NUMBER) -return true; +protocol::Source CreateSource(const lldb::SBFileSpec &file) { + protocol::Source source; + if (file.IsValid()) { +const char *name = file.GetFilename(); +if (name) + source.name = name; +char path[PATH_MAX] = ""; +if (file.GetPath(path, sizeof(path)) && +lldb::SBFileSpec::ResolvePath(path, path, PATH_MAX)) + source.path = path; + } + return source; +} - if (stop_disassembly_display == lldb::eStopDisassemblyTypeNoSource && - !file_spec.Exists()) { -return true; +protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target) { + lldb::SBDebugger debugger = target.GetDebugger(); + lldb::StopDisassemblyType stop_disassembly_display = + GetStopDisassemblyDisplay(debugger); + if (!ShouldDisplayAssemblySource(address, stop_disassembly_display)) { +lldb::SBLineEntry line_entry = GetLineEntryForAddress(target, address); +return CreateSource(line_entry.GetFileSpec()); } - return false; + return CreateAssemblySource(target, address); +} + +protocol::Source CreateSource(llvm::StringRef source_path) { + protocol::Source source; + llvm::StringRef name = llvm::sys::path::filename(source_path); + source.name = name; + source.path = source_path; + return source; eronnen wrote: :100: https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
@@ -317,6 +317,8 @@ struct Source { std::optional presentationHint; // unsupported keys: origin, sources, adapterData, checksums + + bool IsAssemblySource() const { return sourceReference.value_or(0) != 0; } eronnen wrote: :100: https://github.com/llvm/llvm-project/pull/141426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits