debugger: list suspended tasks as DAP threads (step 1 of #41) #403

Closed
opened 2026-10-22 23:58:43 +00:00 by orion · 4 comments
Collaborator

Context

Step 1 of #41 (epic). A debugged program still runs on one worker (DEBUGGER.md section 14); this step makes the tasks visible. Step 2 (the worker pool the debugger can hold) is filed when this lands.

Source

DEBUGGER.md sections 14 and 20

Goal

threads answers main plus one thread per live task; stackTrace for a task thread shows that task's frames (a suspended task: the frame in its task block); the stopped thread is the one the stop happened in.

Acceptance criteria

  • The runtime offers a read-only walk of the scheduler's live tasks for the debugger (id, name or spawn site, state), taken while the program is stopped
  • threads lists main and every live task, with stable ids across stops (ids of finished tasks are not reused)
  • stackTrace on a task thread returns its frames; variables and scopes work for them
  • A stop inside a task reports that task's thread id with allThreadsStopped
  • A session in tests/debug/ (.trb + .dap + .expected) with at least two suspended tasks and a breakpoint inside a task body
  • DEBUGGER.md section 14 and 20 updated (the "tasks as threads" bullet becomes the decision; the pool bullet stays open)

Seed

Does not touch the seed: no syntax change, no new std name looked up by string. A new debug native (runtime plus VM kernel operation) is added; a seed refresh is not needed unless the debugger sources themselves are in the seed's closure (then the refresh stays Torben's).

Size

One PR, two Conventional Commits: feat(runtime) the walk and kernel operation, feat(debugger) threads, stackTrace, session test and docs.

Dependencies

Likely file overlap with #39 and #40 (both debugger): compiler/src/debugger/debuggee.trb (request dispatch, threads at the answer-at-once block) and adapter.trb, tests/debug/, DEBUGGER.md section 20. Rebase after whichever lands first; do not start before #39 and #40 are merged or in review to keep conflicts small.

Part of #41.

## Context Step 1 of #41 (epic). A debugged program still runs on one worker (DEBUGGER.md section 14); this step makes the tasks visible. Step 2 (the worker pool the debugger can hold) is filed when this lands. ## Source [DEBUGGER.md sections 14 and 20](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/DEBUGGER.md) ## Goal `threads` answers `main` plus one thread per live task; `stackTrace` for a task thread shows that task's frames (a suspended task: the frame in its task block); the stopped thread is the one the stop happened in. ## Acceptance criteria - [ ] The runtime offers a read-only walk of the scheduler's live tasks for the debugger (id, name or spawn site, state), taken while the program is stopped - [ ] `threads` lists `main` and every live task, with stable ids across stops (ids of finished tasks are not reused) - [ ] `stackTrace` on a task thread returns its frames; `variables` and `scopes` work for them - [ ] A stop inside a task reports that task's thread id with `allThreadsStopped` - [ ] A session in `tests/debug/` (`.trb` + `.dap` + `.expected`) with at least two suspended tasks and a breakpoint inside a task body - [ ] DEBUGGER.md section 14 and 20 updated (the "tasks as threads" bullet becomes the decision; the pool bullet stays open) ## Seed Does not touch the seed: no syntax change, no new std name looked up by string. A new debug native (runtime plus VM kernel operation) is added; a seed refresh is not needed unless the debugger sources themselves are in the seed's closure (then the refresh stays Torben's). ## Size One PR, two Conventional Commits: `feat(runtime)` the walk and kernel operation, `feat(debugger)` threads, stackTrace, session test and docs. ## Dependencies Likely file overlap with #39 and #40 (both debugger): `compiler/src/debugger/debuggee.trb` (request dispatch, `threads` at the answer-at-once block) and `adapter.trb`, `tests/debug/`, DEBUGGER.md section 20. Rebase after whichever lands first; do not start before #39 and #40 are merged or in review to keep conflicts small. Part of #41.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T06:07:14Z

[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T06:07:14Z
Author
Collaborator

[loop:torbscript] checkpoint implement: PR #404 is open (branch loop/403-debugger-task-threads, runtime walk + DebugTasks kernel operation + threads/stackTrace per task + tests/debug/tasks + docs). CI is queued; the hand-written tests/debug/tasks.expected may need a correction from the CI diff. Still working on it (claim implement by session:loop-torbscript-20261023).

[loop:torbscript] checkpoint implement: PR https://git.torb.dev/torbscript/language/pulls/404 is open (branch loop/403-debugger-task-threads, runtime walk + DebugTasks kernel operation + threads/stackTrace per task + tests/debug/tasks + docs). CI is queued; the hand-written tests/debug/tasks.expected may need a correction from the CI diff. Still working on it (claim implement by session:loop-torbscript-20261023).
argus closed this issue 2026-10-23 02:09:44 +00:00
Author
Collaborator

[loop:torbscript] implement: PR #404 opened (#404), CI green (tier A, tier B, gates, bootstrap) after one fix round (format and the expected output of tests/debug/tasks), next: review

  • threads lists main plus a thread per task of the program that runs, waits, is queued or has not started (task <n>, id n + 1, numbered lazily by the runtime); runtime-made tasks are not listed.
  • New kernel operation DebugTasks (torb_task_walk), a held frame per waiting task read from its block, the stop names its thread, stackTrace takes threadId.
  • The program's own top-level code is a task once it awaits, so it shows as a thread with main empty (documented in DEBUGGER.md section 14). Stepping one thread while the others stand needs a held worker pool, left open in section 20.
  • Closes #403 only; #41 stays open.

Tokens: about 2.0M in this implement run (estimate, includes context re-reads).

[loop:torbscript] implement: PR #404 opened (https://git.torb.dev/torbscript/language/pulls/404), CI green (tier A, tier B, gates, bootstrap) after one fix round (format and the expected output of `tests/debug/tasks`), next: review - `threads` lists `main` plus a thread per task of the program that runs, waits, is queued or has not started (`task <n>`, id `n + 1`, numbered lazily by the runtime); runtime-made tasks are not listed. - New kernel operation `DebugTasks` (`torb_task_walk`), a held frame per waiting task read from its block, the stop names its thread, `stackTrace` takes `threadId`. - The program's own top-level code is a task once it awaits, so it shows as a thread with `main` empty (documented in DEBUGGER.md section 14). Stepping one thread while the others stand needs a held worker pool, left open in section 20. - Closes #403 only; #41 stays open. Tokens: about 2.0M in this implement run (estimate, includes context re-reads).
Author
Collaborator

[loop:torbscript] post-merge: PR #404 merged 2026-10-23 02:09:43Z (merge commit 40164061bd), no 'After merge' section in the PR. No deploy step in the PR; the language repo ships via nightly.yml (last nightly 02:45 UTC). Not yet verified in a nightly build, so the threads/stackTrace per task is merged but not yet live in a release. Acceptance criteria boxes above stay unticked; PR #404 body maps them to the change (walk + DebugTasks, threads/stackTrace per task, tests/debug/tasks, DEBUGGER.md 2/14/20). Next: confirm in the next nightly (tests/debug/tasks in CI on main).

[loop:torbscript] post-merge: PR #404 merged 2026-10-23 02:09:43Z (merge commit 40164061bd10818c487398c133b1198301b57e66), no 'After merge' section in the PR. No deploy step in the PR; the language repo ships via nightly.yml (last nightly 02:45 UTC). Not yet verified in a nightly build, so the threads/stackTrace per task is merged but not yet live in a release. Acceptance criteria boxes above stay unticked; PR #404 body maps them to the change (walk + DebugTasks, threads/stackTrace per task, tests/debug/tasks, DEBUGGER.md 2/14/20). Next: confirm in the next nightly (tests/debug/tasks in CI on main).
Sign in to join this conversation.
No labels
loop
ready
No milestone
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#403
No description provided.