vmError_windows.cpp revision 0:a61af66fc99e
156067Smarkm/* 256067Smarkm * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. 3114464Smarkm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4103962Smarkm * 556067Smarkm * This code is free software; you can redistribute it and/or modify it 656067Smarkm * under the terms of the GNU General Public License version 2 only, as 756067Smarkm * published by the Free Software Foundation. 856067Smarkm * 956067Smarkm * This code is distributed in the hope that it will be useful, but WITHOUT 1081104Smarkm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1156067Smarkm * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12112049Smarkm * version 2 for more details (a copy is included in the LICENSE file that 1356549Smarkm * accompanied this code). 1456549Smarkm * 1556549Smarkm * You should have received a copy of the GNU General Public License version 16116517Smr * 2 along with this work; if not, write to the Free Software Foundation, 17116517Smr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18116517Smr * 19116517Smr * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20116517Smr * CA 95054 USA or visit www.sun.com if you need additional information or 21116517Smr * have any questions. 22116517Smr * 2356067Smarkm */ 2456067Smarkm 2556067Smarkm# include "incls/_precompiled.incl" 2656067Smarkm# include "incls/_vmError_windows.cpp.incl" 2756067Smarkm 2856067Smarkm 2956067Smarkmvoid VMError::show_message_box(char *buf, int buflen) { 3056067Smarkm bool yes; 3156067Smarkm do { 3256067Smarkm error_string(buf, buflen); 3356067Smarkm int len = (int)strlen(buf); 3456067Smarkm char *p = &buf[len]; 3556067Smarkm 3656067Smarkm jio_snprintf(p, buflen - len, 3756067Smarkm "\n\n" 3856067Smarkm "Do you want to debug the problem?\n\n" 3956067Smarkm "To debug, attach Visual Studio to process %d; then switch to thread 0x%x\n" 4056067Smarkm "Select 'Yes' to launch Visual Studio automatically (PATH must include msdev)\n" 4156067Smarkm "Otherwise, select 'No' to abort...", 4256067Smarkm os::current_process_id(), os::current_thread_id()); 4356067Smarkm 4456067Smarkm yes = os::message_box("Unexpected Error", buf) != 0; 4556067Smarkm 4656067Smarkm if (yes) { 4772450Sassar // yes, user asked VM to launch debugger 4872450Sassar // 4972450Sassar // os::breakpoint() calls DebugBreak(), which causes a breakpoint 5072450Sassar // exception. If VM is running inside a debugger, the debugger will 5172450Sassar // catch the exception. Otherwise, the breakpoint exception will reach 5272450Sassar // the default windows exception handler, which can spawn a debugger and 5356067Smarkm // automatically attach to the dying VM. 5456067Smarkm os::breakpoint(); 5556067Smarkm yes = false; 5656067Smarkm } 5756067Smarkm } while (yes); 5856067Smarkm} 5956067Smarkm 6056067Smarkmint VMError::get_resetted_sigflags(int sig) { 6156067Smarkm return -1; 6256067Smarkm} 6356067Smarkm 6456067Smarkmaddress VMError::get_resetted_sighandler(int sig) { 6556067Smarkm return NULL; 6656067Smarkm} 6756067Smarkm 6856067SmarkmLONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) { 6956067Smarkm DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode; 7056067Smarkm VMError err(NULL, exception_code, NULL, 7156067Smarkm exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord); 7256067Smarkm err.report_and_die(); 7356067Smarkm return EXCEPTION_CONTINUE_SEARCH; 7456067Smarkm} 7556067Smarkm 7656067Smarkmvoid VMError::reset_signal_handlers() { 7756067Smarkm SetUnhandledExceptionFilter(crash_handler); 7856067Smarkm} 7956067Smarkm