[Lldb-commits] [lldb] [lldb] Prefer exact address match when looking up symbol by address (PR #172055)

Augusto Noronha via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 12 11:57:25 PST 2025


================
@@ -494,17 +494,20 @@ uint32_t Module::ResolveSymbolContextForAddress(
         !(resolved_flags & eSymbolContextSymbol)) {
       Symtab *symtab = symfile->GetSymtab();
       if (symtab && so_addr.IsSectionOffset()) {
-        Symbol *matching_symbol = nullptr;
-
-        symtab->ForEachSymbolContainingFileAddress(
-            so_addr.GetFileAddress(),
-            [&matching_symbol](Symbol *symbol) -> bool {
-              if (symbol->GetType() != eSymbolTypeInvalid) {
-                matching_symbol = symbol;
-                return false; // Stop iterating
-              }
-              return true; // Keep iterating
-            });
+        addr_t file_address = so_addr.GetFileAddress();
+        Symbol *matching_symbol = symtab->FindSymbolAtFileAddress(file_address);
+
+        if (!matching_symbol ||
----------------
augusto2112 wrote:

I agree that this is the wrong default. I can attempt to change this in a followup NFC patch, if it doesn't break too many things (which I assume it won't).

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


More information about the lldb-commits mailing list