comparison src/os/windows/vm/os_windows.cpp @ 10349:a213d425d87a

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
author ctornqvi
date Tue, 28 May 2013 15:08:57 +0200
parents f9be75d21404
children e72f7eecc96d
comparison
equal deleted inserted replaced
10348:3970971c91e0 10349:a213d425d87a
942 DWORD processId = GetCurrentProcessId(); 942 DWORD processId = GetCurrentProcessId();
943 HANDLE dumpFile; 943 HANDLE dumpFile;
944 MINIDUMP_TYPE dumpType; 944 MINIDUMP_TYPE dumpType;
945 static const char* cwd; 945 static const char* cwd;
946 946
947 // Default is to always create dump for debug builds, on product builds only dump on server versions of Windows.
948 #ifndef ASSERT
947 // If running on a client version of Windows and user has not explicitly enabled dumping 949 // If running on a client version of Windows and user has not explicitly enabled dumping
948 if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) { 950 if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) {
949 VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false); 951 VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false);
950 return; 952 return;
951 // If running on a server version of Windows and user has explictly disabled dumping 953 // If running on a server version of Windows and user has explictly disabled dumping
952 } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) { 954 } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
953 VMError::report_coredump_status("Minidump has been disabled from the command line", false); 955 VMError::report_coredump_status("Minidump has been disabled from the command line", false);
954 return; 956 return;
955 } 957 }
958 #else
959 if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
960 VMError::report_coredump_status("Minidump has been disabled from the command line", false);
961 return;
962 }
963 #endif
956 964
957 dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0); 965 dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0);
958 966
959 if (dbghelp == NULL) { 967 if (dbghelp == NULL) {
960 VMError::report_coredump_status("Failed to load dbghelp.dll", false); 968 VMError::report_coredump_status("Failed to load dbghelp.dll", false);
1002 1010
1003 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all 1011 // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all
1004 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. 1012 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then.
1005 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false && 1013 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false &&
1006 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) { 1014 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) {
1007 VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false); 1015 DWORD error = GetLastError();
1016 LPTSTR msgbuf = NULL;
1017
1018 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
1019 FORMAT_MESSAGE_FROM_SYSTEM |
1020 FORMAT_MESSAGE_IGNORE_INSERTS,
1021 NULL, error, 0, (LPTSTR)&msgbuf, 0, NULL) != 0) {
1022
1023 jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf);
1024 LocalFree(msgbuf);
1025 } else {
1026 // Call to FormatMessage failed, just include the result from GetLastError
1027 jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x)", error);
1028 }
1029 VMError::report_coredump_status(buffer, false);
1008 } else { 1030 } else {
1009 VMError::report_coredump_status(buffer, true); 1031 VMError::report_coredump_status(buffer, true);
1010 } 1032 }
1011 1033
1012 CloseHandle(dumpFile); 1034 CloseHandle(dumpFile);