When I build a program with debugging information (gcc -g
), gdb
is able to tell me addresses of local variables inside a function. Thus, the debugging symbols must contain enough information to calculate this (i.e. an offset from ebp
), and since gdb
uses libbfd
to read debugging symbols, I should be able to as well.
However, libbdf
's documentation seems to have nothing on this. Can libbfd
give me this information?
libbfd
will provide access to the ELF file, opening the file, getting access to the contents of the section, but interpreting these contents is not something that libbfd
does, this is something the application would need to do.
Usually, debugging information is encoded using DWARF.
There are libraries for interpreting DWARF however, gdb includes it's own code for parsing DWARF.