src/share/vm/utilities/vmError.hpp

Thu, 22 May 2014 15:52:41 -0400

author
drchase
date
Thu, 22 May 2014 15:52:41 -0400
changeset 6680
78bbf4d43a14
parent 5667
38f750491293
child 6876
710a3c8b516e
permissions
-rw-r--r--

8037816: Fix for 8036122 breaks build with Xcode5/clang
8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas
8043164: Format warning in traceStream.hpp
Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings
Reviewed-by: kvn, coleenp, iveresov, twisti

duke@435 1 /*
fparain@5333 2 * Copyright (c) 2003, 2013, 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 #ifndef SHARE_VM_UTILITIES_VMERROR_HPP
stefank@2314 26 #define SHARE_VM_UTILITIES_VMERROR_HPP
stefank@2314 27
stefank@2314 28 #include "utilities/globalDefinitions.hpp"
stefank@2314 29
zgu@3544 30 class Decoder;
duke@435 31 class VM_ReportJavaOutOfMemory;
duke@435 32
duke@435 33 class VMError : public StackObj {
duke@435 34 friend class VM_ReportJavaOutOfMemory;
zgu@3544 35 friend class Decoder;
duke@435 36
duke@435 37 int _id; // Solaris/Linux signals: 0 - SIGRTMAX
duke@435 38 // Windows exceptions: 0xCxxxxxxx system errors
duke@435 39 // 0x8xxxxxxx system warnings
duke@435 40
duke@435 41 const char * _message;
jcoomes@1845 42 const char * _detail_msg;
duke@435 43
duke@435 44 Thread * _thread; // NULL if it's native thread
duke@435 45
duke@435 46
duke@435 47 // additional info for crashes
duke@435 48 address _pc; // faulting PC
duke@435 49 void * _siginfo; // ExceptionRecord on Windows,
duke@435 50 // siginfo_t on Solaris/Linux
duke@435 51 void * _context; // ContextRecord on Windows,
duke@435 52 // ucontext_t on Solaris/Linux
duke@435 53
duke@435 54 // additional info for VM internal errors
duke@435 55 const char * _filename;
twisti@1038 56 int _lineno;
duke@435 57
duke@435 58 // used by fatal error handler
duke@435 59 int _current_step;
duke@435 60 const char * _current_step_info;
duke@435 61 int _verbose;
bobv@2036 62 // First error, and its thread id. We must be able to handle native thread,
bobv@2036 63 // so use thread id instead of Thread* to identify thread.
bobv@2036 64 static VMError* volatile first_error;
bobv@2036 65 static volatile jlong first_error_tid;
duke@435 66
ctornqvi@2520 67 // Core dump status, false if we have been unable to write a core/minidump for some reason
ctornqvi@2520 68 static bool coredump_status;
ctornqvi@2520 69
ctornqvi@2520 70 // When coredump_status is set to true this will contain the name/path to the core/minidump,
ctornqvi@2520 71 // if coredump_status if false, this will (hopefully) contain a useful error explaining why
ctornqvi@2520 72 // no core/minidump has been written to disk
ctornqvi@2520 73 static char coredump_message[O_BUFLEN];
ctornqvi@2520 74
duke@435 75 // used by reporting about OOM
duke@435 76 size_t _size;
duke@435 77
duke@435 78 // set signal handlers on Solaris/Linux or the default exception filter
duke@435 79 // on Windows, to handle recursive crashes.
duke@435 80 void reset_signal_handlers();
duke@435 81
duke@435 82 // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
duke@435 83 void show_message_box(char* buf, int buflen);
duke@435 84
duke@435 85 // generate an error report
duke@435 86 void report(outputStream* st);
duke@435 87
twisti@1819 88 // generate a stack trace
twisti@1819 89 static void print_stack_trace(outputStream* st, JavaThread* jt,
twisti@1819 90 char* buf, int buflen, bool verbose = false);
twisti@1819 91
duke@435 92 // accessor
jcoomes@1845 93 const char* message() const { return _message; }
jcoomes@1845 94 const char* detail_msg() const { return _detail_msg; }
ccheung@4993 95 bool should_report_bug(unsigned int id) {
ccheung@4993 96 return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
ccheung@4993 97 }
duke@435 98
fparain@5333 99 static fdStream out;
fparain@5333 100 static fdStream log; // error log used by VMError::report_and_die()
fparain@5333 101
duke@435 102 public:
ccheung@4993 103
duke@435 104 // Constructor for crashes
coleenp@2418 105 VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
coleenp@2418 106 void* context);
duke@435 107 // Constructor for VM internal errors
jcoomes@1845 108 VMError(Thread* thread, const char* filename, int lineno,
jcoomes@1845 109 const char* message, const char * detail_msg);
duke@435 110
jcoomes@1845 111 // Constructor for VM OOM errors
jcoomes@1845 112 VMError(Thread* thread, const char* filename, int lineno, size_t size,
ccheung@4993 113 VMErrorType vm_err_type, const char* message);
duke@435 114 // Constructor for non-fatal errors
duke@435 115 VMError(const char* message);
duke@435 116
duke@435 117 // return a string to describe the error
duke@435 118 char *error_string(char* buf, int buflen);
duke@435 119
ctornqvi@2520 120 // Report status of core/minidump
ctornqvi@2520 121 static void report_coredump_status(const char* message, bool status);
ctornqvi@2520 122
duke@435 123 // main error reporting function
duke@435 124 void report_and_die();
duke@435 125
duke@435 126 // reporting OutOfMemoryError
duke@435 127 void report_java_out_of_memory();
duke@435 128
duke@435 129 // returns original flags for signal, if it was resetted, or -1 if
duke@435 130 // signal was not changed by error reporter
duke@435 131 static int get_resetted_sigflags(int sig);
duke@435 132
duke@435 133 // returns original handler for signal, if it was resetted, or NULL if
duke@435 134 // signal was not changed by error reporter
duke@435 135 static address get_resetted_sighandler(int sig);
bobv@2036 136
bobv@2036 137 // check to see if fatal error reporting is in progress
bobv@2036 138 static bool fatal_error_in_progress() { return first_error != NULL; }
iklam@5667 139
iklam@5667 140 static jlong get_first_error_tid() {
iklam@5667 141 return first_error_tid;
iklam@5667 142 }
duke@435 143 };
stefank@2314 144
stefank@2314 145 #endif // SHARE_VM_UTILITIES_VMERROR_HPP

mercurial