Skip to content

Commit 788ad7b

Browse files
authored
Initialize Claude (#18)
1 parent ceed619 commit 788ad7b

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

CLAUDE.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
This is **LLVM-oxcaml**, a specialized fork of the LLVM project with modifications to support OCaml debugging capabilities. The primary focus is on enhancing LLDB's ability to debug and display OCaml values intelligently.
8+
9+
## Build System Commands
10+
11+
The project uses CMake with Ninja as the build system. By default, all builds are configured in the `build/` directory.
12+
13+
### Core Build Commands
14+
```bash
15+
# Build everything (project is pre-configured)
16+
ninja -C build
17+
18+
# Build with specific parallel jobs
19+
ninja -C build -j <number>
20+
21+
# Clean build
22+
ninja -C build clean
23+
24+
# Build specific components
25+
ninja -C build clang
26+
ninja -C build llc
27+
ninja -C build opt
28+
ninja -C build lldb
29+
```
30+
31+
### Testing Commands
32+
```bash
33+
# Run all regression tests (primary test command)
34+
ninja -C build check-all
35+
36+
# Component-specific tests
37+
ninja -C build check-llvm # LLVM core tests
38+
ninja -C build check-clang # Clang compiler tests
39+
ninja -C build check-lldb # LLDB debugger tests
40+
```
41+
42+
### Installation
43+
By default, built binaries are available in `_install/` directory. To reinstall:
44+
```bash
45+
ninja -C build install
46+
```
47+
48+
## OCaml Debugging Features
49+
50+
This repository contains OCaml-specific debugging extensions:
51+
52+
### Key Features
53+
54+
1. **OCaml Value Debugging** (`lldb/source/Core/DumpDataExtractor.cpp`)
55+
- New LLDB format: `eFormatOCamlValue` for intelligent value display
56+
- Automatic tag detection and OCaml data structure interpretation
57+
- Support for arrays, records, variants, and lazy values
58+
- Forward pointer resolution for OCaml values
59+
- **Critical implementation detail**: OCaml uses tagged integers encoded as `(value << 1) | 1`. The `FormatOCamlValue` function in `DumpDataExtractor.cpp` handles decoding these values. When modifying this logic, ensure proper signed/unsigned integer handling to correctly interpret the encoded values.
60+
61+
2. **OCaml Type System Integration** (`clang/include/clang/AST/BuiltinTypes.def`)
62+
- New builtin type: `eBasicTypeOCamlValue`
63+
- DWARF support with `DW_LANG_OCaml` language identifier
64+
- TypeSystem integration in LLDB for OCaml type understanding
65+
66+
## Development Guidelines
67+
68+
### Working with OCaml Debugging
69+
- When modifying LLDB, consider OCaml value display in `DumpDataExtractor.cpp`
70+
- OCaml value formatting improvements should handle various OCaml data structures
71+
- Test OCaml debugging features using the built `lldb` binary
72+
73+
### Build Configuration
74+
- LLVM Version: 16.0.6
75+
- Build system: Ninja (faster than make for incremental builds)
76+
- By default, pre-built installation available in `_install/`
77+
78+
### Testing OCaml Value Debugging
79+
When making changes to OCaml value formatting in `DumpDataExtractor.cpp`:
80+
81+
1. **Create test OCaml files** with non-inlined functions to ensure debugger visibility:
82+
```ocaml
83+
let[@local never][@inline never] test_function x = x
84+
```
85+
86+
2. **Compile with debugging flags** (ask user for OCaml compiler path):
87+
```bash
88+
<ocaml-compiler-path> -g -gno-upstream-dwarf -shape-format debugging-shapes -o test file.ml
89+
```
90+
- `-g`: Generate debug information
91+
- `-gno-upstream-dwarf`: Use OCaml-specific DWARF generation
92+
- `-shape-format debugging-shapes`: Include shape debugging information
93+
94+
3. **Test in LLDB**:
95+
```bash
96+
lldb ./test
97+
(lldb) b <function_name>
98+
(lldb) run
99+
(lldb) frame variable # Check parameter display
100+
(lldb) memory read -f ocaml_value -s8 -c1 <address> # Test OCaml formatting
101+
```
102+
103+
4. **Verify comprehensive test cases**: Test various value types (integers, strings, records, arrays) and edge cases to ensure proper encoding/decoding, especially for tagged immediate values.
104+
105+
## Key Files for OCaml Debugging Development
106+
107+
### Core OCaml Debugging Support
108+
- `lldb/source/Core/DumpDataExtractor.cpp` - OCaml value debugging and formatting
109+
- `clang/include/clang/AST/BuiltinTypes.def` - OCaml builtin types
110+
- `lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp` - LLDB type integration
111+
112+
## Repository Structure
113+
This is the standard LLVM monorepo structure with OCaml debugging enhancements primarily in LLDB components. The project includes all major LLVM components (clang, lldb, lld, polly, etc.) with focused improvements for OCaml value debugging and display.

0 commit comments

Comments
 (0)