72 #include "utilities/defaultStream.hpp" |
72 #include "utilities/defaultStream.hpp" |
73 #include "utilities/events.hpp" |
73 #include "utilities/events.hpp" |
74 #include "utilities/growableArray.hpp" |
74 #include "utilities/growableArray.hpp" |
75 #include "utilities/macros.hpp" |
75 #include "utilities/macros.hpp" |
76 #include "utilities/vmError.hpp" |
76 #include "utilities/vmError.hpp" |
|
77 #include "windbghelp.hpp" |
|
78 |
77 |
79 |
78 #ifdef _DEBUG |
80 #ifdef _DEBUG |
79 #include <crtdbg.h> |
81 #include <crtdbg.h> |
80 #endif |
82 #endif |
81 |
83 |
1007 } |
1009 } |
1008 VMError::record_coredump_status(buffer, status); |
1010 VMError::record_coredump_status(buffer, status); |
1009 } |
1011 } |
1010 |
1012 |
1011 void os::abort(bool dump_core, void* siginfo, const void* context) { |
1013 void os::abort(bool dump_core, void* siginfo, const void* context) { |
1012 HINSTANCE dbghelp; |
|
1013 EXCEPTION_POINTERS ep; |
1014 EXCEPTION_POINTERS ep; |
1014 MINIDUMP_EXCEPTION_INFORMATION mei; |
1015 MINIDUMP_EXCEPTION_INFORMATION mei; |
1015 MINIDUMP_EXCEPTION_INFORMATION* pmei; |
1016 MINIDUMP_EXCEPTION_INFORMATION* pmei; |
1016 |
1017 |
1017 HANDLE hProcess = GetCurrentProcess(); |
1018 HANDLE hProcess = GetCurrentProcess(); |
1021 shutdown(); |
1022 shutdown(); |
1022 if (!dump_core || dumpFile == NULL) { |
1023 if (!dump_core || dumpFile == NULL) { |
1023 if (dumpFile != NULL) { |
1024 if (dumpFile != NULL) { |
1024 CloseHandle(dumpFile); |
1025 CloseHandle(dumpFile); |
1025 } |
1026 } |
1026 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
|
1027 } |
|
1028 |
|
1029 dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0); |
|
1030 |
|
1031 if (dbghelp == NULL) { |
|
1032 jio_fprintf(stderr, "Failed to load dbghelp.dll\n"); |
|
1033 CloseHandle(dumpFile); |
|
1034 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
|
1035 } |
|
1036 |
|
1037 _MiniDumpWriteDump = |
|
1038 CAST_TO_FN_PTR(BOOL(WINAPI *)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, |
|
1039 PMINIDUMP_EXCEPTION_INFORMATION, |
|
1040 PMINIDUMP_USER_STREAM_INFORMATION, |
|
1041 PMINIDUMP_CALLBACK_INFORMATION), |
|
1042 GetProcAddress(dbghelp, |
|
1043 "MiniDumpWriteDump")); |
|
1044 |
|
1045 if (_MiniDumpWriteDump == NULL) { |
|
1046 jio_fprintf(stderr, "Failed to find MiniDumpWriteDump() in module dbghelp.dll.\n"); |
|
1047 CloseHandle(dumpFile); |
|
1048 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
1027 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
1049 } |
1028 } |
1050 |
1029 |
1051 dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData | |
1030 dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData | |
1052 MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules); |
1031 MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules); |
1062 pmei = NULL; |
1041 pmei = NULL; |
1063 } |
1042 } |
1064 |
1043 |
1065 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all |
1044 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all |
1066 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. |
1045 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. |
1067 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false && |
1046 if (!WindowsDbgHelp::miniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) && |
1068 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) { |
1047 !WindowsDbgHelp::miniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL)) { |
1069 jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x)\n", GetLastError()); |
1048 jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x)\n", GetLastError()); |
1070 } |
1049 } |
1071 CloseHandle(dumpFile); |
1050 CloseHandle(dumpFile); |
1072 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
1051 win32::exit_process_or_thread(win32::EPT_PROCESS, 1); |
1073 } |
1052 } |