From: Jan Vrany Date: Mon, 17 Nov 2025 10:15:28 +0000 (+0000) Subject: gdb: simplify find_symbol_at_address X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86f6485002db6f243907a89c8d97b26ce30194d9;p=thirdparty%2Fbinutils-gdb.git gdb: simplify find_symbol_at_address 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 --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7a2564c20a4..961cf430e0b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 2634e8fe5c2..90bcce2348e 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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;