dwarves

Gem Version

DWARF parser (only the .debug_info section for now) using parslet and unix utilities.

Source code is avaiable under MIT license at https://github.com/jethrodaniel/dwarves.


What it do

Parses DWARF format, as outputed by the following:

  • readelf --debug-dump=info
  • objdump --dwarf=info
λ ./bin/setup
...
λ readelf --debug-dump=info spec/fixtures/c/build/example.so > spec/fixtures/out.dwarves
λ dwarves -T < spec/fixtures/out.dwarves | head

{
  :compilation_unit_offset => "0x0"@66,
                   :length => "0x112"@89,
             :architecture => "32-bit"@96,
                  :version => "4"@122,
            :abbrev_offset => "0x0"@142,
             :pointer_size => "8"@164,
                     :dies => [
    {
              :depth => "0"@168,
...
λ dwarves < spec/fixtures/out.dwarves | head

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x112 (32-bit)
   Version:       4
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : (indirect string, offset: 0x91): GNU C11 7.4.0 -mtune=generic -march=x86-64 -g -fPIC -fstack-protector-strong
    <10>   DW_AT_language    : 12   (ANSI C99)
...

Future

  • more than just .debug_info section
  • parse object files with rbelftools

Installation

gem install dwarves

Development

λ ls bin/
console  objdump  readelf  setup
λ rake -T
rake build            # Build dwarves-0.1.0.gem into the pkg directory
rake clean            # Remove any temporary products
rake clobber          # Remove any generated files
rake doc              # Generates documentation
rake install          # Build and install dwarves-0.1.0.gem into system gems
rake install:local    # Build and install dwarves-0.1.0.gem into system gems without network access
rake lint             # Runs the linter
rake release[remote]  # Create tag v0.1.0 and build and push dwarves-0.1.0.gem to 'https://rubygems.org'
rake test             # Run tests

A good test for the parser is to parse its own input, since we reconstruct the output when printing.

./bin/readelf | bundle exec ./exe/dwarves | bundle exec ./exe/dwarves

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jethrodaniel/dwarves.

License

The gem is available as open source under the terms of the MIT License.

Resources