mcpbeat Sign in

Dwarf Expert Agent Skill

Analyzes DWARF debug information in compiled binaries. Use when inspecting .debug_* sections, DIE trees, or DW_TAG_/DW_AT_ entries with dwarfdump/llvm-dwarfdump or readelf, verifying debug info with llvm-dwarfdump --verify, answering DWARF standard questions, or writing code that parses DWARF (libdwarf, pyelftools, gimli).

2k tokens
context cost
the whole folder, loaded on every use
3
files
instructions only
0
copies elsewhere
how many repositories repackaged it
6417
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/trailofbits/skills --skill dwarf-expert

The instruction itself

7 sections, as written by the author

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".

  • LLVMllvm/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 --name when 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; --lookup for addresses.
  • Attribute or type queries (e.g. all parameters of type float *): dump and

filter. grep -B pulls 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

(--lookup takes a program address, not a DIE offset).

  • Multi-attribute or structural queries: when grep pipelines turn brittle,

write a Python script using pyelftools instead.

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; --quiet for 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) or DW_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; walk DW_AT_type links to

reach the base type.

Other skills for the same job

different authors, same section of the catalogue
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Codex
by softaworks
×2

Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing. Uses GPT-5.2 by default for state-of-the-art software engineering.

2k tokens
Memory Safety Patterns
by ComeOnOliver
×2

Implement memory-safe programming with RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code, managing resources, or preventing memory bugs.

6k tokens
Pysam
by K-Dense-AI
×1

Python/HTSlib workflows for genomic files. Use when reading, querying, filtering, or writing SAM/BAM/CRAM, VCF/BCF, FASTA/FASTQ, or tabix data with pysam, including pileup, coverage, indexing, and CRAM references.

34k tokens scripts
Scientific Critical Thinking
by K-Dense-AI
×1

Evaluate scientific claims and evidence quality. Use for assessing experimental design validity, identifying biases and confounders, applying evidence grading frameworks (GRADE, Cochrane Risk of Bias), or teaching critical analysis. Best for understanding evidence quality, identifying flaws. For formal peer review writing use peer-review.

26k tokens
Gh Fix CI
by openai
vendor ×1

Use when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft a fix plan, and implement only after explicit approval. Treat external providers (for example Buildkite) as out of scope and report only the details URL.

8k tokens scripts
Declarative Agent Developer
by microsoft
vendor ×1

> Create, build, deploy, and localize declarative agents for M365 Copilot and Teams. USE THIS SKILL for ANY task involving a declarative agent — including localization, scaffolding, editing manifests, adding capabilities, and deploying. Localization requires tokenized manifests and language files that only this skill knows how to produce. "scaffold an agent", "new agent project", "add a capability", "add a plugin", "configure my agent", "deploy my agent", "fix my agent manifest", "edit my agent", "localize my agent", "add localization", "translate my agent", "multi-language agent", "add an API plugin", "add an MCP plugin", "add OAuth to my plugin", "review instructions", "improve instructions", "fix my instructions"

66k tokens
Documentation
by lingxling
×1

Documentation generation workflow covering API docs, architecture docs, README files, code comments, and technical writing.

1k tokens

How to use it

Copy the folder

Take trailofbits/dwarf-expert from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.