`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.
55 lines
1.7 KiB
Bash
Executable File
55 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Debug-stepping smoke (ERR E3.0 slice 3e, rung 1: macOS native).
|
|
#
|
|
# Verifies the DWARF emitted by `sx build --emit-obj` actually drives
|
|
# source-level stepping in lldb — the deep-debug half of the trace story.
|
|
# NOT part of `run_examples.sh` (it needs `lldb`, and is macOS-specific via the
|
|
# debug-map → kept `.o`). Run manually: bash tests/debug_stepping_smoke.sh
|
|
#
|
|
# Exit 0 = lldb resolved a file:line breakpoint + a source-mapped backtrace.
|
|
|
|
set -u
|
|
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
SX="$ROOT_DIR/zig-out/bin/sx"
|
|
TMP="$ROOT_DIR/.sx-tmp"
|
|
SRC="$TMP/dbg_smoke.sx"
|
|
BIN="$TMP/dbg_smoke"
|
|
|
|
if ! command -v lldb >/dev/null 2>&1; then
|
|
echo "SKIP: lldb not found (macOS/Xcode tools required)"
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p "$TMP"
|
|
cat > "$SRC" <<'EOF'
|
|
add :: (a: s32, b: s32) -> s32 {
|
|
c := a + b;
|
|
return c;
|
|
}
|
|
main :: () -> s32 {
|
|
return add(40, 2);
|
|
}
|
|
EOF
|
|
|
|
"$SX" build --emit-obj "$SRC" -o "$BIN" >/dev/null 2>&1 || { echo "FAIL: build"; exit 1; }
|
|
|
|
# Breakpoint on the `return c;` line; expect lldb to resolve it + a backtrace
|
|
# mapping both frames to dbg_smoke.sx.
|
|
out=$(cd "$ROOT_DIR" && lldb --batch \
|
|
-o "breakpoint set --file dbg_smoke.sx --line 3" \
|
|
-o "run" -o "bt" -o "quit" "$BIN" 2>&1)
|
|
|
|
rm -f "$SRC" "$BIN" "$TMP/main.o"
|
|
|
|
fail=0
|
|
echo "$out" | grep -q "dbg_smoke.sx:3" || { echo "FAIL: breakpoint did not resolve to dbg_smoke.sx:3"; fail=1; }
|
|
echo "$out" | grep -q "add at dbg_smoke.sx:3" || { echo "FAIL: stopped frame not source-mapped"; fail=1; }
|
|
echo "$out" | grep -q "main at dbg_smoke.sx:6" || { echo "FAIL: caller frame not source-mapped"; fail=1; }
|
|
|
|
if [[ $fail -eq 0 ]]; then
|
|
echo "ok: lldb stepped sx source (breakpoint + backtrace resolved via DWARF)"
|
|
exit 0
|
|
fi
|
|
echo "--- lldb output ---"; echo "$out"
|
|
exit 1
|