hotspot/src/os/windows/vm/os_windows.cpp
changeset 17832 4bb8ccdc32a9
parent 17376 4ee999c3c007
child 17854 d65bc1546091
equal deleted inserted replaced
17831:d8112d90739f 17832:4bb8ccdc32a9
   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);