Prefer symtab symbol over minsym for function names in non-contiguous blocks
authorKevin Buettner <kevinb@redhat.com>
Thu, 4 Jul 2019 00:32:21 +0000 (17:32 -0700)
committerKevin Buettner <kevinb@redhat.com>
Sat, 27 Jul 2019 20:26:46 +0000 (13:26 -0700)
commit567238c956c4e5530bd143bfae9393c7ae5524cd
treef67329e470e8cbb13d7908bd738bb3c4d4e431b7
parentc89f9f2a528e490733ace16204752e9af945454e
Prefer symtab symbol over minsym for function names in non-contiguous blocks

The discussion on gdb-patches which led to this patch may be found
here:

https://www.sourceware.org/ml/gdb-patches/2019-05/msg00018.html

Here's a brief synopsis/analysis:

Eli Zaretskii, while debugging a Windows emacs executable, found
that functions comprised of more than one (non-contiguous)
address range were not being displayed correctly in a backtrace.  This
is the example that Eli provided:

  (gdb) bt
  #0  0x76a63227 in KERNELBASE!DebugBreak ()
     from C:\Windows\syswow64\KernelBase.dll
  #1  0x012e7b89 in emacs_abort () at w32fns.c:10768
  #2  0x012e1f3b in print_vectorlike.cold () at print.c:1824
  #3  0x011d2dec in print_object (obj=<optimized out>, printcharfun=XIL(0),
      escapeflag=true) at print.c:2150

The function print_vectorlike consists of two address ranges, one of
which contains "cold" code which is expected to not execute very often.
There is a minimal symbol, print_vectorlike.cold.65, which is the address
of the "cold" range.

GDB is prefering this minsym over the the name provided by the
DWARF info due to some really old code in GDB which handles
"certain pathological cases".  This comment reads as follows:

      /* In certain pathological cases, the symtabs give the wrong
 function (when we are in the first function in a file which
 is compiled without debugging symbols, the previous function
 is compiled with debugging symbols, and the "foo.o" symbol
 that is supposed to tell us where the file with debugging
 symbols ends has been truncated by ar because it is longer
 than 15 characters).  This also occurs if the user uses asm()
 to create a function but not stabs for it (in a file compiled
 with -g).

 So look in the minimal symbol tables as well, and if it comes
 up with a larger address for the function use that instead.
 I don't think this can ever cause any problems; there
 shouldn't be any minimal symbols in the middle of a function;
 if this is ever changed many parts of GDB will need to be
 changed (and we'll create a find_pc_minimal_function or some
 such).  */

In an earlier version of this patch, I had left the code for the
pathological case intact, but those who reviwed that patch recommended
removing it.  So that's what I've done - I've removed it.

gdb/ChangeLog:

* stack.c (find_frame_funname): Remove code which preferred
minsym over symtab sym in "certain pathological cases".
gdb/ChangeLog
gdb/stack.c
This page took 0.025684 seconds and 4 git commands to generate.