tmcgilchrist/durin

Durin is a library for reading and writing the DWARF debugging format

OCaml

51

182 commits

updated Aug 11, 2026

See the code

README

Durin

Durin is a library for reading and writing the Dwarf debugging format.

It supports:

  • Reading DWARF 4 and 5 from ELF and MachO object files.
  • Writing DWARF 5 into GNU assembler-compatible assembly files.
  • Writing DWARF 4 and 5 into object files.
  • Split DWARF (.dwo files, .dwp package files, skeleton units).

It provides:

  • Cross-platform: durin supports both ELF (Linux) and MachO (macOS) object files via the object library.
  • Lazy: you can iterate compilation units without parsing their contents. Parse only as many debugging information entry (DIE) trees as you iterate over. durin also uses DW_AT_sibling references to avoid parsing a DIE's children to find its next sibling where possible.

Section Support

SectionReadWriteDWARF Version
.debug_infoYesYes4, 5
.debug_abbrevYesYes4, 5
.debug_lineYesYes4, 5
.debug_line_strYesYes5
.debug_strYesYes4, 5
.debug_str_offsetsYesYes5
.debug_addrYesYes5
.debug_frameYesYes4, 5
.eh_frameYesYes4, 5
.debug_arangesYesYes4, 5
.debug_loclistsYesYes5
.debug_rnglistsYesYes5
.debug_namesYesYes5
.debug_macroYesYes5
.debug_cu_indexYesYes5
.debug_tu_indexYesYes5
.debug_locYesYes4
.debug_rangesYesYes4
.debug_pubnamesYesYes4
.debug_pubtypesYesYes4
.debug_macinfoYesYes4
.debug_typesYesYes4

Install

To install durin as a dependency, run:

$ opam install durin

And add durin to your project's dune-project or *.opam files.

Documentation

Resources

Future work / Known limitations

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.

Contributors

tmcgilchrist

181 commits

tmcgilchrist/durin

Durin is a library for reading and writing the DWARF debugging format

OCaml

51

182 commits

updated Aug 11, 2026

See the code

README

Durin

Durin is a library for reading and writing the Dwarf debugging format.

It supports:

  • Reading DWARF 4 and 5 from ELF and MachO object files.
  • Writing DWARF 5 into GNU assembler-compatible assembly files.
  • Writing DWARF 4 and 5 into object files.
  • Split DWARF (.dwo files, .dwp package files, skeleton units).

It provides:

  • Cross-platform: durin supports both ELF (Linux) and MachO (macOS) object files via the object library.
  • Lazy: you can iterate compilation units without parsing their contents. Parse only as many debugging information entry (DIE) trees as you iterate over. durin also uses DW_AT_sibling references to avoid parsing a DIE's children to find its next sibling where possible.

Section Support

SectionReadWriteDWARF Version
.debug_infoYesYes4, 5
.debug_abbrevYesYes4, 5
.debug_lineYesYes4, 5
.debug_line_strYesYes5
.debug_strYesYes4, 5
.debug_str_offsetsYesYes5
.debug_addrYesYes5
.debug_frameYesYes4, 5
.eh_frameYesYes4, 5
.debug_arangesYesYes4, 5
.debug_loclistsYesYes5
.debug_rnglistsYesYes5
.debug_namesYesYes5
.debug_macroYesYes5
.debug_cu_indexYesYes5
.debug_tu_indexYesYes5
.debug_locYesYes4
.debug_rangesYesYes4
.debug_pubnamesYesYes4
.debug_pubtypesYesYes4
.debug_macinfoYesYes4
.debug_typesYesYes4

Install

To install durin as a dependency, run:

$ opam install durin

And add durin to your project's dune-project or *.opam files.

Documentation

Resources

Future work / Known limitations

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.

Contributors

tmcgilchrist

181 commits

Languages

OCaml

99.5%