src/os/windows/vm/os_windows.cpp

Print this page




 986 static BOOL (WINAPI *_MiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
 987                                          PMINIDUMP_EXCEPTION_INFORMATION,
 988                                          PMINIDUMP_USER_STREAM_INFORMATION,
 989                                          PMINIDUMP_CALLBACK_INFORMATION);
 990 
 991 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
 992   HINSTANCE dbghelp;
 993   EXCEPTION_POINTERS ep;
 994   MINIDUMP_EXCEPTION_INFORMATION mei;
 995   MINIDUMP_EXCEPTION_INFORMATION* pmei;
 996 
 997   HANDLE hProcess = GetCurrentProcess();
 998   DWORD processId = GetCurrentProcessId();
 999   HANDLE dumpFile;
1000   MINIDUMP_TYPE dumpType;
1001   static const char* cwd;
1002 
1003 // Default is to always create dump for debug builds, on product builds only dump on server versions of Windows.
1004 #ifndef ASSERT
1005   // If running on a client version of Windows and user has not explicitly enabled dumping
1006   if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) {
1007     VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false);
1008     return;
1009     // If running on a server version of Windows and user has explictly disabled dumping
1010   } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
1011     VMError::report_coredump_status("Minidump has been disabled from the command line", false);
1012     return;
1013   }
1014 #else
1015   if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
1016     VMError::report_coredump_status("Minidump has been disabled from the command line", false);
1017     return;
1018   }
1019 #endif
1020 
1021   dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0);
1022 
1023   if (dbghelp == NULL) {
1024     VMError::report_coredump_status("Failed to load dbghelp.dll", false);
1025     return;
1026   }
1027 
1028   _MiniDumpWriteDump =
1029       CAST_TO_FN_PTR(BOOL(WINAPI *)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
1030                                     PMINIDUMP_EXCEPTION_INFORMATION,
1031                                     PMINIDUMP_USER_STREAM_INFORMATION,
1032                                     PMINIDUMP_CALLBACK_INFORMATION),
1033                                     GetProcAddress(dbghelp,
1034                                     "MiniDumpWriteDump"));
1035 
1036   if (_MiniDumpWriteDump == NULL) {




 986 static BOOL (WINAPI *_MiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
 987                                          PMINIDUMP_EXCEPTION_INFORMATION,
 988                                          PMINIDUMP_USER_STREAM_INFORMATION,
 989                                          PMINIDUMP_CALLBACK_INFORMATION);
 990 
 991 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
 992   HINSTANCE dbghelp;
 993   EXCEPTION_POINTERS ep;
 994   MINIDUMP_EXCEPTION_INFORMATION mei;
 995   MINIDUMP_EXCEPTION_INFORMATION* pmei;
 996 
 997   HANDLE hProcess = GetCurrentProcess();
 998   DWORD processId = GetCurrentProcessId();
 999   HANDLE dumpFile;
1000   MINIDUMP_TYPE dumpType;
1001   static const char* cwd;
1002 
1003 // Default is to always create dump for debug builds, on product builds only dump on server versions of Windows.
1004 #ifndef ASSERT
1005   // If running on a client version of Windows and user has not explicitly enabled dumping
1006   if (!os::win32::is_windows_server() && !CreateCoredumpOnCrash) {
1007     VMError::report_coredump_status("Coredumps are not enabled by default on client versions of Windows", false);
1008     return;
1009     // If running on a server version of Windows and user has explictly disabled dumping
1010   } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
1011     VMError::report_coredump_status("Coredump has been disabled from the command line", false);
1012     return;
1013   }
1014 #else
1015   if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {
1016     VMError::report_coredump_status("Coredump has been disabled from the command line", false);
1017     return;
1018   }
1019 #endif
1020 
1021   dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0);
1022 
1023   if (dbghelp == NULL) {
1024     VMError::report_coredump_status("Failed to load dbghelp.dll", false);
1025     return;
1026   }
1027 
1028   _MiniDumpWriteDump =
1029       CAST_TO_FN_PTR(BOOL(WINAPI *)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
1030                                     PMINIDUMP_EXCEPTION_INFORMATION,
1031                                     PMINIDUMP_USER_STREAM_INFORMATION,
1032                                     PMINIDUMP_CALLBACK_INFORMATION),
1033                                     GetProcAddress(dbghelp,
1034                                     "MiniDumpWriteDump"));
1035 
1036   if (_MiniDumpWriteDump == NULL) {