919 |
919 |
920 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { |
920 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { |
921 HINSTANCE dbghelp; |
921 HINSTANCE dbghelp; |
922 EXCEPTION_POINTERS ep; |
922 EXCEPTION_POINTERS ep; |
923 MINIDUMP_EXCEPTION_INFORMATION mei; |
923 MINIDUMP_EXCEPTION_INFORMATION mei; |
|
924 MINIDUMP_EXCEPTION_INFORMATION* pmei; |
|
925 |
924 HANDLE hProcess = GetCurrentProcess(); |
926 HANDLE hProcess = GetCurrentProcess(); |
925 DWORD processId = GetCurrentProcessId(); |
927 DWORD processId = GetCurrentProcessId(); |
926 HANDLE dumpFile; |
928 HANDLE dumpFile; |
927 MINIDUMP_TYPE dumpType; |
929 MINIDUMP_TYPE dumpType; |
928 static const char* cwd; |
930 static const char* cwd; |
969 |
971 |
970 if (dumpFile == INVALID_HANDLE_VALUE) { |
972 if (dumpFile == INVALID_HANDLE_VALUE) { |
971 VMError::report_coredump_status("Failed to create file for dumping", false); |
973 VMError::report_coredump_status("Failed to create file for dumping", false); |
972 return; |
974 return; |
973 } |
975 } |
974 |
976 if (exceptionRecord != NULL && contextRecord != NULL) { |
975 ep.ContextRecord = (PCONTEXT) contextRecord; |
977 ep.ContextRecord = (PCONTEXT) contextRecord; |
976 ep.ExceptionRecord = (PEXCEPTION_RECORD) exceptionRecord; |
978 ep.ExceptionRecord = (PEXCEPTION_RECORD) exceptionRecord; |
977 |
979 |
978 mei.ThreadId = GetCurrentThreadId(); |
980 mei.ThreadId = GetCurrentThreadId(); |
979 mei.ExceptionPointers = &ep; |
981 mei.ExceptionPointers = &ep; |
|
982 pmei = &mei; |
|
983 } else { |
|
984 pmei = NULL; |
|
985 } |
|
986 |
980 |
987 |
981 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all |
988 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all |
982 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. |
989 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. |
983 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, &mei, NULL, NULL) == false && |
990 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false && |
984 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, &mei, NULL, NULL) == false) { |
991 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) { |
985 VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false); |
992 VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false); |
986 } else { |
993 } else { |
987 VMError::report_coredump_status(buffer, true); |
994 VMError::report_coredump_status(buffer, true); |
988 } |
995 } |
989 |
996 |