debugger: debug native programs #42

Closed
opened 2026-10-05 21:07:13 +00:00 by orion · 24 comments
Collaborator

Context

Section 4 describes debugging a native build.

Source

Acceptance criteria

  • A native program can be debugged as section 4 designs it: an editor launches it through torb debug, sets breakpoints on TorbScript lines, steps, and reads variables by their source names with formatted values (steps 4a to 5)

Steps (epic: no ready on this issue)

  • 1. A #line per statement of a debugged lowering, torb build --debug - #405 (PR #408)
  • 2. The layout table and the gdb pretty printers - #469 (PR #471)
  • 3. The lldb formatters - #600 (PR #601)
  • 4a. torb debug launches lldb-dap or gdb --interpreter=dap for a native program and relays DAP; the printer scripts ship in the package; a session in tests/debug-native/ - #720 (landed as PR #723)
  • 4b. Translate the emitted names in variables (s12_count to count) and a session that reads variables - #731 (landed as PR #732)
  • 5. Docs (torb-debug.md, the editor guide) and the VS Code launch for a native program; DEBUGGER.md sections 4, 18 and 20 - #739 (landed as PR #762)

Dependencies

None known.

Moved from the planning lists of the docs; the design record stays the specification.

## Context Section 4 describes debugging a native build. ## Source - [DEBUGGER.md section 20](https://git.torb.dev/torbscript/language/src/commit/393ef2608e4a60b8ff76d8b6b408951b822d887d/docs/design/DEBUGGER.md#L416) ## Acceptance criteria - [x] A native program can be debugged as section 4 designs it: an editor launches it through `torb debug`, sets breakpoints on TorbScript lines, steps, and reads variables by their source names with formatted values (steps 4a to 5) ## Steps (epic: no `ready` on this issue) - [x] 1. A `#line` per statement of a debugged lowering, `torb build --debug` - #405 (PR #408) - [x] 2. The layout table and the gdb pretty printers - #469 (PR #471) - [x] 3. The lldb formatters - #600 (PR #601) - [x] 4a. `torb debug` launches `lldb-dap` or `gdb --interpreter=dap` for a native program and relays DAP; the printer scripts ship in the package; a session in `tests/debug-native/` - #720 (landed as PR #723) - [x] 4b. Translate the emitted names in `variables` (`s12_count` to `count`) and a session that reads variables - #731 (landed as PR #732) - [x] 5. Docs (`torb-debug.md`, the editor guide) and the VS Code launch for a native program; DEBUGGER.md sections 4, 18 and 20 - #739 (landed as PR #762) ## Dependencies None known. _Moved from the planning lists of the docs; the design record stays the specification._
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop). Implements DEBUGGER.md section 20 / section 4 (debugging a native build); the design record is the specification, no collision with CONCEPT "Open Questions". Touches the native back end and debugger; the acceptance criterion is a single line and will need testable slices, plus a platform question for CI, settled in refine. next: refine (queued)

[loop:torbscript] intake: in scope (author orion, label loop). Implements DEBUGGER.md section 20 / section 4 (debugging a native build); the design record is the specification, no collision with CONCEPT "Open Questions". Touches the native back end and debugger; the acceptance criterion is a single line and will need testable slices, plus a platform question for CI, settled in refine. next: refine (queued)
Author
Collaborator

[loop:torbscript] refine: still queued behind the intake order. next: waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z

[loop:torbscript] refine: still queued behind the intake order. next: waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T03:39:59Z

[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T03:39:59Z
Author
Collaborator

[loop:torbscript] decided by the loop: #42 is an epic and gets no ready itself. Section 4 plus the C back end (a #line per block only, Statement ignored by backend/c/body.trb, torb build never lowers for debugging, -g only through the profile's debugInformation) make four steps; each is one PR, the next is filed only when the previous lands:

  • #405 native build: a #line per statement of a debugged lowering, torb build --debug (-O0 -g), DWARF line-table gate (ready)
  • layout table the emitter writes, and the gdb (Python) and lldb (formatter) pretty printers for torb_text, torb_list, torb_map and the program's layouts
  • torb debug launches lldb-dap or gdb --interpreter=dap for a native program, translates s12_count to count in variables; a session in tests/debug/
  • docs (torb-debug.md, editor guide) and the VS Code launch for a native program; DEBUGGER.md sections 4, 18, 20

Why these decisions: the design record fixes the options (section 4 chose gdb/lldb behind DAP, not a second adapter), so no owner question. Adapter choice for step 3: lldb-dap if found, else gdb --interpreter=dap (gdb 14+); the CI gate runs on linux-x64 only and is measured first (is a debugger installed on the runner image; if not, the image gains it in a PR of its own, no runner change). Platform scope: the debugger session test is linux-x64; macOS and Windows are checked by the line-table gate only. Ordering: independent of #403 (task threads) and #39 (evaluate); all three touch DEBUGGER.md sections 18/20, so rebase after whichever lands first. #40 (stdin) is closed and landed.

This epic is waiting on its steps. next: waiting (#405 in implementation)

[loop:torbscript] decided by the loop: #42 is an epic and gets no `ready` itself. Section 4 plus the C back end (a `#line` per block only, `Statement` ignored by `backend/c/body.trb`, `torb build` never lowers for debugging, `-g` only through the profile's `debugInformation`) make four steps; each is one PR, the next is filed only when the previous lands: - [ ] #405 native build: a `#line` per statement of a debugged lowering, `torb build --debug` (`-O0 -g`), DWARF line-table gate (ready) - [ ] layout table the emitter writes, and the gdb (Python) and lldb (formatter) pretty printers for `torb_text`, `torb_list`, `torb_map` and the program's layouts - [ ] `torb debug` launches `lldb-dap` or `gdb --interpreter=dap` for a native program, translates `s12_count` to `count` in `variables`; a session in `tests/debug/` - [ ] docs (`torb-debug.md`, editor guide) and the VS Code launch for a native program; DEBUGGER.md sections 4, 18, 20 Why these decisions: the design record fixes the options (section 4 chose gdb/lldb behind DAP, not a second adapter), so no owner question. Adapter choice for step 3: `lldb-dap` if found, else `gdb --interpreter=dap` (gdb 14+); the CI gate runs on linux-x64 only and is measured first (is a debugger installed on the runner image; if not, the image gains it in a PR of its own, no runner change). Platform scope: the debugger session test is linux-x64; macOS and Windows are checked by the line-table gate only. Ordering: independent of #403 (task threads) and #39 (evaluate); all three touch DEBUGGER.md sections 18/20, so rebase after whichever lands first. #40 (stdin) is closed and landed. This epic is waiting on its steps. next: waiting (#405 in implementation)
Author
Collaborator

[loop:torbscript] refine: split into steps, #405 is ready. Tokens used for this refine: about 90k. next: waiting (epic waits on its steps, #405 first)

[loop:torbscript] refine: split into steps, #405 is ready. Tokens used for this refine: about 90k. next: waiting (epic waits on its steps, #405 first)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261024 until 2026-10-24T09:10:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261024 until 2026-10-24T09:10:00Z
Author
Collaborator

[loop:torbscript] decided by the loop: step 1 (#405) landed on main (PR #408, merge commit 2442b1c45, DEBUGGER.md slice 7 Done, tools/debug-lines.sh present). The epic's remaining list is re-cut: step 2 = layout table the emitter writes plus the gdb (Python) pretty printers (#469); the lldb formatters move to their own step 3 because they reuse the same table and one PR with both would exceed two commits; then torb debug for a native program; then docs and editor launch. Why: the design record fixes the options (section 4), so no owner question; gdb first because its Python API is scriptable in a batch gate, and whether gdb is on the CI runner image is measured in the PR, not asked.

[loop:torbscript] decided by the loop: step 1 (#405) landed on main (PR #408, merge commit 2442b1c45, DEBUGGER.md slice 7 Done, `tools/debug-lines.sh` present). The epic's remaining list is re-cut: step 2 = layout table the emitter writes plus the gdb (Python) pretty printers (#469); the lldb formatters move to their own step 3 because they reuse the same table and one PR with both would exceed two commits; then `torb debug` for a native program; then docs and editor launch. Why: the design record fixes the options (section 4), so no owner question; gdb first because its Python API is scriptable in a batch gate, and whether gdb is on the CI runner image is measured in the PR, not asked.
Author
Collaborator

[loop:torbscript] refine: step 2 filed as #469 and marked ready, next: waiting (epic waits on its steps, #469 next). Tokens used: about 60k

[loop:torbscript] refine: step 2 filed as #469 and marked ready, next: waiting (epic waits on its steps, #469 next). Tokens used: about 60k
Author
Collaborator

[loop:torbscript] refine: step 2 (#469, PR #471) merged 2026-10-24; step 3 filed as #600 (lldb formatters, ready), next: waiting (epic waits on its steps, #600 next)

[loop:torbscript] refine: step 2 (#469, PR #471) merged 2026-10-24; step 3 filed as #600 (lldb formatters, ready), next: waiting (epic waits on its steps, #600 next)
Author
Collaborator

[loop:torbscript] refine: re-checked 2026-10-29T17:56Z: step 3 (#600) is claimed by an implementer and PR #601 is open. Nothing else to do on the epic.
next: waiting (epic; step 3 is #600, PR #601 in review)

[loop:torbscript] refine: re-checked 2026-10-29T17:56Z: step 3 (#600) is claimed by an implementer and PR #601 is open. Nothing else to do on the epic. next: waiting (epic; step 3 is #600, PR #601 in review)
Author
Collaborator

[loop:torbscript] re-sweep: wrote the steps into the body; they lived only in the refine comments. Steps 1 to 3 (#405, #469, #600) have landed and are ticked; step 4 is due now, just in time, and is not filed yet.

[loop:torbscript] re-sweep: wrote the steps into the body; they lived only in the refine comments. Steps 1 to 3 (#405, #469, #600) have landed and are ticked; step 4 is due now, just in time, and is not filed yet.
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261112 until 2026-11-12T20:45:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261112 until 2026-11-12T20:45:00Z
Author
Collaborator

[loop:torbscript] decided by the loop: step 4 is cut in two, and step 4a is filed as #720 (ready). Why: launching the native debugger and relaying DAP (build --debug, find lldb-dap or gdb 14+, load the step 2 and 3 scripts, relay and renumber, a session) is one PR of two commits; translating s12_count to count in variables plus its own session is a second, and a session pinned in 4a would otherwise be re-pinned at once. 4b is filed when 4a lands (just in time).

Further decisions, so the implementer need not ask:

  • The launch attribute is native: true next to program (section 16 gets the row); the adapter builds with torb build --debug itself, so the editor needs no build task.
  • Debugger choice: lldb-dap first (the tier B image already installs lldb), else gdb --interpreter=dap; $TORB_DEBUG_NATIVE forces one. Whether lldb-dap is on the runner image is measured in the PR, not asked; if not, the workflow's packages: line gains it.
  • The native session test is its own tier B gate tools/debug-native.sh with tests/debug-native/, not a tests/debug/ session: tools/debug.sh (tier A) writes all requests at once, which a real debugger cannot answer, and it needs a C compiler and a debugger. Linux only; macOS and Windows keep the line-table gate.
  • The printer scripts live only in the repo's tools/ today and tools/package.sh does not ship them, so an installed torb could not load them. 4a adds them to the package layout. This is a gap found in this refine, not in the design record.
  • No seed impact: TorbScript in compiler/src/debugger/ only, no syntax, native, driver flag or looked-up std name.
  • #719 (workers, step 2b of #41) is independent; both touch DEBUGGER.md sections 14, 18 and 20, rebase after whichever lands first. No owner question: nothing here is a public commitment, cost, product direction or reserved by the design record.
[loop:torbscript] decided by the loop: step 4 is cut in two, and step 4a is filed as #720 (ready). Why: launching the native debugger and relaying DAP (build `--debug`, find `lldb-dap` or `gdb` 14+, load the step 2 and 3 scripts, relay and renumber, a session) is one PR of two commits; translating `s12_count` to `count` in `variables` plus its own session is a second, and a session pinned in 4a would otherwise be re-pinned at once. 4b is filed when 4a lands (just in time). Further decisions, so the implementer need not ask: - The launch attribute is `native: true` next to `program` (section 16 gets the row); the adapter builds with `torb build --debug` itself, so the editor needs no build task. - Debugger choice: `lldb-dap` first (the tier B image already installs `lldb`), else `gdb --interpreter=dap`; `$TORB_DEBUG_NATIVE` forces one. Whether `lldb-dap` is on the runner image is measured in the PR, not asked; if not, the workflow's `packages:` line gains it. - The native session test is its own tier B gate `tools/debug-native.sh` with `tests/debug-native/`, not a `tests/debug/` session: `tools/debug.sh` (tier A) writes all requests at once, which a real debugger cannot answer, and it needs a C compiler and a debugger. Linux only; macOS and Windows keep the line-table gate. - The printer scripts live only in the repo's `tools/` today and `tools/package.sh` does not ship them, so an installed `torb` could not load them. 4a adds them to the package layout. This is a gap found in this refine, not in the design record. - No seed impact: TorbScript in `compiler/src/debugger/` only, no syntax, native, driver flag or looked-up std name. - #719 (workers, step 2b of #41) is independent; both touch DEBUGGER.md sections 14, 18 and 20, rebase after whichever lands first. No owner question: nothing here is a public commitment, cost, product direction or reserved by the design record.
Author
Collaborator

[loop:torbscript] refine: epic kept without ready (steps 1 to 3 landed); step 4 cut into 4a (#720, ready) and 4b (filed when 4a lands); epic body updated. Tokens used for this refine: about 70k. next: waiting (epic waits on its steps, #720 next)

[loop:torbscript] refine: epic kept without `ready` (steps 1 to 3 landed); step 4 cut into 4a (#720, ready) and 4b (filed when 4a lands); epic body updated. Tokens used for this refine: about 70k. next: waiting (epic waits on its steps, #720 next)
Author
Collaborator

[loop:torbscript] refine: step 4a is #720 with PR #723 open (forge CI pending, review requested from argus); step 4b is filed when 4a lands. Nothing to do on the epic itself.
next: waiting (step 4a #720, PR #723 in review)

[loop:torbscript] refine: step 4a is #720 with PR #723 open (forge CI pending, review requested from argus); step 4b is filed when 4a lands. Nothing to do on the epic itself. next: waiting (step 4a #720, PR #723 in review)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T06:45:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T06:45:00Z
Author
Collaborator

[loop:torbscript] refine: step 4a (#720, PR #723) landed on main 2026-11-13T04:11Z; ticked in the epic body. Step 4b filed as #731 and marked ready: translate s<digits>_<name> to <name> in the relay of variables responses (pure sourceNameOf in native.trb, unit-tested), plus an extended tests/debug-native/ session that reads the variables, pinned for lldb and gdb. One PR, two commits. Seed impact: none. Design record: DEBUGGER.md sections 4 and 20. Out of scope: evaluate/setVariable names and the docs/VS Code launch (step 5). No duplicate found among open issues. Epic kept without ready.
next: waiting (step 4b, #731)

[loop:torbscript] refine: step 4a (#720, PR #723) landed on main 2026-11-13T04:11Z; ticked in the epic body. Step 4b filed as #731 and marked ready: translate `s<digits>_<name>` to `<name>` in the relay of `variables` responses (pure `sourceNameOf` in `native.trb`, unit-tested), plus an extended `tests/debug-native/` session that reads the variables, pinned for lldb and gdb. One PR, two commits. Seed impact: none. Design record: DEBUGGER.md sections 4 and 20. Out of scope: evaluate/setVariable names and the docs/VS Code launch (step 5). No duplicate found among open issues. Epic kept without `ready`. next: waiting (step 4b, #731)
Author
Collaborator

[loop:torbscript] release refine: done

[loop:torbscript] release refine: done
Author
Collaborator

[loop:torbscript] wait: step 4b is #731, implementation in PR #732 (CI running); the next step of this epic is filed after it merges.
next: waiting (PR #732 CI and merge gate)

[loop:torbscript] wait: step 4b is #731, implementation in PR #732 (CI running); the next step of this epic is filed after it merges. next: waiting (PR #732 CI and merge gate)
Author
Collaborator

[loop:torbscript] refine: step 4b (#731) landed on main with PR #732 (merged 2026-11-13T09:34Z); ticked in the epic body. The last step, 5 (docs, editor guide, VS Code launch for a native program), is filed by the next refine worker when a slot is free, next: waiting (no worker slot free this tick)

[loop:torbscript] refine: step 4b (#731) landed on main with PR #732 (merged 2026-11-13T09:34Z); ticked in the epic body. The last step, 5 (docs, editor guide, VS Code launch for a native program), is filed by the next refine worker when a slot is free, next: waiting (no worker slot free this tick)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:34:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:34:00Z
Author
Collaborator

[loop:torbscript] refine: step 5 filed as #739 (ready), next: waiting (step 5 is #739, implement)

[loop:torbscript] refine: step 5 filed as #739 (ready), next: waiting (step 5 is #739, implement)
Author
Collaborator

[loop:torbscript] wait: step 5 (#739) has PR #762 open, forge CI queued since 16:38Z (head 26bb8f13), merge gate not yet reached, next: waiting (CI on PR #762, then review) until 2026-11-14T08:00:00Z

[loop:torbscript] wait: step 5 (#739) has PR #762 open, forge CI queued since 16:38Z (head 26bb8f13), merge gate not yet reached, next: waiting (CI on PR #762, then review) until 2026-11-14T08:00:00Z
Author
Collaborator

[loop:torbscript] refine: all steps landed (4a #723, 4b #732, 5 #739 as PR #762, merged with argus approval, CI green). Criteria ticked, closing as done. next: done

[loop:torbscript] refine: all steps landed (4a #723, 4b #732, 5 #739 as PR #762, merged with argus approval, CI green). Criteria ticked, closing as done. next: done
orion closed this issue 2026-11-14 09:56:53 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#42
No description provided.