p-x9/swift-dwarf
A Swift library for parsing binary files to obtain DWARF information.
Usage
Basic
DWARF information from binary files can be retrieved via the dwarf property. Import the format-specific adapter that matches the binary type you want to inspect.
import MachOKit
import DWARF
import DWARFMachO
let machO: MachOFile = ...
// string table in `.debug_str` section
let strings = machO.dwarf.strings
// abbreviations tables in `.debug_abbrev` section
let abbreviationSets = machO.dwarf.abbreviationsSets
// compilation units in `.debug_info` section
let compilationUnits = machO.dwarf.compilationUnits
/* ... */import ELFKit
import DWARF
import DWARFELF
let elf: ELFFile = ...
let elfStrings = elf.dwarf.strings
let elfCompilationUnits = elf.dwarf.compilationUnitsDWARFMachOPrintTests.swift provides test cases that generate output similar to dwarfdump. DWARFELFPrintTests.swift provides the same for ELF binaries. Please use these as a reference.
Status
Supported Binary formats
- [x] mach-o
- [x] ELF
Supported DWARF sections
- [x]
.debug_abbrev - [x]
.debug_info - [x]
.debug_line - [x]
.debug_str - [x]
.debug_line_str - [x]
.debug_str_offs - [x]
.debug_addr - [x]
.debug_aranges - [x]
.debug_rnglists - [x]
.debug_loclists - [x]
.debug_names - [ ]
.debug-macro - [ ]
.debug-pubnames - [ ]
.debug-pubtypes - [ ]
.debug-ranges
License
swift-dwarf is released under the MIT License. See LICENSE
Package Metadata
Repository: p-x9/swift-dwarf
Default branch: main
README: README.md