|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +dwarf2cpp generates C++ headers from DWARF debug information in compiled binaries. It uses pybind11 C++ bindings to access LLVM's DWARF DebugInfo module and reconstructs source headers from debug symbols. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install from source (requires C++ toolchain: MSVC on Windows, GCC on Linux, Apple Clang on macOS) |
| 13 | +pip install . |
| 14 | + |
| 15 | +# Run the tool |
| 16 | +python -m dwarf2cpp <binary> --base-dir <compilation-base-dir> |
| 17 | + |
| 18 | +# Format Python code |
| 19 | +ruff format src/ |
| 20 | + |
| 21 | +# Lint Python code |
| 22 | +ruff check src/ |
| 23 | + |
| 24 | +# Format C++ code |
| 25 | +clang-format -i src/dwarf2cpp/*.cpp src/dwarf2cpp/*.h |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture |
| 29 | + |
| 30 | +### Data Flow |
| 31 | +``` |
| 32 | +Binary File → DWARFContext (C++ pybind11) → Visitor (Python) → Models → Jinja2 Templates → Post-process → .h files |
| 33 | +``` |
| 34 | + |
| 35 | +### Key Modules |
| 36 | + |
| 37 | +- **`src/dwarf2cpp/_dwarf.cpp`** - pybind11 bindings exposing LLVM DWARF types: DWARFContext, DWARFDie, DWARFUnit, DWARFTypePrinter |
| 38 | +- **`src/dwarf2cpp/visitor.py`** - Visitor pattern traversing DWARF DIE tree; ~25 `visit_*` methods for different DWARF tags; converts to Python models |
| 39 | +- **`src/dwarf2cpp/models.py`** - Dataclass-based AST: Namespace, Function, Struct, Class, Union, Enum, TypeDef, Template, etc. |
| 40 | +- **`src/dwarf2cpp/filters.py`** - Jinja2 filters for namespace handling and template rendering |
| 41 | +- **`src/dwarf2cpp/post_process.py`** - Regex-based cleanup (std::__1/std::__ndk1 aliasing, type simplification) |
| 42 | +- **`src/dwarf2cpp/templates/`** - Jinja2 templates for C++ header generation |
| 43 | + |
| 44 | +### Entry Points |
| 45 | +- CLI: `dwarf2cpp.cli:main` (Click-based) |
| 46 | +- Module: `python -m dwarf2cpp` → `__main__.py` → `cli.py` |
| 47 | + |
| 48 | +## Build System |
| 49 | + |
| 50 | +- **Python build**: scikit-build-core with Conan |
| 51 | +- **C++ build**: CMake 3.15+ |
| 52 | +- **Dependencies**: LLVM 19.1.7, pybind11 3.0.1, libxml2 (via Conan) |
| 53 | +- **Compiler settings**: C++17 required (MSVC 193 / GCC 11 / Apple Clang 13) |
| 54 | + |
| 55 | +## Code Style |
| 56 | + |
| 57 | +- Python: Ruff with 120 char line length, import sorting enabled |
| 58 | +- C++: clang-format with LLVM-based style, 99 char column limit |
0 commit comments