]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: lookup minsym using section in find_sal_for_pc_sect
authorSébastien Darche <sdarche@efficios.com>
Mon, 20 Oct 2025 19:07:33 +0000 (15:07 -0400)
committerSébastien Darche <sdarche@efficios.com>
Tue, 28 Oct 2025 13:43:30 +0000 (09:43 -0400)
The find_sal_for_pc_sect function attempts to find the line that is
closest to a pc+section in the available symbols. One of the first thing
the function does is search for a bound minimal symbol corresponding to
that pc. In its original version, the lookup is performed by
lookup_minimal_symbol_by_pc, discarding the section. This is misleading
and may cause issues with overlay debugging if a second minsym with the
same pc (but a different section) can be found -- although this is only
in theory after inspecting the code, as I have no way to test this on a
system supporting overlays.

This should have no observable effects for the end user. One slight
benefit is that we can avoid a section lookup inside
lookup_minimal_symbol_by_pc_section if the caller does provide a
section.

Since the section is already passed as an argument to the function, the
proposed change forwards this section to the minsym lookup section.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I86a16bf397ea7167d3e9c7db79b8d7901fad1a97

gdb/symtab.c

index 2b54d245b86a5ec7342926029ab5351426cb33e2..0ddb25f2879997abe8ab447739c286696a3472a4 100644 (file)
@@ -2965,7 +2965,7 @@ find_sal_for_pc_sect (CORE_ADDR pc, struct obj_section *section, int notcurrent)
    * rather than the stub address.
    *
    * Assumptions being made about the minimal symbol table:
-   *   1. lookup_minimal_symbol_by_pc() will return a trampoline only
+   *   1. lookup_minimal_symbol_by_pc_section() will return a trampoline only
    *      if we're really in the trampoline.s If we're beyond it (say
    *      we're in "foo" in the above example), it'll have a closer
    *      symbol (the "foo" text symbol for example) and will not
@@ -2976,7 +2976,7 @@ find_sal_for_pc_sect (CORE_ADDR pc, struct obj_section *section, int notcurrent)
    *      check for the address being the same, to avoid an
    *      infinite recursion.
    */
-  bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc);
+  bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
   if (msymbol.minsym != NULL)
     if (msymbol.minsym->type () == mst_solib_trampoline)
       {