src/os/windows/vm/os_windows.cpp

Print this page

        

@@ -986,44 +986,54 @@
 static BOOL (WINAPI *_MiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
                                          PMINIDUMP_EXCEPTION_INFORMATION,
                                          PMINIDUMP_USER_STREAM_INFORMATION,
                                          PMINIDUMP_CALLBACK_INFORMATION);
 
-void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
+void os::check_dump_limit(char* buffer, size_t bufferSize) {
+  // First presume we can dump core file, detail checking done in abort()
+  jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp", get_current_directory(NULL, 0), current_process_id());
+  VMError::report_coredump_status(buffer, true);
+}
+
+void os::abort(bool dump_core, void* siginfo, void* context) {
   HINSTANCE dbghelp;
   EXCEPTION_POINTERS ep;
   MINIDUMP_EXCEPTION_INFORMATION mei;
   MINIDUMP_EXCEPTION_INFORMATION* pmei;
 
   HANDLE hProcess = GetCurrentProcess();
   DWORD processId = GetCurrentProcessId();
   HANDLE dumpFile;
   MINIDUMP_TYPE dumpType;
   static const char* cwd;
+  static char buffer[O_BUFLEN];
+
+  os::shutdown();
+  if (!dump_core) return;
 
 // 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);
+  if (!os::win32::is_windows_server() && !CreateCoredumpOnCrash) {
+    jio_fprintf(stderr, "Minidumps are not enabled by default on client versions of Windows.\n");
     return;
     // If running on a server version of Windows and user has explictly disabled dumping
-  } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
-    VMError::report_coredump_status("Minidump has been disabled from the command line", false);
+  } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
+    jio_fprintf(stderr, "Minidump has been disabled from the command line.\n");
     return;
   }
 #else
-  if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
-    VMError::report_coredump_status("Minidump has been disabled from the command line", false);
+  if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
+    jio_fprintf(stderr, "Minidump has been disabled from the command line.\n");
     return;
   }
 #endif
 
   dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0);
 
   if (dbghelp == NULL) {
-    VMError::report_coredump_status("Failed to load dbghelp.dll", false);
+    jio_fprintf(stderr, "Failed to load dbghelp.dll.\n");
     return;
   }
 
   _MiniDumpWriteDump =
       CAST_TO_FN_PTR(BOOL(WINAPI *)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,

@@ -1032,11 +1042,11 @@
                                     PMINIDUMP_CALLBACK_INFORMATION),
                                     GetProcAddress(dbghelp,
                                     "MiniDumpWriteDump"));
 
   if (_MiniDumpWriteDump == NULL) {
-    VMError::report_coredump_status("Failed to find MiniDumpWriteDump() in module dbghelp.dll", false);
+    jio_fprintf(stderr, "Failed to find MiniDumpWriteDump() in module dbghelp.dll.\n");
     return;
   }
 
   dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData);
 

@@ -1046,20 +1056,21 @@
   dumpType = (MINIDUMP_TYPE)(dumpType | MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo |
                              MiniDumpWithUnloadedModules);
 #endif
 
   cwd = get_current_directory(NULL, 0);
-  jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp", cwd, current_process_id());
+  jio_snprintf(buffer, sizeof(buffer), "%s\\hs_err_pid%u.mdmp", cwd, current_process_id());
   dumpFile = CreateFile(buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 
   if (dumpFile == INVALID_HANDLE_VALUE) {
-    VMError::report_coredump_status("Failed to create file for dumping", false);
+    jio_fprintf(stderr, "Failed to create file %s for dumping.\n", buffer);
     return;
   }
-  if (exceptionRecord != NULL && contextRecord != NULL) {
-    ep.ContextRecord = (PCONTEXT) contextRecord;
-    ep.ExceptionRecord = (PEXCEPTION_RECORD) exceptionRecord;
+
+  if (siginfo != NULL && context != NULL) {
+    ep.ContextRecord = (PCONTEXT) context;
+    ep.ExceptionRecord = (PEXCEPTION_RECORD) siginfo;
 
     mei.ThreadId = GetCurrentThreadId();
     mei.ExceptionPointers = &ep;
     pmei = &mei;
   } else {

@@ -1077,28 +1088,21 @@
     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);
+      jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)\n", 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);
+      jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x)\n", error);
     }
-    VMError::report_coredump_status(buffer, false);
   } else {
-    VMError::report_coredump_status(buffer, true);
+    jio_fprintf(stderr, "%s.\n", buffer);
   }
 
   CloseHandle(dumpFile);
-}
-
-
-void os::abort(bool dump_core) {
-  os::shutdown();
-  // no core dump on Windows
   win32::exit_process_or_thread(win32::EPT_PROCESS, 1);
 }
 
 // Die immediately, no exit hook, no abort hook, no cleanup.
 void os::die() {