7

I'm working on an academic software visualization project that aims to capture debug sessions and display graphically. For this, I am trying to create a Visual Studio Code Extension where I can get the data exchanged with the current language debugger, such as added breakpoints, stepsinto, stepsover, debug session start, debug file, context variables, line code debugged. That is, the same data that is displayed in the VS Code windows: VARIABLES, WATCH, CALL STACK, LOADED SCRIPTS and BREAKPOINTS.

I tried to create an extension that adds a new Debugger Provider, using Debug Adapter (DAP - Debug Adapter Protocol). However this cancels the current provider and does not allow debugging. https://code.visualstudio.com/api/extension-guides/debugger-extension

I also tried using the VS Code API events. With these events I managed to control the start of the session and some breakpoint data, however incomplete. https://code.visualstudio.com/api/references/vscode-api#debug

Would anyone know how to capture this debugging data in the VS Code scope (VS Code Generic Debugger UI), that is, regardless of the language used? Is there any open issue for this in VS Code's GitHub?

2
  • I doubt this is possible. Having written a debug adapter myself, I believe the communication between vscode and the adapter is purely restricted to these 2 components and cannot be intercepted or read by any other code part. Commented May 7, 2019 at 5:29
  • Could you elaborate on how you want to visualize the data? Commented Aug 30, 2020 at 13:17

1 Answer 1

9

The solution for this is called a DebugAdapterTracker.

vscode.debug.registerDebugAdapterTrackerFactory('*', {
  createDebugAdapterTracker(session: DebugSession) {
    return {
      onWillReceiveMessage: m => console.log(`> ${JSON.stringify(m, undefined, 2)}`),
      onDidSendMessage: m => console.log(`< ${JSON.stringify(m, undefined, 2)}`)
    };
  }
});

https://code.visualstudio.com/updates/v1_30#_extension-authoring

Look for "Finalized Debug Adapter Tracker API". It was originally created for Live Share debugging.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.