mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
clean up MINIDUMP_EXCEPTION_INFORMATION mess in windows.cpp
The last two commits were meant to work around a supposed bug in mingw-w64's dbghelp.h, but closer inspection reminded me that we're not using dbghelp.h at all; legacy mingw doesn't have it, so we had to declare the structures we needed ourselves based on the MSDN documentation. What that documentation doesn't mention is that MINIDUMP_EXCEPTION_INFORMATION is subject to a special, packed layout, which we must represent using the __packed__ attribute.
This commit is contained in:
parent
5c88f77412
commit
eae79fdb34
@ -833,7 +833,7 @@ class MySystem: public System {
|
|||||||
const char* crashDumpDirectory;
|
const char* crashDumpDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_EXCEPTION_INFORMATION {
|
struct __attribute__ ((__packed__)) MINIDUMP_EXCEPTION_INFORMATION {
|
||||||
DWORD thread;
|
DWORD thread;
|
||||||
LPEXCEPTION_POINTERS exception;
|
LPEXCEPTION_POINTERS exception;
|
||||||
BOOL exceptionInCurrentAddressSpace;
|
BOOL exceptionInCurrentAddressSpace;
|
||||||
@ -856,16 +856,6 @@ typedef BOOL (*MiniDumpWriteDumpType)
|
|||||||
const MINIDUMP_USER_STREAM_INFORMATION* userStream,
|
const MINIDUMP_USER_STREAM_INFORMATION* userStream,
|
||||||
const MINIDUMP_CALLBACK_INFORMATION* callback);
|
const MINIDUMP_CALLBACK_INFORMATION* callback);
|
||||||
|
|
||||||
// dbghelp.dll expects that MINIDUMP_EXCEPTION_INFORMATION has a
|
|
||||||
// packed layout and will crash if it doesn't (at least on 64-bit
|
|
||||||
// systems), but as of this writing mingw-w64's version is not
|
|
||||||
// declared to be so. Hence this workaround:
|
|
||||||
struct __attribute__ ((__packed__)) My_MINIDUMP_EXCEPTION_INFORMATION {
|
|
||||||
DWORD ThreadId;
|
|
||||||
PEXCEPTION_POINTERS ExceptionPointers;
|
|
||||||
WINBOOL ClientPointers;
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dump(LPEXCEPTION_POINTERS e, const char* directory)
|
dump(LPEXCEPTION_POINTERS e, const char* directory)
|
||||||
{
|
{
|
||||||
@ -887,22 +877,15 @@ dump(LPEXCEPTION_POINTERS e, const char* directory)
|
|||||||
(name, FILE_WRITE_DATA, 0, 0, CREATE_ALWAYS, 0, 0);
|
(name, FILE_WRITE_DATA, 0, 0, CREATE_ALWAYS, 0, 0);
|
||||||
|
|
||||||
if (file != INVALID_HANDLE_VALUE) {
|
if (file != INVALID_HANDLE_VALUE) {
|
||||||
My_MINIDUMP_EXCEPTION_INFORMATION exception
|
MINIDUMP_EXCEPTION_INFORMATION exception
|
||||||
= { GetCurrentThreadId(), e, true };
|
= { GetCurrentThreadId(), e, true };
|
||||||
|
|
||||||
union {
|
|
||||||
MINIDUMP_EXCEPTION_INFORMATION* exceptionPointer;
|
|
||||||
My_MINIDUMP_EXCEPTION_INFORMATION* myExceptionPointer;
|
|
||||||
};
|
|
||||||
|
|
||||||
myExceptionPointer = &exception;
|
|
||||||
|
|
||||||
MiniDumpWriteDump
|
MiniDumpWriteDump
|
||||||
(GetCurrentProcess(),
|
(GetCurrentProcess(),
|
||||||
GetCurrentProcessId(),
|
GetCurrentProcessId(),
|
||||||
file,
|
file,
|
||||||
MiniDumpWithFullMemory,
|
MiniDumpWithFullMemory,
|
||||||
exceptionPointer,
|
&exception,
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user