--- old/src/os/windows/vm/os_windows.cpp 2015-03-25 10:42:47.937448755 -0700 +++ new/src/os/windows/vm/os_windows.cpp 2015-03-25 10:42:47.817442748 -0700 @@ -988,7 +988,13 @@ 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; @@ -999,21 +1005,25 @@ 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 @@ -1021,7 +1031,7 @@ 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; } @@ -1034,7 +1044,7 @@ "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; } @@ -1048,16 +1058,17 @@ #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; @@ -1079,24 +1090,17 @@ 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); }