https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/144119
>From 3e2d743ecec705e2ab6bc2d09a2d45acd1ec5e86 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Thu, 12 Jun 2025 13:57:50 -0700 Subject: [PATCH 1/8] Expose SBModule iterator for all separate debug info modules, and implement in each symbol file --- lldb/include/lldb/API/SBModule.h | 8 ++++++ lldb/include/lldb/Core/Module.h | 2 ++ lldb/include/lldb/Symbol/SymbolFile.h | 14 ++++++++++ lldb/source/API/SBModule.cpp | 5 ++++ lldb/source/Core/Module.cpp | 8 ++++++ .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 26 +++++++++++++++++++ .../SymbolFile/DWARF/SymbolFileDWARF.h | 2 ++ .../DWARF/SymbolFileDWARFDebugMap.cpp | 14 ++++++++++ .../DWARF/SymbolFileDWARFDebugMap.h | 2 ++ lldb/source/Symbol/SymbolFile.cpp | 1 - 10 files changed, 81 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 4009ca1461e51..9577bb57005ec 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -287,6 +287,14 @@ class LLDB_API SBModule { /// A const reference to the file specification object. lldb::SBFileSpec GetSymbolFileSpec() const; + /// Get a list of filespecs associated with all the separate symbol files + /// associated with this module. + /// + /// \return + /// A list of filespecs associated with all the separate symbol files + /// associated with this module. + lldb::SBFileSpecList GetSeparateDebugInfoFiles(); + lldb::SBAddress GetObjectFileHeaderAddress() const; lldb::SBAddress GetObjectFileEntryPointAddress() const; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index f1c8ce51027f5..3277edae07a9a 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -475,6 +475,8 @@ class Module : public std::enable_shared_from_this<Module>, } const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; } + + const llvm::StringMap<FileSpec> GetSeparateDebugInfoFiles(); void PreloadSymbols(); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 6b53ba8b6acce..1480461eb3dbf 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -28,6 +28,7 @@ #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Support/Errc.h" #include <mutex> @@ -504,6 +505,19 @@ class SymbolFile : public PluginInterface { /// A DWOStats struct with loaded, total, and error counts for DWO files. virtual DWOStats GetDwoStats() { return {}; } + /// Return a map of separate debug info files that are loaded. + /// + /// Unlike GetSeparateDebugInfo(), this function will only return the list of + /// files, if there are errors they are simply ignored. This function will + /// always return a valid list, even if it is empty. + /// + /// \return + /// A unique map of all the filespecs, dwos in a dwps would be joined to the dwp path + /// for example. + virtual llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() { + return {}; + } + virtual lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional<uint64_t> byte_size, SymbolContextScope *context, diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index ac80be62e1148..dd3ef89f3e244 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -640,6 +640,11 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { return sb_file_spec; } +lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { + lldb::SBFileSpecList sb_filespeclist; + +} + lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 709b78f62062a..7b64f3e51eb99 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1663,3 +1663,11 @@ DataFileCache *Module::GetIndexCache() { .GetPath()); return g_data_file_cache; } + +const llvm::StringMap<lldb_private::FileSpec> Module::GetSeparateDebugInfoFiles() { + SymbolFile *symfile = GetSymbolFile(false); + if (!symfile) + return {}; + + return symfile->GetSeparateDebugInfoFiles(); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 3b22cfcec633d..cd4bf0add7f7b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4375,6 +4375,32 @@ void SymbolFileDWARF::DumpClangAST(Stream &s, llvm::StringRef filter, clang->Dump(s.AsRawOstream(), filter, show_color); } +llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARF::GetSeparateDebugInfoFiles() { + DWARFDebugInfo &info = DebugInfo(); + const size_t num_cus = info.GetNumUnits(); + llvm::StringMap<lldb_private::FileSpec> symbolfile_map; + for (uint32_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) { + DWARFUnit *unit = info.GetUnitAtIndex(cu_idx); + DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(unit); + if (dwarf_cu == nullptr) + continue; + + if (!dwarf_cu->GetDWOId().has_value()) + continue; + + + SymbolFile *dwo_symfile = dwarf_cu->GetDwoSymbolFile(); + if (!dwo_symfile) + continue; + + lldb_private::FileSpec symfile_spec = dwo_symfile->GetObjectFile()->GetFileSpec(); + if (symbolfile_map.find(symfile_spec.GetPath()) == symbolfile_map.end()) + symbolfile_map[symfile_spec.GetPath()] = symfile_spec; + } + return symbolfile_map; +} + + bool SymbolFileDWARF::GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 09dc8da9b7260..ab68b9c7a67ef 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -280,6 +280,8 @@ class SymbolFileDWARF : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_colors) override; + llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() override; + /// List separate dwo files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info = false) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index eb80b7ed45d7b..a1eec25738644 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1289,6 +1289,20 @@ void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s, llvm::StringRef filter, }); } +llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { + const uint32_t cu_count = GetNumCompileUnits(); + llvm::StringMap<lldb_private::FileSpec> cu_map; + for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) { + const auto &info = m_compile_unit_infos[cu_idx]; + if (info.so_file.GetPath().empty()) + continue; + + if (cu_map.find(info.oso_path) == cu_map.end()) + cu_map[info.oso_path] = info.so_file;; + } + return cu_map; +} + bool SymbolFileDWARFDebugMap::GetSeparateDebugInfo( lldb_private::StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 74b97f610f29c..9872af9788f79 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -132,6 +132,8 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_color) override; + llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() override; + /// List separate oso files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info = false) override; diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 0ef139b1d453a..3f41b6803ac62 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -21,7 +21,6 @@ #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" - #include <future> using namespace lldb_private; >From ab351a8d249ef09eeba47b5b37650c7922075531 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Thu, 12 Jun 2025 15:11:17 -0700 Subject: [PATCH 2/8] Add new test, and add swig extension to make writing the test easier --- lldb/source/API/SBModule.cpp | 10 ++++- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 - .../sbmodule/SeperateDebugInfo/Makefile | 3 ++ .../TestSBModuleSeparateDebugInfo.py | 43 +++++++++++++++++++ .../sbmodule/SeperateDebugInfo/main.cpp | 5 +++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/sbmodule/SeperateDebugInfo/Makefile create mode 100644 lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py create mode 100644 lldb/test/API/python_api/sbmodule/SeperateDebugInfo/main.cpp diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index dd3ef89f3e244..24261d05d8fb4 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -642,7 +642,15 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { lldb::SBFileSpecList sb_filespeclist; - + ModuleSP module_sp(GetSP()); + if (module_sp) { + llvm::StringMap<lldb_private::FileSpec> debug_info_files = module_sp->GetSeparateDebugInfoFiles(); + for (auto &&[_, debug_info_file] : debug_info_files) { + sb_filespeclist.Append(debug_info_file); + } + } + + return sb_filespeclist; } lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index cd4bf0add7f7b..3dca32d9c0f50 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4388,7 +4388,6 @@ llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARF::GetSeparateDebugInfoFil if (!dwarf_cu->GetDWOId().has_value()) continue; - SymbolFile *dwo_symfile = dwarf_cu->GetDwoSymbolFile(); if (!dwo_symfile) continue; diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/Makefile b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py new file mode 100644 index 0000000000000..4aafcd4c166d8 --- /dev/null +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py @@ -0,0 +1,43 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +import os, signal, subprocess + +from lldbsuite.test import lldbutil + + +class SBModuleSeparateDebugInfoCase(TestBase): + def setUp(self): + TestBase.setUp(self) + self.background_pid = None + + def tearDown(self): + TestBase.tearDown(self) + if self.background_pid: + os.kill(self.background_pid, signal.SIGKILL) + + @skipIf(debug_info=no_match("dwo")) + def test_get_separate_debug_info_files_dwo(self): + """Test the SBModule::GetSeparateDebugInfoFiles""" + self.build() + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + + # Target should have a DWO + main_module = target.GetModuleAtIndex(0) + file_specs = main_module.GetSeparateDebugInfoFiles() + self.assertEqual(len(file_specs), 1) + self.assertTrue(file_specs[0].GetFilename().endswith(".dwo")) + + @skipIf(debug_info=no_match("oso")) + def test_get_separate_debug_info_files_oso(self): + """Test the SBModule::GetSeparateDebugInfoFiles""" + self.build() + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + + # Target should have a DWO + main_module = target.GetModuleAtIndex(0) + file_specs = main_module.GetSeparateDebugInfoFiles() + self.assertEqual(len(file_specs), 1) + self.assertTrue(file_specs[0].GetFilename().endswith(".a")) diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/main.cpp b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/main.cpp new file mode 100644 index 0000000000000..f54a8087e1dc4 --- /dev/null +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/main.cpp @@ -0,0 +1,5 @@ +int main() { + int x = 40; + x += 2; // break here + return x; +} >From 7d5e4d6c45a6700a367dde245e541605ab88adfa Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Thu, 12 Jun 2025 15:12:21 -0700 Subject: [PATCH 3/8] run GCF --- lldb/include/lldb/Core/Module.h | 2 +- lldb/include/lldb/Symbol/SymbolFile.h | 4 ++-- lldb/source/API/SBModule.cpp | 5 +++-- lldb/source/Core/Module.cpp | 3 ++- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 7 ++++--- .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 6 ++++-- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 3277edae07a9a..7c0f5b2a966e5 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -475,7 +475,7 @@ class Module : public std::enable_shared_from_this<Module>, } const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; } - + const llvm::StringMap<FileSpec> GetSeparateDebugInfoFiles(); void PreloadSymbols(); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 1480461eb3dbf..8ec069b403fdf 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -512,8 +512,8 @@ class SymbolFile : public PluginInterface { /// always return a valid list, even if it is empty. /// /// \return - /// A unique map of all the filespecs, dwos in a dwps would be joined to the dwp path - /// for example. + /// A unique map of all the filespecs, dwos in a dwps would be joined to + /// the dwp path for example. virtual llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() { return {}; } diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 24261d05d8fb4..4e37a01d52509 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -640,11 +640,12 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { return sb_file_spec; } -lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { +lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { lldb::SBFileSpecList sb_filespeclist; ModuleSP module_sp(GetSP()); if (module_sp) { - llvm::StringMap<lldb_private::FileSpec> debug_info_files = module_sp->GetSeparateDebugInfoFiles(); + llvm::StringMap<lldb_private::FileSpec> debug_info_files = + module_sp->GetSeparateDebugInfoFiles(); for (auto &&[_, debug_info_file] : debug_info_files) { sb_filespeclist.Append(debug_info_file); } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 7b64f3e51eb99..6a714b3d7938a 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1664,7 +1664,8 @@ DataFileCache *Module::GetIndexCache() { return g_data_file_cache; } -const llvm::StringMap<lldb_private::FileSpec> Module::GetSeparateDebugInfoFiles() { +const llvm::StringMap<lldb_private::FileSpec> +Module::GetSeparateDebugInfoFiles() { SymbolFile *symfile = GetSymbolFile(false); if (!symfile) return {}; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 3dca32d9c0f50..4b62c254ce364 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4375,7 +4375,8 @@ void SymbolFileDWARF::DumpClangAST(Stream &s, llvm::StringRef filter, clang->Dump(s.AsRawOstream(), filter, show_color); } -llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARF::GetSeparateDebugInfoFiles() { +llvm::StringMap<lldb_private::FileSpec> +SymbolFileDWARF::GetSeparateDebugInfoFiles() { DWARFDebugInfo &info = DebugInfo(); const size_t num_cus = info.GetNumUnits(); llvm::StringMap<lldb_private::FileSpec> symbolfile_map; @@ -4392,14 +4393,14 @@ llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARF::GetSeparateDebugInfoFil if (!dwo_symfile) continue; - lldb_private::FileSpec symfile_spec = dwo_symfile->GetObjectFile()->GetFileSpec(); + lldb_private::FileSpec symfile_spec = + dwo_symfile->GetObjectFile()->GetFileSpec(); if (symbolfile_map.find(symfile_spec.GetPath()) == symbolfile_map.end()) symbolfile_map[symfile_spec.GetPath()] = symfile_spec; } return symbolfile_map; } - bool SymbolFileDWARF::GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index a1eec25738644..e9011106eb77c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1289,7 +1289,8 @@ void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s, llvm::StringRef filter, }); } -llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { +llvm::StringMap<lldb_private::FileSpec> +SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { const uint32_t cu_count = GetNumCompileUnits(); llvm::StringMap<lldb_private::FileSpec> cu_map; for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) { @@ -1298,7 +1299,8 @@ llvm::StringMap<lldb_private::FileSpec> SymbolFileDWARFDebugMap::GetSeparateDebu continue; if (cu_map.find(info.oso_path) == cu_map.end()) - cu_map[info.oso_path] = info.so_file;; + cu_map[info.oso_path] = info.so_file; + ; } return cu_map; } >From 2ef0d28a6822dbc77cf4481686664a101693fda8 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Thu, 12 Jun 2025 15:52:19 -0700 Subject: [PATCH 4/8] Change test to dsym --- .../SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py index 4aafcd4c166d8..fc26af71325d7 100644 --- a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py @@ -29,8 +29,8 @@ def test_get_separate_debug_info_files_dwo(self): self.assertEqual(len(file_specs), 1) self.assertTrue(file_specs[0].GetFilename().endswith(".dwo")) - @skipIf(debug_info=no_match("oso")) - def test_get_separate_debug_info_files_oso(self): + @skipIf(debug_info=no_match("dsym")) + def test_get_separate_debug_info_files_dsym(self): """Test the SBModule::GetSeparateDebugInfoFiles""" self.build() exe = self.getBuildArtifact("a.out") >From be038d8d5d99f70a65f0c4b77d583a15956be94f Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Fri, 13 Jun 2025 09:44:26 -0700 Subject: [PATCH 5/8] Use the correct 'oso_path' instead of 'so_file'. --- .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 3 +-- .../SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index e9011106eb77c..0d7d1a13a75ae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1299,8 +1299,7 @@ SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { continue; if (cu_map.find(info.oso_path) == cu_map.end()) - cu_map[info.oso_path] = info.so_file; - ; + cu_map[info.oso_path] = lldb_private::FileSpec(info.oso_path); } return cu_map; } diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py index fc26af71325d7..011928cd0f330 100644 --- a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py @@ -29,8 +29,9 @@ def test_get_separate_debug_info_files_dwo(self): self.assertEqual(len(file_specs), 1) self.assertTrue(file_specs[0].GetFilename().endswith(".dwo")) - @skipIf(debug_info=no_match("dsym")) - def test_get_separate_debug_info_files_dsym(self): + @skipUnlessDarwin + @skipIf(debug_info=no_match("dwarf")) + def test_get_separate_debug_info_files_darwin_dwarf(self): """Test the SBModule::GetSeparateDebugInfoFiles""" self.build() exe = self.getBuildArtifact("a.out") @@ -40,4 +41,4 @@ def test_get_separate_debug_info_files_dsym(self): main_module = target.GetModuleAtIndex(0) file_specs = main_module.GetSeparateDebugInfoFiles() self.assertEqual(len(file_specs), 1) - self.assertTrue(file_specs[0].GetFilename().endswith(".a")) + self.assertTrue(file_specs[0].GetFilename().endswith(".o")) >From 77eb7aee99f1be81396d153ff86fe4b6c84ab323 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Mon, 16 Jun 2025 10:43:03 -0700 Subject: [PATCH 6/8] Switch to filespeclist --- lldb/include/lldb/API/SBFileSpecList.h | 3 +++ lldb/include/lldb/Core/Module.h | 2 +- lldb/include/lldb/Symbol/SymbolFile.h | 7 ++----- lldb/include/lldb/Symbol/SymbolFileOnDemand.h | 4 ++++ lldb/source/API/SBFileSpecList.cpp | 5 +++++ lldb/source/API/SBModule.cpp | 12 +++--------- lldb/source/Core/Module.cpp | 3 +-- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 10 ++++------ .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 2 +- .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 9 ++++----- .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.h | 2 +- 11 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lldb/include/lldb/API/SBFileSpecList.h b/lldb/include/lldb/API/SBFileSpecList.h index 1a654865a3079..e55b2a89bc7a3 100644 --- a/lldb/include/lldb/API/SBFileSpecList.h +++ b/lldb/include/lldb/API/SBFileSpecList.h @@ -40,6 +40,9 @@ class LLDB_API SBFileSpecList { private: friend class SBTarget; + friend class SBModule; + + SBFileSpecList(lldb_private::FileSpecList &&list); const lldb_private::FileSpecList *operator->() const; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 7c0f5b2a966e5..ffbf9be45a445 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -476,7 +476,7 @@ class Module : public std::enable_shared_from_this<Module>, const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; } - const llvm::StringMap<FileSpec> GetSeparateDebugInfoFiles(); + FileSpecList GetSeparateDebugInfoFiles(); void PreloadSymbols(); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 8ec069b403fdf..4131fac478b18 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -512,11 +512,8 @@ class SymbolFile : public PluginInterface { /// always return a valid list, even if it is empty. /// /// \return - /// A unique map of all the filespecs, dwos in a dwps would be joined to - /// the dwp path for example. - virtual llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() { - return {}; - } + /// A unique list of all the filespecs, or an empty list. + virtual lldb_private::FileSpecList GetSeparateDebugInfoFiles() { return {}; } virtual lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h index 6807ae2df8faa..6bcbae31712ca 100644 --- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h +++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h @@ -231,6 +231,10 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile { load_all_debug_info); } + lldb_private::FileSpecList GetSeparateDebugInfoFiles() override { + return m_sym_file_impl->GetSeparateDebugInfoFiles(); + } + lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional<uint64_t> byte_size, SymbolContextScope *context, diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index 74a368a3cabeb..40af7fc81cc83 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -31,6 +31,11 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) { m_opaque_up = clone(rhs.m_opaque_up); } +SBFileSpecList::SBFileSpecList(FileSpecList &&list) + : m_opaque_up(new FileSpecList(std::move(list))) { + LLDB_INSTRUMENT_VA(this); +} + SBFileSpecList::~SBFileSpecList() = default; const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 4e37a01d52509..296745c7d9bb8 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -641,17 +641,11 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { } lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { - lldb::SBFileSpecList sb_filespeclist; ModuleSP module_sp(GetSP()); - if (module_sp) { - llvm::StringMap<lldb_private::FileSpec> debug_info_files = - module_sp->GetSeparateDebugInfoFiles(); - for (auto &&[_, debug_info_file] : debug_info_files) { - sb_filespeclist.Append(debug_info_file); - } - } + if (module_sp) + return lldb::SBFileSpecList(module_sp->GetSeparateDebugInfoFiles()); - return sb_filespeclist; + return lldb::SBFileSpecList(); } lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 6a714b3d7938a..482c9fd7a3179 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1664,8 +1664,7 @@ DataFileCache *Module::GetIndexCache() { return g_data_file_cache; } -const llvm::StringMap<lldb_private::FileSpec> -Module::GetSeparateDebugInfoFiles() { +lldb_private::FileSpecList Module::GetSeparateDebugInfoFiles() { SymbolFile *symfile = GetSymbolFile(false); if (!symfile) return {}; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 4b62c254ce364..bf7b4a0adb54a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4375,11 +4375,10 @@ void SymbolFileDWARF::DumpClangAST(Stream &s, llvm::StringRef filter, clang->Dump(s.AsRawOstream(), filter, show_color); } -llvm::StringMap<lldb_private::FileSpec> -SymbolFileDWARF::GetSeparateDebugInfoFiles() { +lldb_private::FileSpecList SymbolFileDWARF::GetSeparateDebugInfoFiles() { DWARFDebugInfo &info = DebugInfo(); const size_t num_cus = info.GetNumUnits(); - llvm::StringMap<lldb_private::FileSpec> symbolfile_map; + lldb_private::FileSpecList spec_list; for (uint32_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) { DWARFUnit *unit = info.GetUnitAtIndex(cu_idx); DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(unit); @@ -4395,10 +4394,9 @@ SymbolFileDWARF::GetSeparateDebugInfoFiles() { lldb_private::FileSpec symfile_spec = dwo_symfile->GetObjectFile()->GetFileSpec(); - if (symbolfile_map.find(symfile_spec.GetPath()) == symbolfile_map.end()) - symbolfile_map[symfile_spec.GetPath()] = symfile_spec; + spec_list.AppendIfUnique(symfile_spec); } - return symbolfile_map; + return spec_list; } bool SymbolFileDWARF::GetSeparateDebugInfo(StructuredData::Dictionary &d, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index ab68b9c7a67ef..21d4ee9092c45 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -280,7 +280,7 @@ class SymbolFileDWARF : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_colors) override; - llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() override; + lldb_private::FileSpecList GetSeparateDebugInfoFiles() override; /// List separate dwo files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 0d7d1a13a75ae..f2b5d34af9e04 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1289,19 +1289,18 @@ void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s, llvm::StringRef filter, }); } -llvm::StringMap<lldb_private::FileSpec> +lldb_private::FileSpecList SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { const uint32_t cu_count = GetNumCompileUnits(); - llvm::StringMap<lldb_private::FileSpec> cu_map; + lldb_private::FileSpecList spec_list; for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) { const auto &info = m_compile_unit_infos[cu_idx]; if (info.so_file.GetPath().empty()) continue; - if (cu_map.find(info.oso_path) == cu_map.end()) - cu_map[info.oso_path] = lldb_private::FileSpec(info.oso_path); + spec_list.AppendIfUnique(lldb_private::FileSpec(info.oso_path)); } - return cu_map; + return spec_list; } bool SymbolFileDWARFDebugMap::GetSeparateDebugInfo( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 9872af9788f79..0928f50341d57 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -132,7 +132,7 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_color) override; - llvm::StringMap<lldb_private::FileSpec> GetSeparateDebugInfoFiles() override; + lldb_private::FileSpecList GetSeparateDebugInfoFiles() override; /// List separate oso files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, >From e2ec3f45a8f47821cd28de4627354e2447d27468 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Mon, 8 Sep 2025 14:30:34 -0700 Subject: [PATCH 7/8] Move to sbmodulespec --- lldb/include/lldb/API/SBFileSpecList.h | 3 --- lldb/include/lldb/API/SBModule.h | 2 +- lldb/include/lldb/API/SBModuleSpec.h | 3 +++ lldb/include/lldb/Core/Module.h | 2 +- lldb/include/lldb/Symbol/SymbolFile.h | 5 +++-- lldb/include/lldb/Symbol/SymbolFileOnDemand.h | 2 +- lldb/source/API/SBFileSpecList.cpp | 5 ----- lldb/source/API/SBModule.cpp | 6 +++--- lldb/source/API/SBModuleSpec.cpp | 5 +++++ lldb/source/Core/Module.cpp | 2 +- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 6 +++--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 2 +- .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 6 +++--- .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h | 2 +- lldb/source/Symbol/SymbolFile.cpp | 1 + .../SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py | 4 ++-- 16 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lldb/include/lldb/API/SBFileSpecList.h b/lldb/include/lldb/API/SBFileSpecList.h index e55b2a89bc7a3..1a654865a3079 100644 --- a/lldb/include/lldb/API/SBFileSpecList.h +++ b/lldb/include/lldb/API/SBFileSpecList.h @@ -40,9 +40,6 @@ class LLDB_API SBFileSpecList { private: friend class SBTarget; - friend class SBModule; - - SBFileSpecList(lldb_private::FileSpecList &&list); const lldb_private::FileSpecList *operator->() const; diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 9577bb57005ec..2917c5cb5564d 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -293,7 +293,7 @@ class LLDB_API SBModule { /// \return /// A list of filespecs associated with all the separate symbol files /// associated with this module. - lldb::SBFileSpecList GetSeparateDebugInfoFiles(); + lldb::SBModuleSpecList GetSeparateDebugInfoFiles(); lldb::SBAddress GetObjectFileHeaderAddress() const; lldb::SBAddress GetObjectFileEntryPointAddress() const; diff --git a/lldb/include/lldb/API/SBModuleSpec.h b/lldb/include/lldb/API/SBModuleSpec.h index 0e7f0f3489596..a1a31c954d9be 100644 --- a/lldb/include/lldb/API/SBModuleSpec.h +++ b/lldb/include/lldb/API/SBModuleSpec.h @@ -135,6 +135,9 @@ class SBModuleSpecList { bool GetDescription(lldb::SBStream &description); private: + friend class SBModule; + + SBModuleSpecList(lldb_private::ModuleSpecList &&module_spec_list); std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_up; }; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index ffbf9be45a445..eb09e8b602da7 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -476,7 +476,7 @@ class Module : public std::enable_shared_from_this<Module>, const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; } - FileSpecList GetSeparateDebugInfoFiles(); + ModuleSpecList GetSeparateDebugInfoFiles(); void PreloadSymbols(); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 4131fac478b18..ae6504c016d7b 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -28,7 +28,6 @@ #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallSet.h" -#include "llvm/ADT/StringMap.h" #include "llvm/Support/Errc.h" #include <mutex> @@ -513,7 +512,9 @@ class SymbolFile : public PluginInterface { /// /// \return /// A unique list of all the filespecs, or an empty list. - virtual lldb_private::FileSpecList GetSeparateDebugInfoFiles() { return {}; } + virtual lldb_private::ModuleSpecList GetSeparateDebugInfoFiles() { + return {}; + } virtual lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h index 6bcbae31712ca..988c6d70c0716 100644 --- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h +++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h @@ -231,7 +231,7 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile { load_all_debug_info); } - lldb_private::FileSpecList GetSeparateDebugInfoFiles() override { + lldb_private::ModuleSpecList GetSeparateDebugInfoFiles() override { return m_sym_file_impl->GetSeparateDebugInfoFiles(); } diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index 40af7fc81cc83..74a368a3cabeb 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -31,11 +31,6 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) { m_opaque_up = clone(rhs.m_opaque_up); } -SBFileSpecList::SBFileSpecList(FileSpecList &&list) - : m_opaque_up(new FileSpecList(std::move(list))) { - LLDB_INSTRUMENT_VA(this); -} - SBFileSpecList::~SBFileSpecList() = default; const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 296745c7d9bb8..f08aee4559e0d 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -640,12 +640,12 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { return sb_file_spec; } -lldb::SBFileSpecList SBModule::GetSeparateDebugInfoFiles() { +lldb::SBModuleSpecList SBModule::GetSeparateDebugInfoFiles() { ModuleSP module_sp(GetSP()); if (module_sp) - return lldb::SBFileSpecList(module_sp->GetSeparateDebugInfoFiles()); + return lldb::SBModuleSpecList(module_sp->GetSeparateDebugInfoFiles()); - return lldb::SBFileSpecList(); + return lldb::SBModuleSpecList(); } lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp index 7e4e82081474f..0c60e1b3d7778 100644 --- a/lldb/source/API/SBModuleSpec.cpp +++ b/lldb/source/API/SBModuleSpec.cpp @@ -196,6 +196,11 @@ SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs) LLDB_INSTRUMENT_VA(this, rhs); } +SBModuleSpecList::SBModuleSpecList(lldb_private::ModuleSpecList &&module_spec) + : m_opaque_up(new ModuleSpecList(std::move(module_spec))) { + LLDB_INSTRUMENT_VA(this); +} + SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { LLDB_INSTRUMENT_VA(this, rhs); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 482c9fd7a3179..b470a5a64cab8 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1664,7 +1664,7 @@ DataFileCache *Module::GetIndexCache() { return g_data_file_cache; } -lldb_private::FileSpecList Module::GetSeparateDebugInfoFiles() { +lldb_private::ModuleSpecList Module::GetSeparateDebugInfoFiles() { SymbolFile *symfile = GetSymbolFile(false); if (!symfile) return {}; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index bf7b4a0adb54a..58598f716ff6e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4375,10 +4375,10 @@ void SymbolFileDWARF::DumpClangAST(Stream &s, llvm::StringRef filter, clang->Dump(s.AsRawOstream(), filter, show_color); } -lldb_private::FileSpecList SymbolFileDWARF::GetSeparateDebugInfoFiles() { +lldb_private::ModuleSpecList SymbolFileDWARF::GetSeparateDebugInfoFiles() { DWARFDebugInfo &info = DebugInfo(); const size_t num_cus = info.GetNumUnits(); - lldb_private::FileSpecList spec_list; + lldb_private::ModuleSpecList spec_list; for (uint32_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) { DWARFUnit *unit = info.GetUnitAtIndex(cu_idx); DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(unit); @@ -4394,7 +4394,7 @@ lldb_private::FileSpecList SymbolFileDWARF::GetSeparateDebugInfoFiles() { lldb_private::FileSpec symfile_spec = dwo_symfile->GetObjectFile()->GetFileSpec(); - spec_list.AppendIfUnique(symfile_spec); + spec_list.Append(symfile_spec); } return spec_list; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 21d4ee9092c45..21a190d1b38f0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -280,7 +280,7 @@ class SymbolFileDWARF : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_colors) override; - lldb_private::FileSpecList GetSeparateDebugInfoFiles() override; + lldb_private::ModuleSpecList GetSeparateDebugInfoFiles() override; /// List separate dwo files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index f2b5d34af9e04..68a8e2623b3b5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1289,16 +1289,16 @@ void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s, llvm::StringRef filter, }); } -lldb_private::FileSpecList +lldb_private::ModuleSpecList SymbolFileDWARFDebugMap::GetSeparateDebugInfoFiles() { const uint32_t cu_count = GetNumCompileUnits(); - lldb_private::FileSpecList spec_list; + lldb_private::ModuleSpecList spec_list; for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) { const auto &info = m_compile_unit_infos[cu_idx]; if (info.so_file.GetPath().empty()) continue; - spec_list.AppendIfUnique(lldb_private::FileSpec(info.oso_path)); + spec_list.Append(lldb_private::FileSpec(info.oso_path)); } return spec_list; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 0928f50341d57..48b80974882b3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -132,7 +132,7 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon { void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_color) override; - lldb_private::FileSpecList GetSeparateDebugInfoFiles() override; + lldb_private::ModuleSpecList GetSeparateDebugInfoFiles() override; /// List separate oso files. bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 3f41b6803ac62..0ef139b1d453a 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -21,6 +21,7 @@ #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" + #include <future> using namespace lldb_private; diff --git a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py index 011928cd0f330..b36bfd009bc2e 100644 --- a/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py +++ b/lldb/test/API/python_api/sbmodule/SeperateDebugInfo/TestSBModuleSeparateDebugInfo.py @@ -27,7 +27,7 @@ def test_get_separate_debug_info_files_dwo(self): main_module = target.GetModuleAtIndex(0) file_specs = main_module.GetSeparateDebugInfoFiles() self.assertEqual(len(file_specs), 1) - self.assertTrue(file_specs[0].GetFilename().endswith(".dwo")) + self.assertTrue(file_specs[0].GetFileSpec().GetFilename().endswith(".dwo")) @skipUnlessDarwin @skipIf(debug_info=no_match("dwarf")) @@ -41,4 +41,4 @@ def test_get_separate_debug_info_files_darwin_dwarf(self): main_module = target.GetModuleAtIndex(0) file_specs = main_module.GetSeparateDebugInfoFiles() self.assertEqual(len(file_specs), 1) - self.assertTrue(file_specs[0].GetFilename().endswith(".o")) + self.assertTrue(file_specs[0].GetFileSpec().GetFilename().endswith(".o")) >From 2c51582509022ce3965519ecaf0b8ae36ef5b772 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Tue, 2 Jun 2026 11:46:46 -0700 Subject: [PATCH 8/8] Fix missing instrumentation in SBModule --- lldb/source/API/SBModule.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index f08aee4559e0d..82634f9d95c8d 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -641,6 +641,7 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { } lldb::SBModuleSpecList SBModule::GetSeparateDebugInfoFiles() { + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) return lldb::SBModuleSpecList(module_sp->GetSeparateDebugInfoFiles()); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
