[Lldb-commits] [lldb] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 30 03:11:39 PDT 2025


================
@@ -771,6 +774,81 @@ class LoadAddressResolver {
   lldb::addr_t m_best_internal_load_address = LLDB_INVALID_ADDRESS;
 };
 
+/// Find a module by LLDB-specific unique identifier.
+///
+/// \param[in] uid The UID of the module assigned to it on construction.
+///
+/// \returns ModuleSP of module with \c uid. Returns nullptr if no such
+/// module could be found.
+static lldb::ModuleSP FindDebugModule(lldb::user_id_t uid,
+                                      const ModuleList &modules) {
+  lldb::ModuleSP module_sp;
+  modules.ForEach([&](const lldb::ModuleSP &m) {
+    if (m->GetID() == uid) {
+      module_sp = m;
+      return IterationAction::Stop;
+    }
+
+    auto *sym = m->GetSymbolFile();
+    if (!sym)
+      return IterationAction::Continue;
+
+    auto debug_modules = sym->GetDebugInfoModules();
----------------
labath wrote:

The ID of the `.o` file is already encoded in the DIE ID, you should be able to extract it similarly to how it's done in e.g. `SymbolFileDWARFDebugMap::GetDeclContextForUID`.

(That said, these days, that extraction is kind of pointless, because that function will eventually call `SymbolFileDWARF::GetDIERefSymbolFile`, which will repeat the extraction and forward the call to the right SymbolFileDWARF instance.)

https://github.com/llvm/llvm-project/pull/148877


More information about the lldb-commits mailing list