Conversation
…ht flag which says whether to apply uncaught exception breakpoint filters, defaulting to True.
|
@nshepperd please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
See #1530. |
|
Thanks for the submission but I think this would need some sort of automated test before we'd accept it. And maybe a section in the readme.md explaining how to use it. |
…ost_mortem does. Also, add an explanation in the README.md
8cd1d7b to
b286f0c
Compare
|
Actually I was wondering how to setup tests for this. I figured it out today. Hooray! |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I'm confused about something. pdb.post_mortem attaches the debugger to the process and starts debugging it. This won't. You have to be already attached, right? What would be the point of this then? Is it just so you don't have to break on exceptions in the debugger, but instead control when the break happens? |
|
I think ideally this would actually start VS code and open the debugger. Which might be doable, but would probably have to be configurable somehow. |
|
Yes, the point is so that you can eg. make a context manager or function decorator to debug exceptions that bubble past it instead of setting bespoke breakpoint, which isn't really directly possible for this. I find something like this indispensable for debugging things like api servers or unit tests (pytest) that have exception handlers that eat exceptions. With this you can just wrap your route handler or set an exception handler with conftest.py and launch the program under the debugger and everything just works. I think previously debugpy had the 'user uncaught exceptions' breakpoint added for similar use cases, but that's much less specific and in some cases has too many false positives to be useful. You're right this is a bit different from pdb.post_mortem() in that that actually starts the debugger. I'm not sure about starting vscode though, heh. Maybe it's possible via some sort of vscode:// url? What we could do is at least run debugpy.listen and wait for the debugger to attach? I'm not sure i would actually use that though, usually if i'd want to debug something with vscode I'm already debugging it (eg. I press the 'debug unit test' button) and the issue is just getting the breakpoint. |
|
Either way each use cases should work, i think. If you wanted to launch vscode and attach the debugger you can use existing debugpy functions for that and then call post_mortem. Or if we include that in the function you can check if debugpy.is_client_connected() before calling it if you don't want that. |
If this is the intended use case, maybe the name is off then. It's not post_mortem, it's more like 'force_exception_handler' or something like that. I feel like 'post_mortem' is intended to be like pdb means it. It starts a debugger even when it's not already attached. |
|
Your unit tests also seem to be failing. Not sure if you can see the errors or not |
|
I see the test failures. Cython issue. I forgot to regenerate the cython files. Confusing because it worked locally. |
|
|
Adds a convenient and easy post_mortem() function that can be called to immediately trigger the graphical postmortem debugger given any exc_info structure. We need to suspend sys.monitoring callbacks while doing this, because the built in reentrancy protection doesn't apply when pydevd suspends directly from normal code instead of a monitoring callback. Functions were added in _pydevd_sys_monitoring to do that.