ERR/E3.0 (slice 3d): --emit-obj + macOS lldb stepping verified

`sx build --emit-obj` keeps the DWARF-bearing object so a debugger can
step the binary, completing the deep-debug half of the trace story.

- --emit-obj flag + TargetConfig.emit_obj. Implies -O0 (DWARF only
  emits at opt none/less); keeps the object at its link-time path
  .sx-tmp/main.o so the binary's debug map resolves to it; skips the
  Level-1 binary cache; reports the object path. macOS resolves via the
  debug map -> .o; Linux carries DWARF in the binary. Build-flow only,
  no runtime/codegen change.
- tests/debug_stepping_smoke.sh (3e rung 1; macOS, lldb, not in
  run_examples): builds with --emit-obj, drives an lldb file:line
  breakpoint, asserts resolution + a source-mapped backtrace. Passing —
  proves the slice 1-2 DWARF drives real source-level stepping.

(Also normalizes the 253 .exit trailing newline from the 3c --update.)
Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
agra
2026-06-01 15:55:05 +03:00
parent 178449b548
commit 4cd641c946
5 changed files with 92 additions and 13 deletions

View File

@@ -389,9 +389,12 @@ emit; sx provides the artifacts and a launch convenience, nothing more.
### Artifacts
`sx build --emit-obj` / `--debug` writes the object (+DWARF) to a build
dir and runs `dsymutil` to produce a `.dSYM`, so a debugger can load and
symbolize it. Reuses the existing `emitObject` path.
`sx build --emit-obj` keeps the DWARF-bearing object at its link-time path
(`.sx-tmp/main.o`) instead of deleting it, and implies `-O0` (DWARF only emits
at opt none/less). On **macOS** the linked binary's debug map resolves to that
`.o`, so `lldb`/`gdb` run from the project root can step the binary directly; on
**Linux** the DWARF is in the binary, so the `.o` isn't even needed. A portable
`.dSYM` (via `dsymutil`) is only required for the on-device iOS rung (below).
### The verification ladder
@@ -400,8 +403,9 @@ Source-level stepping is verified manually/interactively (it needs
provisioning profile — not a `run_examples.sh` test). Climb cheapest-first;
the device run is the final sign-off:
1. **macOS native** — `sx build --opt none` → `dsymutil` → drive
`lldb --batch` with a canned script: breakpoint on a sx function,
1. **macOS native** — `sx build --emit-obj` → drive `lldb --batch` (the
debug map resolves to the kept `.o`; no `dsymutil` needed locally).
Checked in as `tests/debug_stepping_smoke.sh`: breakpoint on a sx function,
`run`, assert it stops at the right `.sx:line`, `next`/`stepi` advance,
`bt` is source-mapped. The automatable rung (a checked-in smoke script).
2. **iOS simulator** — bundle the `.app`, install to a booted simulator
@@ -438,8 +442,9 @@ a Mach-O debug map, never register JIT DWARF.
| Niladic trace-push op + interned `Frame` table (runtime) | ✅ done — E3.3 slice 3a (`1b6cbc1`) |
| Comptime resolver (`func_id, ir_offset` → location) | ✅ done — slice 3b |
| Source snippet + `^` caret | ✅ done — slice 3c (line embedded in `Frame`) |
| `--emit-obj` / `--debug` artifact plumbing | ⏳ planned — slice 3d |
| Stepping verification ladder (macOS → sim → device) | ⏳ planned — slice 3e (capstone) |
| `--emit-obj` artifact plumbing | ✅ done — slice 3d |
| Stepping verification: macOS lldb | ✅ done — slice 3e rung 1 (`tests/debug_stepping_smoke.sh`) |
| Stepping verification: iOS simulator → device | ⏳ planned — slice 3e rungs 23 (capstone) |
| DWARF variable info (`DILocalVariable`, for `p x`) | ⏳ optional follow-on |
The active plan and step breakdown live in `current/PLAN-ERR.md`