trailofbits / trailofbits/skills

Enhancement: Extract DWARF spec to queryable JSON

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
612
Avg merge
17h 35m
Merged PRs (30d)
28

Description

Problem

Claude struggles with specific DWARF questions like "What attributes can exist on a DW_TAG_subprogram DIE?" because:

  • The DWARF standard PDFs are too large for context
  • Claude does 8-12 web searches, often reading LLVM/libdwarf source as fallback
  • Even with web search, answers may be incomplete

Proposed Solution

Create a standalone tool that extracts structured DWARF specification data from PDFs into queryable JSON files. This would enable instant, authoritative answers to structural DWARF questions without web search.

Deliverables
  1. JSON Schema Files (data/dwarf{3,4,5}.json)

    • Tag encodings (DW_TAG_* → hex code)
    • Attribute encodings (DW_AT_* → hex code + classes)
    • Tag-attribute mappings (which attributes are valid for each tag, from Appendix A)
    • Operation encodings (DW_OP_* → hex code + operands)
  2. Extraction Script (scripts/extract_dwarf_spec.py)

    • Uses pdftotext to extract text
    • Regex parsing of structured tables in Chapter 7 and Appendix A
  3. Query Script (scripts/query_dwarf.py)

    • CLI interface for lookups
    • Example: python query_dwarf.py DW_TAG_subprogram returns applicable attributes
Example JSON Schema
{
  "version": "5",
  "tags": {
    "DW_TAG_subprogram": {
      "code": "0x2e",
      "applicable_attributes": ["DW_AT_name", "DW_AT_type", "DW_AT_low_pc", ...]
    }
  },
  "attributes": {
    "DW_AT_name": {
      "code": "0x03",
      "classes": ["string"]
    }
  }
}
Complexity Assessment
Data Source Difficulty
Tag codes Ch 7 table Easy - clean regex
Attr codes Ch 7 table Easy - clean regex
Op codes Ch 7 table Easy - clean regex
Tag→Attrs Appendix A Medium - multi-line tables
Size Estimate

~1,500-2,000 lines total (scripts + JSON), compared to 20K+ lines of full markdown extraction. This provides programmatic access to the most-queried structural data.

Success Criteria
  • python query_dwarf.py DW_TAG_subprogram returns correct attribute list
  • JSON files are valid and parseable
  • Skill can answer "What attrs can X have?" without web search

This enhancement complements the lean skill approach by adding structured, queryable spec data rather than prose.

🤖 Generated with Claude Code

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed scripts/extract_dwarf_spec.py and scripts/query_dwarf.py, and inspect pdftotext output from DWARF Chapter 7 and Appendix A. Define the JSON files under data/ for versions 3, 4, and 5, then verify that they parse and that querying DW_TAG_subprogram returns its correct attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, data, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.