Add breakpoint at specific location (different from current one) #1626
Replies: 1 comment
-
I can try to answer your questions:
There's two ways. The way you indicated (by changing your python code) and by sending messages according to the DAP (Debug Adapter Protocol). See the spec here: https://microsoft.github.io/debug-adapter-protocol/specification Using the DAP requires you start the debugpy adapter though. Not sure how you're attaching, but that's what VS code does.
This isn't possible with python. You'd need to write a VS code extension to do so. VS code extensions are written in javascript/typescript AFAIK. Theoretically the breakpoint data is stored somewhere on disk, but that wouldn't be a stable way to get that information.
I'm not entirely sure what you mean by this. Perhaps you mean you want to attach at the moment your breakpoint statement is fired? I don't believe that's possible without you writing some code in your app. If for example you know some condition that you then want to debug, you could put a
The source for this extension is here: https://github.com/microsoft/vscode-python-debugger but it isn't the one that tells debugpy about the breakpoints. VS code itself does that. That extension provides a DebugAdapterDescriptor in this file here: https://github.com/microsoft/vscode-python-debugger/blob/main/src/extension/debugger/adapter/factory.ts that tells VS code how to start a debugger that talks the DAP. You can read more about how VS code sets up debuggers here: |
Beta Was this translation helpful? Give feedback.
-
I am attaching to debugpy once it hits an error.
How can I programmatically add a breakpoint, similarly to pdb's
b(reak) [[filename:]lineno | function[, condition]]
with debugpy?How can I extract the currently enabled/disabled breakpoints in the current workspace in VSCode (from python)?
The following
only sets a breakpoint at the current location.
How can I wait for a debug client once a breakpoint is hit?
It would also be great if you can point me to the relevant source code showing how the VSCode debugging extension itself does it to get the breakpoints and tell debugpy about their locations.
Beta Was this translation helpful? Give feedback.
All reactions