3

I would like to know if there exists any way to interact programmatically with the vs code debugger during a session. Python would be ideal, but JS/TS could also work. For the langages being debugged (if relevant) would be C/C++ and Fortran.

My goal would be for instance to be able to dump some variables to a file with their values at different points of execution (like a trace), without having to alter the code or even detailing the structures myself (the debugger would allow this kind of 'reflection' for the structure, listing all the fields for me).

My current setup is working on Windows, targeting "cppvsdbg". I had left that point out because I was hoping to find a vscode-level solution, not caring so much about the backend: just query VS Code which already did the job of talking to the underlying debugger.

0

1 Answer 1

1

Not 100% sure that this is what you're looking for, but you could try using the VS Code extension API, which has a DebugSession.customRequest(command: string, args?: any): Thenable<any> method. You can get the currently active debug session with debug.activeDebugSession. From the argument signature, it looks like an access point to send Debug Adapter Protocol requests. A list of DAP requests and their individual argument signatures can be found in the DAP spec.

Specific debug technologies may have something more specialized that you could choose to use as well. Ex. GDB has a Python API. GDB can also be interfaced with through GDB/MI (I'm pretty sure this interface is part of what cpptools uses to implement its debug adapter for GDB/LLDB). LLDB has a Python API. Visual Studio has a debugger API, but I don't know if it would support what you want.

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.