]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: simplify find_symbol_at_address
authorJan Vrany <jan.vrany@labware.com>
Mon, 17 Nov 2025 10:15:28 +0000 (10:15 +0000)
committerJan Vrany <jan.vrany@labware.com>
Mon, 17 Nov 2025 10:15:28 +0000 (10:15 +0000)
This commit further simplifies find_symbol_at_address by moving
the special handling in case of -readnow down to readnow_functions.

Running all tests in gdb.rust with and without -readnow shown no
regressions (tested on Debian, x86_64).

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33555
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read.c
gdb/symtab.c

index 7a2564c20a4bd3524568c6195c3bb1c9a6a3cbe8..961cf430e0bdce347115f7f4409ed1e65878013f 100644 (file)
@@ -1560,6 +1560,19 @@ struct readnow_functions : public dwarf2_base_index_functions
       }
     return true;
   }
+
+  struct symbol *find_symbol_by_address (struct objfile *objfile,
+                                        CORE_ADDR address) override
+  {
+    for (compunit_symtab &symtab : objfile->compunits ())
+      {
+       struct symbol *sym = symtab.symbol_at_address (address);
+       if (sym != nullptr)
+         return sym;
+      }
+
+    return nullptr;
+  }
 };
 
 /* See read.h.  */
index 2634e8fe5c2c54ddc4be8823651132c220566f1a..90bcce2348e0eb9749211d981b6de781b8b559f2 100644 (file)
@@ -2841,24 +2841,9 @@ find_symbol_at_address (CORE_ADDR address)
 {
   for (objfile &objfile : current_program_space->objfiles ())
     {
-      /* If this objfile was read with -readnow, then we need to
-        search the symtabs directly.  */
-      if ((objfile.flags & OBJF_READNOW) != 0)
-       {
-         for (compunit_symtab &symtab : objfile.compunits ())
-           {
-             struct symbol *sym
-               = symtab.symbol_at_address (address);
-             if (sym != nullptr)
-               return sym;
-           }
-       }
-      else
-       {
-         struct symbol *sym = objfile.find_symbol_by_address (address);
-         if (sym != nullptr)
-           return sym;
-       }
+      struct symbol *sym = objfile.find_symbol_by_address (address);
+      if (sym != nullptr)
+       return sym;
     }
 
   return NULL;