This is the mail archive of the
mailing list for the GDB project.
Re: finding a function with address
- To: "J.T. Conklin" <jtc at redback dot com>
- Subject: Re: finding a function with address
- From: Eli Zaretskii <eliz at is dot elta dot co dot il>
- Date: Mon, 5 Feb 2001 11:30:02 +0200 (IST)
- cc: gdb at sources dot redhat dot com
On 1 Feb 2001, J.T. Conklin wrote:
> GDB should be able to determine the name of the function if it has a
> symbol for that address.
This reminds my one of my gripes with GDB. Observe:
C:\bin\gcc\gnu\emacs\src> gdb ../bin/emacs.exe
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-pc-msdosdjgpp"...
(gdb) help info symbol
Describe what symbol is at location ADDR.
Only for symbols with fixed locations (global or static scope).
(gdb) info address Qnil
Symbol "Qnil" is static storage at address 0x1d6cd8.
(gdb) info symbol 0x1d6cd8
No symbol matches 0x1d6cd8.
(gdb) info address command_loop
Symbol "command_loop" is a function at address 0x4b940
(gdb) info symbol 0x4b940
No symbol matches 0x4b940.
In other words, there doesn't seem to be a way of getting a symbol
name given its address, unlike "info symbol" promised?
Am I using GDB incorrectly? Is this a bug in GDB or in its DJGPP
Here's a relevant story from the trenches: I needed the help of `info
symbol' badly when I debugged a case of a crash due to stack overflow.
Since the stack was badly smashed, I couldn't even get a decent stack
trace, all I had was two top-most stack frames. So my first goal was
to find out what was the sequence of function calls leading to the
stack overflow. However, since some of the .data section was also
overwritten by the overflowing stack, I couldn't trust the program's
data structures. So I decided to walk the stack manually, figuring
out the frames as I go. This required to be able to find a function
given a return address pushed onto the stack when it called another
function. Due to the above problems, I ended up using tricks like
`disassemble ADDRESS' and `list *ADDRESS'. If I needed to do the same
for variables, I had to use `info address' in conjunction with
guessing and binary search...
As an aside, "info symbol" doesn't seem to be documented in the manual