I wrote this
blog post a few years ago on my experience using
libdwarf.
I made it into a ~10K-line debugger and ~2K of those where dedicated to elf and dwarf parsing. I parsed only the parts of the format that I encountered and asserted any time I stumbled upon a part of the standard I hadn't implemented yet. I like working that way because I never spend time on something that won't be immediately useful and I always have a use case to test new code.
If I remember correctly, to find the DWARF info inside the binary you first have to parse the ELF format.
libc6-dev provides the
elf.h file that gives you the definition of structures such as the ELF header
Elf64_Ehdr and Section headers
Elf64_Shdr. I followed
this document to do that. I think starting with ELF parsing is a nice way to ramp up to the parsing of the more intricate DWARF format.
Have fun programming!