Just-in-time Debugging
MSYS2 processes
To get just-in-time debugging of MSYS2 processes, use the error_start
MSYS
environment variable setting:
export MSYS="error_start:$(cygpath -w /usr/bin/gdb)"
./crashy.exe
Native Windows processes
MINGW gdb can be used as a Windows JIT debugger.
This is documented here under signal-event
.
As Administrator:
regtool add -w '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug'
regtool set -w '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/Debugger' \"$(cygpath -w /mingw64/bin/gdb.exe)'" -ex "attach %ld" -ex "signal-event %ld" -ex "continue"'
regtool set -w '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/Auto' 1
regtool add -W '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug'
regtool set -W '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/Debugger' \"$(cygpath -w /mingw32/bin/gdb.exe)'" -ex "attach %ld" -ex "signal-event %ld" -ex "continue"'
regtool set -W '/HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/Auto' 1
Native Windows processes started from MSYS2
When a native process which was started (possibly indirectly) from an MSYS2 process (such as bash
) crashes, it does not invoke
the registered debugger (or Windows Error Reporting), unless the SetErrorMode
SEM_NOGPFAULTERRORBOX
flag was cleared in the meantime
(SetErrorMode
flags are inherited from a parent process by default). As of msys2-runtime 3.2.0-2
, it is possible to tell MSYS2 to
create processes without inheriting its error mode flags by setting an MSYS
environment variable setting:
export MSYS=winjitdebug
exec bash
./crashy.exe
bash
needs to be restarted, assuming you are starting processes from bash
).