0N/A/*
1879N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "runtime/arguments.hpp"
1879N/A#include "runtime/os.hpp"
1879N/A#include "runtime/thread.hpp"
1879N/A#include "utilities/vmError.hpp"
0N/A
0N/A
0N/Avoid VMError::show_message_box(char *buf, int buflen) {
0N/A bool yes;
0N/A do {
0N/A error_string(buf, buflen);
0N/A int len = (int)strlen(buf);
0N/A char *p = &buf[len];
0N/A
0N/A jio_snprintf(p, buflen - len,
0N/A "\n\n"
0N/A "Do you want to debug the problem?\n\n"
0N/A "To debug, attach Visual Studio to process %d; then switch to thread 0x%x\n"
0N/A "Select 'Yes' to launch Visual Studio automatically (PATH must include msdev)\n"
0N/A "Otherwise, select 'No' to abort...",
0N/A os::current_process_id(), os::current_thread_id());
0N/A
0N/A yes = os::message_box("Unexpected Error", buf) != 0;
0N/A
0N/A if (yes) {
0N/A // yes, user asked VM to launch debugger
0N/A //
0N/A // os::breakpoint() calls DebugBreak(), which causes a breakpoint
0N/A // exception. If VM is running inside a debugger, the debugger will
0N/A // catch the exception. Otherwise, the breakpoint exception will reach
0N/A // the default windows exception handler, which can spawn a debugger and
0N/A // automatically attach to the dying VM.
0N/A os::breakpoint();
0N/A yes = false;
0N/A }
0N/A } while (yes);
0N/A}
0N/A
0N/Aint VMError::get_resetted_sigflags(int sig) {
0N/A return -1;
0N/A}
0N/A
0N/Aaddress VMError::get_resetted_sighandler(int sig) {
0N/A return NULL;
0N/A}
0N/A
0N/ALONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
0N/A DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
0N/A VMError err(NULL, exception_code, NULL,
0N/A exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord);
0N/A err.report_and_die();
0N/A return EXCEPTION_CONTINUE_SEARCH;
0N/A}
0N/A
0N/Avoid VMError::reset_signal_handlers() {
0N/A SetUnhandledExceptionFilter(crash_handler);
0N/A}