This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't trap exceptions if a debugger is detected on Windows.
Having to "step into" the program every time you debug it to set rt_trapExceptions to false is a nuisance (perhaps more so with Windows debuggers than GDB). Fortunately, we can easily detect when our D program is run under a debugger, and disable the default exception handler, so that an uncaught exception will be handled by the debugger. I believe other Windows runtimes (C++/Delphi) do this as well.
- Loading branch information
1e48655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you "step into" the program?
I'm trying to debug my program but I cannot stop the runtime from handling the Throwable. My minimal example is:
But this still prints the backtrace.
I'm using the rt_trapExceptions because I'm running Linux.
1e48655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux, just break on
_d_throwc
.1e48655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks. I would have never found this myself. I'll give it a try.
1e48655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't set
rt_trapExceptions
from your program, because it is read before any of your code runs (incl. static constructors). It must be set from a debugger.1e48655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaning the debugger sets the variable and then calls main?
But anyway I do not understand the commit message then.