关于
This skill analyzes DWARF debug information in binaries, helping developers inspect debug sections, verify integrity with tools like llvm-dwarfdump, and answer DWARF standard questions. It assists with parsing DIE trees, understanding DW_TAG/DW_AT entries, and writing code that consumes DWARF data using libraries like libdwarf or pyelftools. Use it when working with debug information formats rather than for runtime debugging or broader reverse engineering.
快速安装
Claude Code
推荐npx skills add trailofbits/skills -a claude-code/plugin add https://github.com/trailofbits/skillsgit clone https://github.com/trailofbits/skills.git ~/.claude/skills/dwarf-expert在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
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.
GitHub 仓库
常见问题
什么是 dwarf-expert Skill?
dwarf-expert 是一个 Claude Skill,作者为 trailofbits。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 dwarf-expert 相关的任务。
如何安装 dwarf-expert?
使用本页的安装命令:将 dwarf-expert 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。
dwarf-expert 属于哪个分类?
dwarf-expert 属于测试分类。
dwarf-expert 可以免费使用吗?
可以。dwarf-expert 已收录在 AIMCP,可免费安装。
相关推荐技能
该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
这个Claude Skill提供了关于Cloudflare Cron Triggers的完整知识库,用于通过cron表达式定时执行Workers。它支持配置周期性任务、维护作业和自动化工作流,并能处理常见的cron触发错误。开发者可以用它来设置定时任务、测试cron处理器,并集成Workflows和Green Compute功能。
该Skill为开发者提供了基于Playwright的本地Web应用测试工具集,支持自动化测试前端功能、调试UI行为、捕获屏幕截图和查看浏览器日志。它包含管理服务器生命周期的辅助脚本,可直接作为黑盒工具运行而无需阅读源码。适用于需要快速验证本地Web应用界面和交互功能的开发场景。
这个Skill用于开发分支完成后的集成决策,当代码实现完成且测试通过时,它会引导开发者选择合适的工作流。它首先验证测试状态,然后提供合并、创建PR或清理等结构化选项。核心价值在于确保代码质量的同时,标准化分支收尾流程。
