提交 bf8ceb11 编写于 作者: C ctornqvi

8015329: Print reason for failed MiniDumpWriteDump() call

Summary: Printing both result from GetLastError and text representation of error. Also changed so that we produce dumps by default on client versions of Windows when running with a debug build. Also reviewed by peter.allwin@oracle.com
Reviewed-by: sla, dholmes
上级 a14c95ff
......@@ -944,6 +944,8 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char*
MINIDUMP_TYPE dumpType;
static const char* cwd;
// Default is to always create dump for debug builds, on product builds only dump on server versions of Windows.
#ifndef ASSERT
// If running on a client version of Windows and user has not explicitly enabled dumping
if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) {
VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false);
......@@ -953,6 +955,12 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char*
VMError::report_coredump_status("Minidump has been disabled from the command line", false);
return;
}
#else
if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
VMError::report_coredump_status("Minidump has been disabled from the command line", false);
return;
}
#endif
dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0);
......@@ -1004,7 +1012,21 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char*
// the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then.
if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false &&
_MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) {
VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false);
DWORD error = GetLastError();
LPTSTR msgbuf = NULL;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, 0, (LPTSTR)&msgbuf, 0, NULL) != 0) {
jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf);
LocalFree(msgbuf);
} else {
// Call to FormatMessage failed, just include the result from GetLastError
jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x)", error);
}
VMError::report_coredump_status(buffer, false);
} else {
VMError::report_coredump_status(buffer, true);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册