Dwarf Expert
Trail of BitsOfficialPublished by Trail of Bits
- Skill
- Tool integration
- Software development
- CC-BY-SA-4.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The DWARF Expert skill provides specialized knowledge for working with DWARF debug information. It covers techniques for inspecting DIE trees and attributes using tools like llvm-dwarfdump and readelf, verifying the integrity of debug sections, and implementing custom parsers using libraries such as pyelftools, libdwarf, or gimli. The skill emphasizes using authoritative sources like the DWARF standard and reference implementations to resolve complex structural queries or encoding issues.
What it does
- Analyzes DWARF debug sections and DIE trees in compiled binaries.
- Provides command-line strategies for searching and filtering debug information.
- Verifies DWARF structural integrity and generates quality statistics.
- Guides the selection and usage of DWARF parsing libraries across multiple languages.
- Explains how to resolve attribute indirection and type chains in DWARF data.
- Offers best practices for handling platform-specific debug formats like Mach-O dSYM bundles.
When to use it
- When you need to inspect or debug the contents of .debug_* sections.
- When verifying the correctness of DWARF info produced by compilers or binary rewriters.
- When writing custom tools or scripts to extract metadata from compiled binaries.
- When troubleshooting debugger issues related to missing or malformed debug information.
- When you need to understand specific DWARF standard attributes or encoding forms.
Advantages
- Reduces complexity when navigating deep DIE hierarchies and attribute chains.
- Provides clear guidance on tool selection between llvm-dwarfdump and readelf.
- Standardizes the approach to verifying debug info quality across build pipelines.
- Offers reliable patterns for programmatic DWARF access using established libraries.
Usage examples
- “How do I find all formal parameters of type float* in my binary?”
- The agent provides a grep-based pipeline using llvm-dwarfdump to filter for the specific tag and type, then explains how to use the offset to inspect the full DIE structure.
- “My debugger is failing to resolve symbols; how can I check if the DWARF info is valid?”
- The agent instructs you to run llvm-dwarfdump --verify on the binary to identify structural errors, unit chain issues, or invalid address ranges.
- “I need to write a Python script to extract function names from an ELF file. Which library should I use?”
- The agent recommends pyelftools for Python-based parsing and provides a high-level overview of how to navigate DIEs and resolve attribute references.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/trailofbits/dwarf-expert/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip dwarf-expert.zip -d .agents/skills
Documentation by Trail of Bits
DWARF Expert
Expertise for DWARF debug info: parsing and searching it, verifying its integrity, answering questions about the standard, and writing code that consumes it. Out of scope: runtime debugging (use gdb/lldb), reverse engineering beyond the DWARF sections (use Ghidra/IDA), and compiler-specific DWARF generation bugs.
Authoritative Sources
When precision matters, look standard details up instead of answering from memory:
dwarfstd.org — the official specification. Web-search specific sections, e.g. "DWARF5 DW_TAG_subprogram attributes site:dwarfstd.org".
LLVM —
llvm/lib/DebugInfo/DWARF/is a reliable reference implementation:DWARFDie.cpp(DIE and attribute access),DWARFUnit.cpp(compilation units),DWARFDebugLine.cpp(line tables),DWARFVerifier.cpp(validation).libdwarf — the reference C implementation at github.com/davea42/libdwarf-code.
Parsing and Searching with dwarfdump
Prefer dwarfdump over readelf for DWARF-specific work. Two implementations
exist — libdwarf's dwarfdump and LLVM's llvm-dwarfdump — with different
options, and a bare dwarfdump command may be either: check dwarfdump --version
first. The options below are LLVM's.
On macOS, linked Mach-O executables do not carry DWARF: it stays in the .o
files until dsymutil collects it into a .dSYM bundle. Point dwarfdump at
the dSYM (or the object files), not the executable. pyelftools is ELF-only —
for Mach-O scripted work, stay with the LLVM tools.
--all: dump every DWARF section;--debug-info,--debug-line, etc. dump one--show-children [--recurse-depth=<n>]: include child DIEs when printing selected entries — parameters, locals, and struct members are children of function and type DIEs--show-parents [--parent-recurse-depth=<n>]: include parent DIEs--show-form: print attribute form types, for when encoding details matter--find=<name>: exact-name lookup via the accelerator tables — fast but not exhaustive; fall back to--namewhen it misses--name=<pattern> [--ignore-case] [--regex]: exhaustive DIE-name search--lookup=<address>: find the DIE covering an address--verbose: print low-level encoding detail
Searching DIEs
Escalate through these strategies as the query grows more complex:
Name or address match:
--find, then--name;--lookupfor addresses.Attribute or type queries (e.g. all parameters of type
float *): dump and filter.grep -Bpulls in the header line carrying each DIE's offset:llvm-dwarfdump file | grep -B 5 "float \*" | grep DW_TAG_formal_parameter, then print each DIE at its offset with--debug-info=<offset> --show-children(--lookuptakes a program address, not a DIE offset).Multi-attribute or structural queries: when grep pipelines turn brittle, write a Python script using
pyelftoolsinstead.
Verifying DWARF Integrity
llvm-dwarfdump --verify <binary>: structural checks (unit chains, DIE relationships, address ranges).--error-display=<quiet|summary|details|full>controls detail;--verify-json=<path>writes a machine-readable error summary;--quietfor exit-code-only checks.llvm-dwarfdump --statistics <binary>: debug-info quality metrics as JSON — compare across compiler versions or optimization levels to catch regressions.
Verify after producing DWARF (compilers, binary rewriters), when a debugger misbehaves on a binary, and when developing DWARF tooling against known-good files.
When a current-generation compiler emitted an old DWARF version, the build
explicitly passed -gdwarf-N — modern gcc and clang default to v4/v5, so check
the build system rather than assuming a toolchain default. GCC embeds its flags
in DW_AT_producer, so the pin is often readable right there; clang's producer
string carries no flags. Old versions remain common in the wild and read the
same way apart from surface forms: in v2 output, member offsets appear as
location expressions (DW_OP_plus_uconst) and linkage names as
DW_AT_MIPS_linkage_name.
readelf
For general ELF structure, or when dwarfdump is unavailable:
--debug-dump=<section>: dump a DWARF section (info,line, ...)--dwarf-depth=<n>/--dwarf-start=<n>: limit DIE depth / start offset
Writing Code That Parses DWARF
Prefer an existing library over parsing by hand:
| Library | Language | Notes |
|---|---|---|
libdwarf | C/C++ | github.com/davea42/libdwarf-code — low-level; used to implement dwarfdump |
pyelftools | Python | github.com/eliben/pyelftools — also parses ELF in general |
gimli | Rust | github.com/gimli-rs/gimli — pair with object to load container files |
debug/dwarf | Go | standard library |
LibObjectFile | .NET | github.com/xoofx/LibObjectFile — also handles ELF/PE object files |
Default to Python with pyelftools for one-off scripts unless the task dictates
otherwise.
DWARF-specific pitfalls to handle — and to check for when reviewing DWARF code:
Attributes are optional: a DIE may omit
DW_AT_name,DW_AT_type, ranges, etc.Attribute indirection: a DIE's attributes may live on the DIE referenced by its
DW_AT_abstract_origin(inlined instances) orDW_AT_specification(out-of-line definitions) — resolve the chain before concluding data is absent.Type chains: qualifiers and modifiers (
DW_TAG_const_type,DW_TAG_pointer_type, ...) wrap the underlying type; walkDW_AT_typelinks to reach the base type.
Files
- ATTRIBUTION.mdAdded by AutoGineer930 B
- LICENSELicence file added by AutoGineer19.7 KiB
- SKILL.md5.9 KiB
- agents/openai.yaml232 B
- assets/trail-of-bits-mark.svg3.0 KiB
Requirements and compatibility
Written for: Claude Code
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Claude Code frontmatter
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Trail of Bits
- Publisher
- Trail of Bits (Official)
- Source
- trailofbits/skills · plugins/dwarf-expert/skills/dwarf-expert · commit e4dd0bb
- Licence
- Creative Commons Attribution-ShareAlike 4.0 International (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Trail of Bits.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download dwarf-expert.zip