src/os/windows/vm/vmError_windows.cpp

Fri, 05 Apr 2013 11:15:13 -0700

author
ccheung
date
Fri, 05 Apr 2013 11:15:13 -0700
changeset 4893
4b7cf00ccb08
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8006001: [parfait] Possible file leak in hotspot/src/os/linux/vm/perfMemory_linux.cpp
Reviewed-by: zgu, coleenp, hseigel, dholmes

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "runtime/arguments.hpp"
stefank@2314 27 #include "runtime/os.hpp"
stefank@2314 28 #include "runtime/thread.hpp"
stefank@2314 29 #include "utilities/vmError.hpp"
duke@435 30
duke@435 31
duke@435 32 void VMError::show_message_box(char *buf, int buflen) {
duke@435 33 bool yes;
duke@435 34 do {
duke@435 35 error_string(buf, buflen);
duke@435 36 int len = (int)strlen(buf);
duke@435 37 char *p = &buf[len];
duke@435 38
duke@435 39 jio_snprintf(p, buflen - len,
duke@435 40 "\n\n"
duke@435 41 "Do you want to debug the problem?\n\n"
duke@435 42 "To debug, attach Visual Studio to process %d; then switch to thread 0x%x\n"
duke@435 43 "Select 'Yes' to launch Visual Studio automatically (PATH must include msdev)\n"
duke@435 44 "Otherwise, select 'No' to abort...",
duke@435 45 os::current_process_id(), os::current_thread_id());
duke@435 46
duke@435 47 yes = os::message_box("Unexpected Error", buf) != 0;
duke@435 48
duke@435 49 if (yes) {
duke@435 50 // yes, user asked VM to launch debugger
duke@435 51 //
duke@435 52 // os::breakpoint() calls DebugBreak(), which causes a breakpoint
duke@435 53 // exception. If VM is running inside a debugger, the debugger will
duke@435 54 // catch the exception. Otherwise, the breakpoint exception will reach
duke@435 55 // the default windows exception handler, which can spawn a debugger and
duke@435 56 // automatically attach to the dying VM.
duke@435 57 os::breakpoint();
duke@435 58 yes = false;
duke@435 59 }
duke@435 60 } while (yes);
duke@435 61 }
duke@435 62
duke@435 63 int VMError::get_resetted_sigflags(int sig) {
duke@435 64 return -1;
duke@435 65 }
duke@435 66
duke@435 67 address VMError::get_resetted_sighandler(int sig) {
duke@435 68 return NULL;
duke@435 69 }
duke@435 70
duke@435 71 LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
duke@435 72 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
duke@435 73 VMError err(NULL, exception_code, NULL,
duke@435 74 exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord);
duke@435 75 err.report_and_die();
duke@435 76 return EXCEPTION_CONTINUE_SEARCH;
duke@435 77 }
duke@435 78
duke@435 79 void VMError::reset_signal_handlers() {
duke@435 80 SetUnhandledExceptionFilter(crash_handler);
duke@435 81 }

mercurial