Skip to content

DAP: support reverse debugging (stepBack and reverseContinue) #2116

Done

Description

@lagergren

What

  • stepBack takes granularity and singleThread. The adapter answers, then sends stopped with reason step.
  • reverseContinue takes singleThread.
  • One capability, supportsStepBack, gates both.

Why

  • CodeLLDB: sends supportsStepBack in a capabilities event when the launch configuration has reverseDebugging: true (debug_session/launch.rs:554-557). handle_step_back (:851) and handle_reverse_continue (:862) send the GDB remote packets bs and bc. Its MANUAL.md (lines 437-442) says the only known working backend is Mozilla's rr, version 5.3.0 or later.
  • Delve: sends SupportsStepBack: true in a capabilities event only when the backend is rr (server.go:1400-1401, :2426-2427). Step back uses ReverseNext (:3600), and reverse continue uses Rewind (:3608).
  • rdbg (Ruby):
    • advertises supportsStepBack: true always (lib/debug/server_dap.rb:165);
    • step back works only while the gem's own TracePoint recorder is on, with the record on command (thread_client.rb:1287, session.rb:1040). It does not use rr.
    • reverseContinue always fails: "Reverse Continue is not supported. Only "Step back" is supported." (server_dap.rb:455-458).
  • No: debugpy, vscode-js-debug, lldb-dap, netcoredbg, GDB's DAP, MIEngine, java-debug.

What users miss: stepping back over a line that just ran, or running backwards to the previous breakpoint. This works on rr recordings (Linux) for Go, C, C++ and Rust, and as step back in Ruby.

Today

There is no UI, and supportsStepBack is not read. The XDebugger API of 2024.2 and 2026.3 has no step-back or reverse action either: not in the XDebugProcess methods or in the action groups. So LSP4IJ would add its own actions.

How it could be done

The actions:

  • DAP.StepBack (icon AllIcons.Actions.Back) and DAP.ReverseContinue (AllIcons.Actions.Play_back). Both icons exist in both versions.
  • registerAdditionalActions adds them to topToolbar (the stepping toolbar). They are also added to DebuggingActionsGroup, where OpenDisassemblyAction already is.
  • They are always added and shown by update(), from the live capabilities of the suspend context's client. CodeLLDB and Delve announce supportsStepBack in a capabilities event after the launch, which LSP4IJ applies since fix(dap): apply the capabilities event of a debug adapter #1974; DAPSupport.md's ❌ for Capabilities is stale.
  • update() (BGT): enabled when the session is suspended with a DAPSuspendContext.

Sending:

  • stepBack uses the thread of the context. Its granularity follows DAPDebugProcess.getSteppingGranularity: INSTRUCTION when the disassembly is shown. Its singleThread follows DAPClient.singleThreadStep (DAPClient.java:1340-1361) and the DAP.StepOnlyCurrentThread setting.
  • reverseContinue sends singleThread the same way.

Session state:

  • On success, call session.sessionResumed() in the non-async handler, as in DAPDropFrameHandler.restartFrame. The next stopped then builds a new suspend context.
  • On error, show the adapter's message and stay suspended: rdbg's reverse continue, or rdbg's step back without a recording.
  • Breakpoints hit while running backwards arrive as normal stopped events.

Compatibility and docs: hidden without the capability. Mark StepBack and ReverseContinue as supported in DAPSupport.md, and add a UserGuide section that mentions rr.

Test

  • Session test, in the style of DAPStepOnlyCurrentThreadSessionTest:
    • The server announces supportsStepBack with client.capabilities(...) after configurationDone, and the actions become visible.
    • Step Back sends stepBack with the thread ID and, when set, singleThread and granularity. The server's stopped with reason step suspends the session again.
    • A failed reverseContinue keeps the session suspended.
  • Unit test: the helpers, with Proxy fakes.

Effort and risk

Medium. The code is small, but a real check needs rr on Linux. Low risk. Open questions: where the actions go, and shortcuts (none by default, to avoid conflicts).

Activity

  1. added
    enhancement
    dap
    on Nov 22, 2026
  2. added this to the 0.30.2 milestone on Nov 24, 2026
  3. added a commit that references this issue on Nov 24, 2026
    4918779
  4. added a commit that references this issue on Nov 25, 2026
    4e15453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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