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