Durin is a library for reading and writing the Dwarf debugging format.
It supports:
- Reading and writing DWARF 4 and DWARF 5 from ELF and MachO object files.
- Writing DWARF 5 into GNU assembler-compatible assembly files.
- Writing DWARF 5 into object files.
- Split DWARF (
.dwofiles,.dwppackage files, skeleton units).
It provides:
- Cross-platform:
durinsupports both ELF (Linux) and MachO (macOS) object files via theobjectlibrary. - Lazy: you can iterate compilation units without parsing their contents.
Parse only as many debugging information entry (DIE) trees as you iterate
over.
durinalso usesDW_AT_siblingreferences to avoid parsing a DIE's children to find its next sibling where possible.
| Section | Read | Write | DWARF Version |
|---|---|---|---|
.debug_info |
Yes | Yes | 4, 5 |
.debug_abbrev |
Yes | Yes | 4, 5 |
.debug_line |
Yes | Yes | 4, 5 |
.debug_line_str |
Yes | Yes | 5 |
.debug_str |
Yes | Yes | 4, 5 |
.debug_str_offsets |
Yes | Yes | 5 |
.debug_addr |
Yes | Yes | 5 |
.debug_frame |
Yes | Yes | 4, 5 |
.eh_frame |
Yes | Yes | 4, 5 |
.debug_aranges |
Yes | Yes | 4, 5 |
.debug_loclists |
Yes | Yes | 5 |
.debug_rnglists |
Yes | Yes | 5 |
.debug_names |
Yes | Yes | 5 |
.debug_macro |
Yes | Yes | 5 |
.debug_cu_index |
Yes | Yes | 5 |
.debug_tu_index |
Yes | Yes | 5 |
.debug_loc |
Yes | Yes | 4 |
.debug_ranges |
Yes | Yes | 4 |
.debug_pubnames |
Yes | Yes | 4 |
.debug_pubtypes |
Yes | Yes | 4 |
.debug_macinfo |
Yes | Yes | 4 |
.debug_types |
Yes | Yes | 4 |
To install durin as a dependency, run:
$ opam install durinAnd add durin to your project's dune-project or *.opam files.
- Documentation on ocaml.org
- Example programs in
exampledirectory- A simple .debug_info parser
- A simple .debug_line parser
- A dwarfdump clone
- An addr2line clone
- A small utility dwprod to list the compilers
used to create each compilation unit within a shared library or
executable (via
DW_AT_producer). - A dwarf-valiate clone, a program to validate the integrity of some DWARF information and the references between sections and compilation units.
-
Apple Compact Unwinding Format is defined by the LLVM implementation.
-
Vendor extensions from GCC https://sourceware.org/elfutils/DwarfExtensions
Big-endian is unsupported. Both read and write paths assume
little-endian throughout. The Object.Buffer.Read functions are
hardcoded LE, and all dwarf_write primitives are LE-only. This
affects PowerPC 64, s390x, and big-endian MIPS targets. Fixing
this requires coordinated changes: making Object.Buffer.Read
endianness-aware, threading byte order through the encoding
type, and adding _be write variants. All current targets
(x86-64, ARM64 on Linux/macOS) are little-endian so this is
low priority.