debugger: torb debug launches a native program through lldb-dap or gdb (step 4a of #42) #720
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#720
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 4a of #42 (epic: debug native programs, DEBUGGER.md section 4). Steps 1 to 3 (#405, #469, #600) landed:
torb build --debugwrites a binary with a#lineper statement and a layout table, and gdb and lldb have printers and formatters for it. Nothing yet connects an editor to them:torb debugonly debugs a program in the VM. Step 4 of the epic is cut in two, because the launch and the relay are one reviewable PR and the translation of names invariables(4b) is the next: a session pinned here would otherwise be re-pinned at once.Source
DEBUGGER.md sections 2, 4, 16, 18 and 20
Goal
An editor can launch a native program through
torb debugand get breakpoints at TorbScript lines, stops with the TorbScript source and line, stepping and continue fromlldb-daporgdb --interpreter=dap, withtorb debugrelaying the Debug Adapter Protocol. Names invariablesstay the debugger's own (s12_count) until step 4b.Acceptance criteria
launchwith"native": true(new attribute in the table of DEBUGGER.md section 16;programas fortorb run) makestorb debugruntorb build --debugfor that program as a child process, report its output asoutputevents, and answerlaunchwith an error naming the build failure if the build fails (no debugger is started then)lldb-dap(alsolldb-dap-<N>andlldb-vscodewhere only those exist), elsegdb14 or newer started with--interpreter=dap;$TORB_DEBUG_NATIVE(lldborgdb) forces one. Where none is found,launchfails with a message that names both and how to install them; the VM debugger and every existing session are unchangedinitCommandswithcommand script import; gdb:-x), so values are already formatted by the layout table; where the script file is not found the session still runs and the adapter says so in anoutputeventContent-Length),seqrenumbered by the adapter as for the VM debuggee;initializeis forwarded and its capabilities answered with the native adapter's,launchis translated to the native adapter's own arguments (program= the built binary,args,cwd,env,stopOnEntry);disconnectand the end of standard input end the native debugger and the adaptertests/debug-native/(new, run by a new tier B gatetools/debug-native.sh, which builds a fixture with--debug) sets a breakpoint on a statement line ofsrc/main.trb, seesstoppedwithstackTraceframe sourcesrc/main.trband that line, steps one line (next), sees the next line, continues and seesterminatedwith exit code 0, once per debugger that is installed. It is a separate gate and not part oftools/debug.sh(tier A), because it needs a C compiler and a debugger; where no debugger is installed it skips with a message unlessDEBUG_NATIVE_REQUIREnames it, the wayDEBUG_VALUES_REQUIREdoes. Linux onlyDEBUG_NATIVE_REQUIRE: lldboncelldb-dapis confirmed on the runner image. This is measured first, in the PR: printcommand -v lldb-dap lldb-dap-18 lldb-vscode gdbandgdb --versionin the CI log. Iflldb-dapis not on the image, thepackages:line of the workflow gains the package that has it (a PR change, no runner change), and the PR body says whichtools/gdb/torb_printers.py,tools/lldb/torb_formatters.py):tools/package.shadds them to the layout, and the adapter looks for them besidestd/andruntime/asfindCompilerSourcesdoes (today onlytools/build-slot.shandtools/build-units.shship)nativeattribute) and 20 (what stays open: translation of names, docs and editor launch);docs/tooling/torb-debug.mddocumentsnative, the debugger lookup and$TORB_DEBUG_NATIVE; theskills/copy is regeneratedSeed
No syntax, native, driver flag or looked-up std name changes. The adapter is TorbScript in
compiler/src/debugger/; it usesProcess,EnvironmentandCurrentProcessasadapter.trbdoes today. No seed refresh needed (a refresh would stay Torben's).Size
One PR, two Conventional Commits:
feat(debugger): torb debug launches a native program through lldb-dap or gdb(adapter, lookup, scripts in the package, DEBUGGER.md, docs) andtest(debugger): a native session per installed debugger in tier B(tests/debug-native/,tools/debug-native.sh, workflow line).Dependencies
After #405, #469 and #600 (landed). Part of #42. Independent of #719 (workers;
runtime/task.c, the debuggee) and of #41; both touch DEBUGGER.md sections 14, 18 and 20, so rebase after whichever lands first. Step 4b (the translation ofs12_counttocountinvariables, a variables session) follows.[loop:torbscript] intake+refine: filed from the refine of #42 (step 4a) and marked ready; goal, acceptance criteria, design record sections, seed impact (none) and size (one PR, two commits) are in the body. next: implementation
[loop:torbscript] claim implementation by session:loop-torbscript-20261112 until 2026-11-12T23:50:00Z
[loop:torbscript] checkpoint: design settled (relay in adapter.trb, lookup/translation in native.trb, interactive driver for tier B), implementing
[loop:torbscript] checkpoint: native lookup and launch translation (compiler/src/debugger/native.trb), findDebuggerScripts, and the relay in adapter.trb written; packaging, docs and the tier B session test next
[loop:torbscript] checkpoint: both commits pushed (loop/720-native-debug), PR #723 opened with Refs #720, review requested from argus; waiting for CI, which is the first compile and the first native session run.
[loop:torbscript] implementation: PR #723 (#723, branch loop/720-native-debug, head
f24ba54, two commits, Refs #720) is open, review requested from argus; forge CI pending. The worker hit its time limit before CI finished, so the claim is released here.next: waiting (forge CI on PR #723, then review or a fix on loop/720-native-debug)
[loop:torbscript] claim implementation by session:loop-torbscript-20261112 until 2026-11-13T04:30:00Z
[loop:torbscript] implementation: pushed
d738d73to loop/720-native-debug (fix(debugger): map the line table to the package and end the native session). CI on PR #723 atd738d73is still pending: tier A, tier B, conformance, playground, seed, archives and gates are running, and every finished job is green.The tier B failure at
dc60015wastools/debug-native.sh(lldb). It had two causes:--debugbuild names its files in#lineby the package name plus the path below the package, and the C compiler runs in torb's working directory. So lldb looks for<cwd>/torbscript/debug-native/src/main.trb, while the editor sets the breakpoint on<project>/src/main.trb. Fix:sourceMappingincompiler/src/debugger/native.trbfinds the nearestproject.trband maps<cwd>/<name>to the package directory. The adapter passes it to lldb-dap assourceMapand to gdb as-iex "set substitute-path ...".tests/debug-native/session.trbnow closes the adapter's input after the disconnect response, like a real editor. In the adapter, end of input now ends the adapter right away when the native session is already over (newnativeDisconnectedflag, ornativeEnded).next: waiting (forge CI on PR #723 at
d738d73d5f)ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T06:30:00Z (fix round for PR #723: the commit-message check fails on head
04cf8df4, typestyleis not allowed)[loop:torbscript] implementation: fix round on PR #723. CI job "commit messages" was red because the head subject used type
style, which is not an allowed Conventional Commit type here. Reworded only the head commit (content identical) tochore(debugger): format the native debugger unit testsand force-pushed loop/720-native-debug with lease. New head6181aae813(was04cf8df4). Localtools/check-commits.sh 79b35cb9..HEADexits 0; forge CI: "commit messages", "what the change touches" and "pdisc" are success, gates/bootstrap/tiers/cross builds still pending.[loop:torbscript] release implement: fix round done
next: waiting (forge CI on PR #723, then review)
[loop:torbscript] implementation: done. PR #723 merged into main at 2026-11-13T04:11Z (seven commits, CI green on
6181aae8). The PR body saidRefs #720, so the merge did not close the issue; closing it here. Step 4b of #42 (names invariables) is the next step and is filed by the refine of #42 when the ready buffer allows.