author | stefank |
Tue, 05 Apr 2016 10:35:39 +0200 | |
changeset 37254 | 8631304f255c |
parent 35176 | 11a9d4022d9e |
child 38266 | aa3dbc37ede9 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
19952
diff
changeset
|
2 |
* Copyright (c) 2003, 2015, 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 |
||
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
33 |
class VMError : public AllStatic { |
1 | 34 |
friend class VM_ReportJavaOutOfMemory; |
11761 | 35 |
friend class Decoder; |
1 | 36 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
37 |
static int _id; // Solaris/Linux signals: 0 - SIGRTMAX |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
38 |
// Windows exceptions: 0xCxxxxxxx system errors |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
39 |
// 0x8xxxxxxx system warnings |
1 | 40 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
41 |
static const char* _message; |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
42 |
static char _detail_msg[1024]; |
1 | 43 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
44 |
static Thread* _thread; // NULL if it's native thread |
1 | 45 |
|
46 |
// additional info for crashes |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
47 |
static address _pc; // faulting PC |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
48 |
static void* _siginfo; // ExceptionRecord on Windows, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
49 |
// siginfo_t on Solaris/Linux |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
50 |
static void* _context; // ContextRecord on Windows, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
51 |
// ucontext_t on Solaris/Linux |
1 | 52 |
|
53 |
// additional info for VM internal errors |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
54 |
static const char* _filename; |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
55 |
static int _lineno; |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
56 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
57 |
// used by reporting about OOM |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
58 |
static size_t _size; |
1 | 59 |
|
60 |
// used by fatal error handler |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
61 |
static int _current_step; |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
62 |
static const char* _current_step_info; |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
63 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
64 |
// Thread id of the first error. We must be able to handle native thread, |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
65 |
// so use thread id instead of Thread* to identify thread. |
33131
a8ad9de9e5a4
8138832: CreateCoredumpOnCrash on linux ARM causes assert message to be repeated.
david
parents:
33105
diff
changeset
|
66 |
static volatile intptr_t first_error_tid; |
1 | 67 |
|
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
68 |
// 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
|
69 |
static bool coredump_status; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
70 |
|
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
71 |
// 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
|
72 |
// 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
|
73 |
// no core/minidump has been written to disk |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
74 |
static char coredump_message[O_BUFLEN]; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
75 |
|
1 | 76 |
|
77 |
// set signal handlers on Solaris/Linux or the default exception filter |
|
78 |
// on Windows, to handle recursive crashes. |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
79 |
static void reset_signal_handlers(); |
1 | 80 |
|
81 |
// handle -XX:+ShowMessageBoxOnError. buf is used to format the message string |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
82 |
static void show_message_box(char* buf, int buflen); |
1 | 83 |
|
84 |
// generate an error report |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
85 |
static void report(outputStream* st, bool verbose); |
1 | 86 |
|
5340 | 87 |
// generate a stack trace |
88 |
static void print_stack_trace(outputStream* st, JavaThread* jt, |
|
89 |
char* buf, int buflen, bool verbose = false); |
|
90 |
||
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
91 |
static bool should_report_bug(unsigned int id) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
13963
diff
changeset
|
92 |
return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR); |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
13963
diff
changeset
|
93 |
} |
1 | 94 |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
34139
diff
changeset
|
95 |
// Write a hint to the stream in case siginfo relates to a segv/bus error |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
34139
diff
changeset
|
96 |
// and the offending address points into CDS store. |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
34139
diff
changeset
|
97 |
static void check_failing_cds_access(outputStream* st, const void* siginfo); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
34139
diff
changeset
|
98 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
99 |
static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
100 |
void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
101 |
static void report_and_die(const char* message, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(2, 3); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
102 |
|
18487
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17087
diff
changeset
|
103 |
static fdStream out; |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17087
diff
changeset
|
104 |
static fdStream log; // error log used by VMError::report_and_die() |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17087
diff
changeset
|
105 |
|
1 | 106 |
public: |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
13963
diff
changeset
|
107 |
|
1 | 108 |
// return a string to describe the error |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
109 |
static char* error_string(char* buf, int buflen); |
1 | 110 |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
19952
diff
changeset
|
111 |
// Record status of core/minidump |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
19952
diff
changeset
|
112 |
static void record_coredump_status(const char* message, bool status); |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7719
diff
changeset
|
113 |
|
34139
0728fe06ccf8
8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents:
33131
diff
changeset
|
114 |
// support for VM.info diagnostic command |
0728fe06ccf8
8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents:
33131
diff
changeset
|
115 |
static void print_vm_info(outputStream* st); |
0728fe06ccf8
8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents:
33131
diff
changeset
|
116 |
|
1 | 117 |
// main error reporting function |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
118 |
static void report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
119 |
Thread* thread, address pc, void* siginfo, void* context, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
120 |
const char* filename, int lineno, size_t size) ATTRIBUTE_PRINTF(3, 0); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
121 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
122 |
static void report_and_die(Thread* thread, unsigned int sig, address pc, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
123 |
void* siginfo, void* context); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
124 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
125 |
static void report_and_die(Thread* thread,const char* filename, int lineno, const char* message, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
126 |
const char* detail_fmt, va_list detail_args) ATTRIBUTE_PRINTF(5, 0); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
127 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
128 |
static void report_and_die(Thread* thread, const char* filename, int lineno, size_t size, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
129 |
VMErrorType vm_err_type, const char* detail_fmt, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
130 |
va_list detail_args) ATTRIBUTE_PRINTF(6, 0); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
131 |
|
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
132 |
static void report_and_die(const char* message); |
1 | 133 |
|
134 |
// reporting OutOfMemoryError |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
135 |
static void report_java_out_of_memory(const char* message); |
1 | 136 |
|
137 |
// returns original flags for signal, if it was resetted, or -1 if |
|
138 |
// signal was not changed by error reporter |
|
139 |
static int get_resetted_sigflags(int sig); |
|
140 |
||
141 |
// returns original handler for signal, if it was resetted, or NULL if |
|
142 |
// signal was not changed by error reporter |
|
143 |
static address get_resetted_sighandler(int sig); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
144 |
|
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
145 |
// check to see if fatal error reporting is in progress |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31963
diff
changeset
|
146 |
static bool fatal_error_in_progress() { return first_error_tid != -1; } |
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18487
diff
changeset
|
147 |
|
33131
a8ad9de9e5a4
8138832: CreateCoredumpOnCrash on linux ARM causes assert message to be repeated.
david
parents:
33105
diff
changeset
|
148 |
static intptr_t get_first_error_tid() { return first_error_tid; } |
1 | 149 |
}; |
7397 | 150 |
|
151 |
#endif // SHARE_VM_UTILITIES_VMERROR_HPP |