Re: How to map offset address to source code line number?

Jan Kratochvil <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On Tue, 23 Jul 2013 18:52:14 +0200, mmr wrote:
> suppose think that the binary is in release mode. 
> Here is sample crash location.. 
> #0 0x080485b9 in main () 
> 
> how to map this address to line number in the source code.

You can map it by "info line *0x80485b9" but that will not work with the
binary you have above.


You need full debug information - for simplicity let's call it DWARF.
This is normally generated by compiler - for simplicity gcc - when you specify
its -g option:
	gcc -o test test.c -Wall -g

You also need to ensure there is no option -s or that there is no "strip"
command applied afterwards.


If you ask where to get line number information for a binary you got in
GNU/Linux distribution (Fedora, Ubuntu etc.) you need to install separate
debug info package for that package you are debugging - such packages are
called *-debuginfo.rpm in Fedora, exact naming depends on the distro.


"binary is in release mode" may mean many things, difficult to guess that.


Jan Kratochvil
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.