src/os/windows/vm/vmError_windows.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_vmError_windows.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 void VMError::show_message_box(char *buf, int buflen) {
duke@435 30 bool yes;
duke@435 31 do {
duke@435 32 error_string(buf, buflen);
duke@435 33 int len = (int)strlen(buf);
duke@435 34 char *p = &buf[len];
duke@435 35
duke@435 36 jio_snprintf(p, buflen - len,
duke@435 37 "\n\n"
duke@435 38 "Do you want to debug the problem?\n\n"
duke@435 39 "To debug, attach Visual Studio to process %d; then switch to thread 0x%x\n"
duke@435 40 "Select 'Yes' to launch Visual Studio automatically (PATH must include msdev)\n"
duke@435 41 "Otherwise, select 'No' to abort...",
duke@435 42 os::current_process_id(), os::current_thread_id());
duke@435 43
duke@435 44 yes = os::message_box("Unexpected Error", buf) != 0;
duke@435 45
duke@435 46 if (yes) {
duke@435 47 // yes, user asked VM to launch debugger
duke@435 48 //
duke@435 49 // os::breakpoint() calls DebugBreak(), which causes a breakpoint
duke@435 50 // exception. If VM is running inside a debugger, the debugger will
duke@435 51 // catch the exception. Otherwise, the breakpoint exception will reach
duke@435 52 // the default windows exception handler, which can spawn a debugger and
duke@435 53 // automatically attach to the dying VM.
duke@435 54 os::breakpoint();
duke@435 55 yes = false;
duke@435 56 }
duke@435 57 } while (yes);
duke@435 58 }
duke@435 59
duke@435 60 int VMError::get_resetted_sigflags(int sig) {
duke@435 61 return -1;
duke@435 62 }
duke@435 63
duke@435 64 address VMError::get_resetted_sighandler(int sig) {
duke@435 65 return NULL;
duke@435 66 }
duke@435 67
duke@435 68 LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
duke@435 69 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
duke@435 70 VMError err(NULL, exception_code, NULL,
duke@435 71 exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord);
duke@435 72 err.report_and_die();
duke@435 73 return EXCEPTION_CONTINUE_SEARCH;
duke@435 74 }
duke@435 75
duke@435 76 void VMError::reset_signal_handlers() {
duke@435 77 SetUnhandledExceptionFilter(crash_handler);
duke@435 78 }

mercurial