Skip to content

Commit cf542ca

Browse files
Eric Hartfordclaude
andcommitted
DWARF debug info, type cycle detection, devlog spec notes
- DWARF Phase 1: DICompileUnit/DIFile/DISubprogram per MIR-codegen'd function, per-instruction !dbg locations from statement and terminator spans, dsymutil integration for macOS .dSYM bundles. LLDB shows With source lines, breakpoints and stepping work. - Type cycle detection: Sema post-collection pass builds value-type dependency graph, DFS detects circular struct/enum definitions, emits rich diagnostic with full loop trace and help suggestions. - Terminator spans: MirBuilder.cur_node tracks current AST node, terminate() automatically populates span from it. - Add docs/devlog.md (lazy type resolution, dependency loop diagnostics, --fork flag spec notes from Zig devlog). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 50a9e86 commit cf542ca

14 files changed

Lines changed: 861 additions & 616 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ out/
1515
*.a
1616
*.so
1717
*.dylib
18+
*.dSYM/
1819

1920
# Editor / OS
2021
.DS_Store

docs/debug.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -424,31 +424,31 @@ show disassembly. This is why step 3 must come before step 5.
424424
425425
### Phase 1
426426
427-
- [ ] Add `llvm-c/DebugInfo.h` to `runtime/llvm_bridge.c`
428-
- [ ] Add `wl_di_*` wrapper functions to bridge
429-
- [ ] Declare bridge functions in `src/Codegen.w`
430-
- [ ] Add debug state fields to `Codegen`
431-
- [ ] Add `Source` for cached offset-to-location lookup
432-
- [ ] Implement `debug_init_module`
433-
- [ ] Add module flags for debug version and DWARF version
434-
- [ ] Implement `debug_finalize_module`, call before verify
435-
- [ ] Add `bb_term_spans` to `MirBody`
436-
- [ ] Thread spans through `MirBody.set_terminator`
437-
- [ ] Thread spans through `MirBuilder.terminate`
438-
- [ ] Populate terminator spans from AST node spans
439-
- [ ] Implement `debug_enter_function`
440-
- [ ] Create `DISubprogram` per user function
441-
- [ ] Attach subprograms with `wl_di_set_subprogram`
442-
- [ ] Implement `debug_set_location` and `debug_clear_location`
443-
- [ ] Set location from `stmt_spans` before each MIR statement
444-
- [ ] Set location from `term_spans` before each MIR terminator
445-
- [ ] Set location for function prologue (param stores, allocas)
446-
- [ ] Clear location for synthetic instructions
447-
- [ ] Verify `examples/hello.w` shows source in LLDB
448-
- [ ] Verify loop/match example steps through source
449-
- [ ] `make build` passes
450-
- [ ] `make fixpoint` passes
451-
- [ ] `./out/bin/with-stage2 check src/main.w` passes
427+
- [x] Add `llvm-c/DebugInfo.h` to `runtime/llvm_bridge.c`
428+
- [x] Add `wl_di_*` wrapper functions to bridge
429+
- [x] Declare bridge functions in `src/Codegen.w`
430+
- [x] Add debug state fields to `Codegen`
431+
- [x] Add `Source` for cached offset-to-location lookup
432+
- [x] Implement `debug_init_module`
433+
- [x] Add module flags for debug version and DWARF version
434+
- [x] Implement `debug_finalize_module`, call before verify
435+
- [x] Add `bb_term_spans` to `MirBody`
436+
- [x] Thread spans through `MirBody.set_terminator`
437+
- [x] Thread spans through `MirBuilder.terminate`
438+
- [x] Populate terminator spans from AST node spans
439+
- [x] Implement `debug_enter_function`
440+
- [x] Create `DISubprogram` per user function
441+
- [x] Attach subprograms with `wl_di_set_subprogram`
442+
- [x] Implement `debug_set_location` and `debug_clear_location`
443+
- [x] Set location from `stmt_spans` before each MIR statement
444+
- [x] Set location from `term_spans` before each MIR terminator
445+
- [x] Set location for function prologue (param stores, allocas)
446+
- [x] Clear location for synthetic instructions
447+
- [x] Verify `examples/hello.w` shows source in LLDB
448+
- [x] Verify loop/match example steps through source
449+
- [x] `make build` passes
450+
- [x] `make fixpoint` passes
451+
- [x] `./out/bin/with-stage2 check src/main.w` passes
452452
453453
### Phase 2
454454
@@ -458,4 +458,4 @@ show disassembly. This is why step 3 must come before step 5.
458458
- [ ] Rich DI types for structs, enums, generics
459459
- [ ] Lexical block scopes
460460
- [ ] Register `DW_LANG` for With
461-
- [ ] dSYM packaging on macOS
461+
- [x] dSYM packaging on macOS

0 commit comments

Comments
 (0)