Re: Incorrect symbol name displayed in backtrace

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2020-02-05 11:36 p.m., William Tambe wrote:
> Below is an example of backtrace where I find that GDB printed a
> symbol name that is not found at the address shown in the backtrace.
> In the example below, GDB says that  __kprobes_text_start() is at
> 0x0039f000, however when I used p (void *)0x0039f000, it prints the
> correct symbol name at 0x0039f000.
> 
> (gdb) bt
> #0  0x05000100 in _start ()
> #1  0x0039f000 in __kprobes_text_start ()
> Backtrace stopped: frame did not save the PC
> (gdb) p (void *)0x0039f000
> $6 = (void *) 0x39f000 <__tramp_exit>
> 
> 
> Any idea what is the difference in the way symbol names are printed in
> the backtrace and by the command "p" ?

The only reason I could imagine is that for the backtrace, GDB looks for
the closest code symbol, whereas with the print command, it looks for
any kind of symbol.  And perhaps that in this case, __kprobes_text_start
is a code symbol whereas __tramp_exit is a data symbol.

Note that when GDB says:

#1  0x0039f000 in __kprobes_text_start ()

It doesn't mean that __kprobes_text_start == 0x0039f000, it's just that for
all it knows, the current address (0x0039f000) is in the function
__kprobes_text_start.  What does "print __kprobes_text_start" say?

It's hard to tell without seeing the actual binary, so this is just a guess.

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.