Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Getting Debug Information from a binary

Getting Debug Information from a binary

In our code we extract the debug information from the binaries( .so files) that are built using debug mode and store this information in a separate file. This is required because we strip all debug information from the binaries and then ship them to the customer along with the extraction debug information files .

Incase any failure occurrs ,our application will read the debug information from the stored/extracted file and give proper trace information to the user ( with source , line number where error occured etc debug information).

We are working on HP Itanium and we have code in Solaris and Linux which does the extraction of the debug information. But Solaris and Linux supports ELF STAB format while HP Itanium supports DWARF2 format. Basically we need to extract informations like function name , src file names . source code of functions/sybols , size of function, start offset in exe, 1st function in source file, last function in src file, etc(the information in STAB in Solaris) using the DWARF2 format.

In short this is more or less similar to a debugger code .


Is there any open source code or any API which we can re-use to attain this in HP Itanium ( DWARF2 reader )?
2 REPLIES
Acclaimed Contributor [Founder]

Re: Getting Debug Information from a binary

By default there is no debug info in load modules, +objdebug, it is left in the object files.
You would have to use +noobjdebug.

>we need to extract info like function name, src filenames. size of function, start offset in exe,

This info is already in the minimal line table and you don't need -g to include it.


Highlighted
Occasional Visitor

Re: Getting Debug Information from a binary

You could look into open source HP-WDB debugger.
It reads DWARF2 debugging information from binary.
You can download WDB and its source files from www.hp.com/go/wdb
The code that does this stuff is in file dwarf2read.c.
Hope this helps you.