src/share/vm/utilities/vmError.hpp

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added MIPS 64-bit port.

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_UTILITIES_VMERROR_HPP
aoqi@0 26 #define SHARE_VM_UTILITIES_VMERROR_HPP
aoqi@0 27
aoqi@0 28 #include "utilities/globalDefinitions.hpp"
aoqi@0 29
aoqi@0 30 class Decoder;
aoqi@0 31 class VM_ReportJavaOutOfMemory;
aoqi@0 32
aoqi@0 33 class VMError : public StackObj {
aoqi@0 34 friend class VM_ReportJavaOutOfMemory;
aoqi@0 35 friend class Decoder;
aoqi@0 36
aoqi@0 37 int _id; // Solaris/Linux signals: 0 - SIGRTMAX
aoqi@0 38 // Windows exceptions: 0xCxxxxxxx system errors
aoqi@0 39 // 0x8xxxxxxx system warnings
aoqi@0 40
aoqi@0 41 const char * _message;
aoqi@0 42 const char * _detail_msg;
aoqi@0 43
aoqi@0 44 Thread * _thread; // NULL if it's native thread
aoqi@0 45
aoqi@0 46
aoqi@0 47 // additional info for crashes
aoqi@0 48 address _pc; // faulting PC
aoqi@0 49 void * _siginfo; // ExceptionRecord on Windows,
aoqi@0 50 // siginfo_t on Solaris/Linux
aoqi@0 51 void * _context; // ContextRecord on Windows,
aoqi@0 52 // ucontext_t on Solaris/Linux
aoqi@0 53
aoqi@0 54 // additional info for VM internal errors
aoqi@0 55 const char * _filename;
aoqi@0 56 int _lineno;
aoqi@0 57
aoqi@0 58 // used by fatal error handler
aoqi@0 59 int _current_step;
aoqi@0 60 const char * _current_step_info;
aoqi@0 61 int _verbose;
aoqi@0 62 // First error, and its thread id. We must be able to handle native thread,
aoqi@0 63 // so use thread id instead of Thread* to identify thread.
aoqi@0 64 static VMError* volatile first_error;
aoqi@0 65 static volatile jlong first_error_tid;
aoqi@0 66
aoqi@0 67 // Core dump status, false if we have been unable to write a core/minidump for some reason
aoqi@0 68 static bool coredump_status;
aoqi@0 69
aoqi@0 70 // When coredump_status is set to true this will contain the name/path to the core/minidump,
aoqi@0 71 // if coredump_status if false, this will (hopefully) contain a useful error explaining why
aoqi@0 72 // no core/minidump has been written to disk
aoqi@0 73 static char coredump_message[O_BUFLEN];
aoqi@0 74
aoqi@0 75 // used by reporting about OOM
aoqi@0 76 size_t _size;
aoqi@0 77
aoqi@0 78 // set signal handlers on Solaris/Linux or the default exception filter
aoqi@0 79 // on Windows, to handle recursive crashes.
aoqi@0 80 void reset_signal_handlers();
aoqi@0 81
aoqi@0 82 // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
aoqi@0 83 void show_message_box(char* buf, int buflen);
aoqi@0 84
aoqi@0 85 // generate an error report
aoqi@0 86 void report(outputStream* st);
aoqi@0 87
aoqi@0 88 // generate a stack trace
aoqi@0 89 static void print_stack_trace(outputStream* st, JavaThread* jt,
aoqi@0 90 char* buf, int buflen, bool verbose = false);
aoqi@0 91
aoqi@0 92 // accessor
aoqi@0 93 const char* message() const { return _message; }
aoqi@0 94 const char* detail_msg() const { return _detail_msg; }
aoqi@0 95 bool should_report_bug(unsigned int id) {
aoqi@0 96 return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 static fdStream out;
aoqi@0 100 static fdStream log; // error log used by VMError::report_and_die()
aoqi@0 101
aoqi@0 102 public:
aoqi@0 103
aoqi@0 104 // Constructor for crashes
aoqi@0 105 VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
aoqi@0 106 void* context);
aoqi@0 107 // Constructor for VM internal errors
aoqi@0 108 VMError(Thread* thread, const char* filename, int lineno,
aoqi@0 109 const char* message, const char * detail_msg);
aoqi@0 110
aoqi@0 111 // Constructor for VM OOM errors
aoqi@0 112 VMError(Thread* thread, const char* filename, int lineno, size_t size,
aoqi@0 113 VMErrorType vm_err_type, const char* message);
aoqi@0 114 // Constructor for non-fatal errors
aoqi@0 115 VMError(const char* message);
aoqi@0 116
aoqi@0 117 // return a string to describe the error
aoqi@0 118 char *error_string(char* buf, int buflen);
aoqi@0 119
aoqi@0 120 // Report status of core/minidump
aoqi@0 121 static void report_coredump_status(const char* message, bool status);
aoqi@0 122
aoqi@0 123 // main error reporting function
aoqi@0 124 void report_and_die();
aoqi@0 125
aoqi@0 126 // reporting OutOfMemoryError
aoqi@0 127 void report_java_out_of_memory();
aoqi@0 128
aoqi@0 129 // returns original flags for signal, if it was resetted, or -1 if
aoqi@0 130 // signal was not changed by error reporter
aoqi@0 131 static int get_resetted_sigflags(int sig);
aoqi@0 132
aoqi@0 133 // returns original handler for signal, if it was resetted, or NULL if
aoqi@0 134 // signal was not changed by error reporter
aoqi@0 135 static address get_resetted_sighandler(int sig);
aoqi@0 136
aoqi@0 137 // check to see if fatal error reporting is in progress
aoqi@0 138 static bool fatal_error_in_progress() { return first_error != NULL; }
aoqi@0 139
aoqi@0 140 static jlong get_first_error_tid() {
aoqi@0 141 return first_error_tid;
aoqi@0 142 }
aoqi@0 143 };
aoqi@0 144
aoqi@0 145 #endif // SHARE_VM_UTILITIES_VMERROR_HPP

mercurial