Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/windows/vm/vmError_windows.cpp
32284 views
/*1* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "runtime/arguments.hpp"26#include "runtime/os.hpp"27#include "runtime/thread.hpp"28#include "utilities/vmError.hpp"293031void VMError::show_message_box(char *buf, int buflen) {32bool yes;33do {34error_string(buf, buflen);35int len = (int)strlen(buf);36char *p = &buf[len];3738jio_snprintf(p, buflen - len,39"\n\n"40"Do you want to debug the problem?\n\n"41"To debug, attach Visual Studio to process %d; then switch to thread 0x%x\n"42"Select 'Yes' to launch Visual Studio automatically (PATH must include msdev)\n"43"Otherwise, select 'No' to abort...",44os::current_process_id(), os::current_thread_id());4546yes = os::message_box("Unexpected Error", buf) != 0;4748if (yes) {49// yes, user asked VM to launch debugger50//51// os::breakpoint() calls DebugBreak(), which causes a breakpoint52// exception. If VM is running inside a debugger, the debugger will53// catch the exception. Otherwise, the breakpoint exception will reach54// the default windows exception handler, which can spawn a debugger and55// automatically attach to the dying VM.56os::breakpoint();57yes = false;58}59} while (yes);60}6162int VMError::get_resetted_sigflags(int sig) {63return -1;64}6566address VMError::get_resetted_sighandler(int sig) {67return NULL;68}6970LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {71DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;72VMError err(NULL, exception_code, NULL,73exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord);74err.report_and_die();75return EXCEPTION_CONTINUE_SEARCH;76}7778void VMError::reset_signal_handlers() {79SetUnhandledExceptionFilter(crash_handler);80}818283