Skip to content

DAP: show in the Threads tab which threads run and which are stopped, also when a thread continues alone #2176

Done

Description

@lagergren

What

The Threads tab of a DAP debug session should show which threads run and which are stopped. This matters most when
the debug adapter resumes one thread alone. For example, a continued
event with allThreadsContinued: false for a thread that isn't the one the session is suspended at.

This was left out of #2106 (#2174). With #2174, such an event leaves the session suspended and asks for the threads
again, but the Threads tab still shows the thread as it did before.

Today

The Threads tab doesn't track whether a thread runs:

  • A row's status is the reason of the last thread
    event of that thread, such as started or exited
    (ThreadsPanel.refreshThread).
    refreshThreads
    keeps it when it shows the threads again.
  • Nothing changes the status when the program stops or resumes: not stopped, not continued, not a resume or a
    step of the session.
  • The icon is ThreadRunning only for the status started, and ThreadSuspended for any other
    (getIconForStatus).
    So a thread that started shows as running while it is stopped at a breakpoint. A thread that the adapter listed
    without a thread event shows as suspended while the program runs.
  • The Frames view keeps the stack of a thread that continued alone. VS Code clears the call stack of that thread
    (debugSession.ts, in its continued handler).

How it could be done

  • Keep a run state per thread in the client of the session (the sessions of a tree, startDebugging, number their
    threads each), and update it from:

  • The Threads tab shows that state: the icon, and the status text.

  • A thread that continued alone: its stack in the Frames view no longer shows the frames of the stop. Options:

    • show it without frames;
    • show it as running;
    • when it is the selected stack, select the stopped thread's.

    IntelliJ's suspend context has a fixed list of execution stacks, so this needs a check of what XDebugger allows.

  • Related: after another thread continued alone, Set Value refuses in the thread that is still stopped. feat: set the value of an Evaluate result with the DAP setExpression request #2150 ends
    the execution epoch at every continued. With a run state per thread, the epoch could end only for the threads that
    continued, if the debug adapter's references stay valid for the stopped ones. DAP doesn't say whether they do.

Test

  • A unit test of the run state: stopped and continued events, with and without allThreadsStopped and
    allThreadsContinued, and the session's resume and single-thread step.
  • A session test, like DAPContinuedEventSessionTest in feat: a DAP debug session shows the program running when the debug adapter says that it continued #2174. The main thread stops, then the worker continues
    alone: the Threads tab shows the worker as running and the main thread as stopped, and the Frames view no longer
    shows frames of the worker's stop.

Related: #2106, #2174, #1869 (single-thread steps), #2153 (terminate threads from the Threads tab).

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIdapenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions