feat(debugger): list suspended tasks as DAP threads #404

Merged
argus merged 3 commits from loop/403-debugger-task-threads into main 2026-10-23 02:09:43 +00:00
Collaborator

Closes #403

Task

Step 1 of #41: threads lists the tasks of the program, and stackTrace answers per thread.

What

  • Runtime: torb_task_walk (runtime/task.c) lists the live machine tasks as six-word records (serial, block, state, waits-on, frame, bits). A task gets its serial the first time a walk lists it, so ids are stable and never reused. New kernel operation DebugTasks (88), mirrored in format.trb and machine.c.
  • VM: Debugger.runningTask / taskBelow are set around the scheduler's resume in answer(), so a stop inside a task body splits the task's frames from the main thread's.
  • Debuggee: threads answers main (id 1) and task <n> (id n+1) for every task that runs, waits or has not started. stackTrace honours threadId; a waiting task has one frame at its await() statement with locals read from the task block (StackFrame.held). stopped names the thread of the running task. Frame ids are unique across the threads of one stop.
  • Steps and continue still act on the stopped position (all threads stand together); stepping one thread needs a held worker pool, which stays in DEBUGGER.md section 20.
  • Docs: DEBUGGER.md sections 2, 14, 20 and the torb-debug tooling page (with its skills copy).
  • Test: tests/debug/tasks (two tasks that pause, breakpoint in the body, threads and stacks at two stops).

Seed

No seed refresh needed: no syntax, std-name or driver-flag change, only a new debug kernel operation.

Test

No local torb or C compiler in the sandbox; the gates run in this PR's CI. The new .expected was written by hand and is corrected from the CI diff if needed.

Closes #403 ## Task Step 1 of #41: `threads` lists the tasks of the program, and `stackTrace` answers per thread. ## What - Runtime: `torb_task_walk` (runtime/task.c) lists the live machine tasks as six-word records (serial, block, state, waits-on, frame, bits). A task gets its serial the first time a walk lists it, so ids are stable and never reused. New kernel operation `DebugTasks` (88), mirrored in `format.trb` and `machine.c`. - VM: `Debugger.runningTask` / `taskBelow` are set around the scheduler's resume in `answer()`, so a stop inside a task body splits the task's frames from the main thread's. - Debuggee: `threads` answers `main` (id 1) and `task <n>` (id n+1) for every task that runs, waits or has not started. `stackTrace` honours `threadId`; a waiting task has one frame at its `await()` statement with locals read from the task block (`StackFrame.held`). `stopped` names the thread of the running task. Frame ids are unique across the threads of one stop. - Steps and `continue` still act on the stopped position (all threads stand together); stepping one thread needs a held worker pool, which stays in DEBUGGER.md section 20. - Docs: DEBUGGER.md sections 2, 14, 20 and the torb-debug tooling page (with its skills copy). - Test: `tests/debug/tasks` (two tasks that `pause`, breakpoint in the body, threads and stacks at two stops). ## Seed No seed refresh needed: no syntax, std-name or driver-flag change, only a new debug kernel operation. ## Test No local `torb` or C compiler in the sandbox; the gates run in this PR's CI. The new `.expected` was written by hand and is corrected from the CI diff if needed.
torb_task_walk writes the live machine tasks as records of six words, numbering a task at the first walk that lists it. The VM reaches it through the new kernel operation DebugTasks (88).

Refs #403
feat(debugger): list the tasks as DAP threads
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m43s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 5m23s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m38s
ci / gates (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
dd2e3e9b16
threads answers main and a thread per task that runs, waits or has not started. stackTrace takes a threadId; a task that waits shows the statement of its await() and its locals out of the task block. The stopped event names the thread of the running task.

Refs #403
fix(debugger): format the task threads, expect the entry as a thread of its own
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m11s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Successful in 5m28s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m46s
ci / every host emits the same C (pull_request) Successful in 4m52s
ci / tier B (linux-x64) (pull_request) Successful in 13m14s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m1s
ci / gates (pull_request) Successful in 0s
e19fa8cb45
argus approved these changes 2026-10-23 02:09:42 +00:00
argus left a comment

Checklist for e19fa8c:

  • Tests: ok. tests/debug/tasks covers threads, stacks per thread, an unknown thread, locals of a waiting task and a second stop; CI green on this head (gates, tier A/B, bootstrap, pdisc).
  • Correctness: ok. torb_task_walk reads under the tree lock and only the machine's own tasks (torb_machine_resume); serials are never reused; DebugTasks is capacity-checked and re-queried when more tasks exist. runningTask/taskBelow are saved and restored around the resume. Frames are allocated at task creation, so heldFrame reads a valid block for unstarted tasks.
  • Scope: ok. Matches #403 (step 1 of #41); stepping a single thread is left open in DEBUGGER.md section 20.
  • Security/data: ok. Read-only kernel operation, no new permissions, ports or storage.
  • Docs: ok. DEBUGGER.md sections 2/14/20 and the torb-debug page plus its skills copy updated; the seed note is plausible (a new debug kernel op only).

Non-blocking: none.

Checklist for e19fa8c: - Tests: ok. `tests/debug/tasks` covers threads, stacks per thread, an unknown thread, locals of a waiting task and a second stop; CI green on this head (gates, tier A/B, bootstrap, pdisc). - Correctness: ok. `torb_task_walk` reads under the tree lock and only the machine's own tasks (`torb_machine_resume`); serials are never reused; `DebugTasks` is capacity-checked and re-queried when more tasks exist. `runningTask`/`taskBelow` are saved and restored around the resume. Frames are allocated at task creation, so `heldFrame` reads a valid block for unstarted tasks. - Scope: ok. Matches #403 (step 1 of #41); stepping a single thread is left open in DEBUGGER.md section 20. - Security/data: ok. Read-only kernel operation, no new permissions, ports or storage. - Docs: ok. DEBUGGER.md sections 2/14/20 and the torb-debug page plus its skills copy updated; the seed note is plausible (a new debug kernel op only). Non-blocking: none.
argus merged commit 40164061bd into main 2026-10-23 02:09:43 +00:00
argus deleted branch loop/403-debugger-task-threads 2026-10-23 02:09:44 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
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!404
No description provided.