views:

132

answers:

2

I would like to understand how symbolic debuggers work?. What are debug symbol table and how it facilitates source-level debugging. I am quite oblivious to the behind the scene actions of debuggers..what actually happens when I provide '-g' option to gcc, what gets written to object file and such intricacies. I would be glad if SO community can explain and direct me to sources where I can get more information

+1  A: 

Symbol files are just a list of all the defined global variables and functions, as well as their offsets from the beginning of the module. It also has a list of all structures and describes their fields.

That way, when GDB/WinDbg loads up, it is able to look at EIP (current instruction) and map the address to something like (SomeFunc+0x25). Of course, most symbols also have the line information encoded as well, so it can go a step further and say, "SomeFunc+0x25 is closest to foo.cpp line 57".

Paul Betts
A: 

Check out the DWARF Debugging specification for an in-depth description of all the debugging information generated by gcc and how the debugger makes use of it.

DWARF 3 Debugging Specification

Nathan

related questions