-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cause a debug break when a panic occurs on Windows. #34502
Comments
Why just on windows? There used to be an instruction on the panic path that triggered the debugger on Unix at least. I recall it could be annoying. |
When debugging C++ programs on windows, any uncaught exceptions will trigger the just-in-time debugger. The program will pause before unwinding if the exception would have been uncaught, and you're able to enter a debugging session as though the exception has not yet happened (such that the next instruction would cause the exception). It would be really nice if the same experience was possible with rust. |
But in that case programs won't be able to unwind from panic without dropping into debugger. When debugger is not attached, |
Having looked into it a little, I think the best option would be to remove the top-level exception handler which rustc installs, when compiling for windows. When a panic is uncaught, it should then automatically trigger the windows JIT debugging feature, or if running in a debugger, it would break into the debugger. Setting a breakpoint on |
Would you expect different behaviour for programs compiled in release mode in comparison to those compiled in debug mode with regards to the above ? |
Seems reasonable. I would like to see an implementation of this in a PR, along with a brief writeup of how this improves the debugging experience and how it impacts non-debug use cases, and I think the libs team will be able to arrive at a discussion in the PR. |
How about using an environment variable, similar to |
Triage; I'm not aware of any movement on this feature. |
It seem natural to support Windows JIT Debugger attaching same as in C++, I'm surprised this is not implemented yet. |
I'm surprised this is not implemented yet. |
This was attempted then reverted due to how invasive it is. It is not necessarily the case that every panic should break into the debugger (which is especially bad for projects that use
Yes, this would be the better approach imho. Then we would get the C/C++ behaviour "for free". |
In order to aid debugging it would be really useful if Rust would trigger a debug break whenever a panic occurs on Windows. Ideally using the
__debugbreak
intrinsic which is equivalent toint 3
on x86 platforms.The text was updated successfully, but these errors were encountered: