Catching excecptions in the MSVC debugger when running Win64

Lewis musicaljelly at gmail.com
Tue Apr 27 05:43:31 UTC 2021


Okay, I was able to get the VS debugger to catch exceptions in 
win64 by adding a hack to deh_win64_posix.d so that it mimics 
deh_win32.d.

I added the following code above the definition of _d_throwc():

```
import core.sys.windows.windef : DWORD;
extern(Windows)
{
     void RaiseException(DWORD, DWORD, DWORD, void*);
}
```

...and I added the following to _d_throwc() itself, right after 
it calls _d_createTrace():

```
template MAKE_EXCEPTION_CODE(int severity, int facility, int 
exception)
{
    enum int MAKE_EXCEPTION_CODE = (((severity) << 30) | (1 << 29) 
| (0 << 28) | ((facility) << 16) | (exception));
}
enum int STATUS_DIGITAL_MARS_D_EXCEPTION = 
MAKE_EXCEPTION_CODE!(3,'D',1);
enum DWORD EXCEPTION_NONCONTINUABLE = 1;
RaiseException(STATUS_DIGITAL_MARS_D_EXCEPTION, 
EXCEPTION_NONCONTINUABLE, 1, cast(void*)&h);
```

With this, the debugger catches exceptions again.

This feels like a total hack though. Presumably I'm missing an 
obvious better solution?


More information about the Digitalmars-d-debugger mailing list