Linux process access own DWARF debug information?

492 views Asked by At

Is there a simple way for a Linux process to access its own DWARF debug information? I have a process that wants to dump the DWARF information for one specific compilation unit into a log file.

This is to simplify some logistics. I have binary log files that contain raw C structs and I need to use DWARF information to decode these files. I would prefer to include the DWARF data at the start of the log files to make them "stand-alone" instead of having to make it available separately.

1

There are 1 answers

0
chaosless On

read the dwarf info from /proc/self/exe such as ..

objdump --dwarf --full-contents /proc/self/exe

shows the idea .. what you want might then be queryable with existing tools

/proc/self/exe:     file format elf64-x86-64

Contents of the .eh_frame section:
...

if you are wanting to get at the dwarf info yourself then libdwarf has helpful examples .. dwarfexample/simplereader.c