author | stefank |
Tue, 05 Apr 2016 10:35:39 +0200 | |
changeset 37254 | 8631304f255c |
parent 37113 | 5a33bf5089ac |
child 38254 | 05e46b580b4e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
37113 | 2 |
* Copyright (c) 1997, 2016, 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_DEBUG_HPP |
26 |
#define SHARE_VM_UTILITIES_DEBUG_HPP |
|
27 |
||
22827 | 28 |
#include "utilities/globalDefinitions.hpp" |
8680 | 29 |
#include "prims/jvm.h" |
7397 | 30 |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
31 |
#include <stdarg.h> |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
32 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
33 |
// Simple class to format the ctor arguments into a fixed-sized buffer. |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
34 |
class FormatBufferBase { |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
35 |
protected: |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
36 |
char* _buf; |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
37 |
inline FormatBufferBase(char* buf) : _buf(buf) {} |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
38 |
public: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
39 |
static const int BufferSize = 256; |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
40 |
operator const char *() const { return _buf; } |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
41 |
}; |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
42 |
|
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
43 |
// Use resource area for buffer |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
44 |
class FormatBufferResource : public FormatBufferBase { |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
45 |
public: |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23515
diff
changeset
|
46 |
FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
47 |
}; |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
48 |
|
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
49 |
// Use stack for buffer |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
50 |
template <size_t bufsz = FormatBufferBase::BufferSize> |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
51 |
class FormatBuffer : public FormatBufferBase { |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
52 |
public: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
53 |
inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23515
diff
changeset
|
54 |
inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23515
diff
changeset
|
55 |
inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23515
diff
changeset
|
56 |
inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
57 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
58 |
char* buffer() { return _buf; } |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
59 |
int size() { return bufsz; } |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
60 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
61 |
private: |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
62 |
FormatBuffer(const FormatBuffer &); // prevent copies |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
63 |
char _buffer[bufsz]; |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
64 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
65 |
protected: |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
66 |
inline FormatBuffer(); |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
67 |
}; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
68 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
69 |
template <size_t bufsz> |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
70 |
FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) { |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
71 |
va_list argp; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
72 |
va_start(argp, format); |
8680 | 73 |
jio_vsnprintf(_buf, bufsz, format, argp); |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
74 |
va_end(argp); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
75 |
} |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
76 |
|
7923 | 77 |
template <size_t bufsz> |
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11636
diff
changeset
|
78 |
FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) { |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
79 |
_buf[0] = '\0'; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
80 |
} |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
81 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
82 |
template <size_t bufsz> |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
83 |
void FormatBuffer<bufsz>::print(const char * format, ...) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
84 |
va_list argp; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
85 |
va_start(argp, format); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
86 |
jio_vsnprintf(_buf, bufsz, format, argp); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
87 |
va_end(argp); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
88 |
} |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
89 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
90 |
template <size_t bufsz> |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
91 |
void FormatBuffer<bufsz>::printv(const char * format, va_list argp) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
92 |
jio_vsnprintf(_buf, bufsz, format, argp); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
93 |
} |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
94 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
8921
diff
changeset
|
95 |
template <size_t bufsz> |
7923 | 96 |
void FormatBuffer<bufsz>::append(const char* format, ...) { |
97 |
// Given that the constructor does a vsnprintf we can assume that |
|
98 |
// _buf is already initialized. |
|
99 |
size_t len = strlen(_buf); |
|
100 |
char* buf_end = _buf + len; |
|
101 |
||
102 |
va_list argp; |
|
103 |
va_start(argp, format); |
|
8680 | 104 |
jio_vsnprintf(buf_end, bufsz - len, format, argp); |
7923 | 105 |
va_end(argp); |
106 |
} |
|
107 |
||
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
108 |
// Used to format messages. |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
109 |
typedef FormatBuffer<> err_msg; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
110 |
|
1 | 111 |
// assertions |
28477 | 112 |
#ifndef ASSERT |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
113 |
#define vmassert(p, ...) |
28477 | 114 |
#else |
115 |
// Note: message says "assert" rather than "vmassert" for backward |
|
116 |
// compatibility with tools that parse/match the message text. |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
117 |
// Note: The signature is vmassert(p, format, ...), but the solaris |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
118 |
// compiler can't handle an empty ellipsis in a macro without a warning. |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
119 |
#define vmassert(p, ...) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
120 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
121 |
if (!(p)) { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
122 |
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
123 |
BREAKPOINT; \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
124 |
} \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
125 |
} while (0) |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
126 |
|
28477 | 127 |
#endif |
1 | 128 |
|
28477 | 129 |
// For backward compatibility. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
130 |
#define assert(p, ...) vmassert(p, __VA_ARGS__) |
28477 | 131 |
|
132 |
// This version of vmassert is for use with checking return status from |
|
1 | 133 |
// library calls that return actual error values eg. EINVAL, |
134 |
// ENOMEM etc, rather than returning -1 and setting errno. |
|
135 |
// When the status is not what is expected it is very useful to know |
|
136 |
// what status was actually returned, so we pass the status variable as |
|
137 |
// an extra arg and use strerror to convert it to a meaningful string |
|
138 |
// like "Invalid argument", "out of memory" etc |
|
28477 | 139 |
#define vmassert_status(p, status, msg) \ |
37113 | 140 |
do { \ |
141 |
if (!(p)) { \ |
|
142 |
report_vm_status_error(__FILE__, __LINE__, "assert(" #p ") failed", \ |
|
143 |
status, msg); \ |
|
144 |
BREAKPOINT; \ |
|
145 |
} \ |
|
146 |
} while (0) |
|
1 | 147 |
|
28477 | 148 |
// For backward compatibility. |
149 |
#define assert_status(p, status, msg) vmassert_status(p, status, msg) |
|
1 | 150 |
|
28477 | 151 |
// guarantee is like vmassert except it's always executed -- use it for |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
152 |
// cheap tests that catch errors that would otherwise be hard to find. |
1 | 153 |
// guarantee is also used for Verify options. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
154 |
#define guarantee(p, ...) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
155 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
156 |
if (!(p)) { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
157 |
report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", __VA_ARGS__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
158 |
BREAKPOINT; \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
159 |
} \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
160 |
} while (0) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
161 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
162 |
#define fatal(...) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
163 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
164 |
report_fatal(__FILE__, __LINE__, __VA_ARGS__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
165 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
166 |
} while (0) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
167 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
168 |
// out of memory |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
169 |
#define vm_exit_out_of_memory(size, vm_err_type, ...) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
170 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
171 |
report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, __VA_ARGS__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
172 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
173 |
} while (0) |
1 | 174 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
175 |
#define ShouldNotCallThis() \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
176 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
177 |
report_should_not_call(__FILE__, __LINE__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
178 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
179 |
} while (0) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
180 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
181 |
#define ShouldNotReachHere() \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
182 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
183 |
report_should_not_reach_here(__FILE__, __LINE__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
184 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
185 |
} while (0) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
186 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
187 |
#define Unimplemented() \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
188 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
189 |
report_unimplemented(__FILE__, __LINE__); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
190 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
191 |
} while (0) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
192 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
193 |
#define Untested(msg) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
194 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
195 |
report_untested(__FILE__, __LINE__, msg); \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
196 |
BREAKPOINT; \ |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
197 |
} while (0); |
1 | 198 |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
199 |
|
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
200 |
// types of VM error - originally in vmError.hpp |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
201 |
enum VMErrorType { |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
202 |
INTERNAL_ERROR = 0xe0000000, |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
203 |
OOM_MALLOC_ERROR = 0xe0000001, |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
204 |
OOM_MMAP_ERROR = 0xe0000002 |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
205 |
}; |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16370
diff
changeset
|
206 |
|
1 | 207 |
// error reporting helper functions |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
208 |
void report_vm_error(const char* file, int line, const char* error_msg); |
33142
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
209 |
#if !defined(__GNUC__) || defined (__clang_major__) || (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || __GNUC__ > 4) |
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
210 |
// ATTRIBUTE_PRINTF works with gcc >= 4.8 and any other compiler. |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
211 |
void report_vm_error(const char* file, int line, const char* error_msg, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
212 |
const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); |
33142
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
213 |
#else |
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
214 |
// GCC < 4.8 warns because of empty format string. Warning can not be switched off selectively. |
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
215 |
void report_vm_error(const char* file, int line, const char* error_msg, |
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
216 |
const char* detail_fmt, ...); |
399fdb935d28
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents:
33105
diff
changeset
|
217 |
#endif |
37113 | 218 |
void report_vm_status_error(const char* file, int line, const char* error_msg, |
219 |
int status, const char* detail); |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
220 |
void report_fatal(const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(3, 4); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
221 |
void report_vm_out_of_memory(const char* file, int line, size_t size, VMErrorType vm_err_type, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31340
diff
changeset
|
222 |
const char* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6); |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
223 |
void report_should_not_call(const char* file, int line); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
224 |
void report_should_not_reach_here(const char* file, int line); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
225 |
void report_unimplemented(const char* file, int line); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
226 |
void report_untested(const char* file, int line, const char* message); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
227 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23515
diff
changeset
|
228 |
void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); |
1 | 229 |
|
28480 | 230 |
// Compile-time asserts. Cond must be a compile-time constant expression that |
231 |
// is convertible to bool. STATIC_ASSERT() can be used anywhere a declaration |
|
232 |
// may appear. |
|
233 |
// |
|
234 |
// Implementation Note: STATIC_ASSERT_FAILURE<true> provides a value member |
|
235 |
// rather than type member that could be used directly in the typedef, because |
|
236 |
// a type member would require conditional use of "typename", depending on |
|
237 |
// whether Cond is dependent or not. The use of a value member leads to the |
|
238 |
// use of an array type. |
|
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18683
diff
changeset
|
239 |
|
28480 | 240 |
template<bool x> struct STATIC_ASSERT_FAILURE; |
241 |
template<> struct STATIC_ASSERT_FAILURE<true> { enum { value = 1 }; }; |
|
242 |
||
29691 | 243 |
#define STATIC_ASSERT(Cond) \ |
31340
2f9ff278bb13
8086027: Multiple STATIC_ASSERTs at class scope doesn't work
kbarrett
parents:
29691
diff
changeset
|
244 |
typedef char PASTE_TOKENS(STATIC_ASSERT_DUMMY_TYPE_, __LINE__)[ \ |
2f9ff278bb13
8086027: Multiple STATIC_ASSERTs at class scope doesn't work
kbarrett
parents:
29691
diff
changeset
|
245 |
STATIC_ASSERT_FAILURE< (Cond) >::value ] |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18683
diff
changeset
|
246 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
247 |
// out of shared space reporting |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
248 |
enum SharedSpaceType { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
249 |
SharedReadOnly, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
250 |
SharedReadWrite, |
27404
33c0f343cd5c
8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents:
26821
diff
changeset
|
251 |
SharedMiscData, |
33c0f343cd5c
8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents:
26821
diff
changeset
|
252 |
SharedMiscCode |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
253 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
254 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
255 |
void report_out_of_shared_space(SharedSpaceType space_type); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7923
diff
changeset
|
256 |
|
28476
ae1ca3bf45ca
8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
27404
diff
changeset
|
257 |
void report_insufficient_metaspace(size_t required_size); |
ae1ca3bf45ca
8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
27404
diff
changeset
|
258 |
|
1 | 259 |
// out of memory reporting |
260 |
void report_java_out_of_memory(const char* message); |
|
261 |
||
262 |
// Support for self-destruct |
|
263 |
bool is_error_reported(); |
|
264 |
void set_error_reported(); |
|
265 |
||
28477 | 266 |
/* Test vmassert(), fatal(), guarantee(), etc. */ |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
17087
diff
changeset
|
267 |
NOT_PRODUCT(void test_error_handler();) |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
1
diff
changeset
|
268 |
|
28943
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
269 |
// crash in a controlled way: |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
270 |
// how can be one of: |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
271 |
// 1,2 - asserts |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
272 |
// 3,4 - guarantee |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
273 |
// 5-7 - fatal |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
274 |
// 8 - vm_exit_out_of_memory |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
275 |
// 9 - ShouldNotCallThis |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
276 |
// 10 - ShouldNotReachHere |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
277 |
// 11 - Unimplemented |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
278 |
// 12,13 - (not guaranteed) crashes |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
279 |
// 14 - SIGSEGV |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
280 |
// 15 - SIGFPE |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
281 |
NOT_PRODUCT(void controlled_crash(int how);) |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
282 |
|
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
283 |
// returns an address which is guaranteed to generate a SIGSEGV on read, |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
284 |
// for test purposes, which is not NULL and contains bits in every word |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
285 |
NOT_PRODUCT(void* get_segfault_address();) |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28485
diff
changeset
|
286 |
|
1 | 287 |
void pd_ps(frame f); |
288 |
void pd_obfuscate_location(char *buf, size_t buflen); |
|
7397 | 289 |
|
26821
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
24424
diff
changeset
|
290 |
class outputStream; |
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
24424
diff
changeset
|
291 |
void print_native_stack(outputStream* st, frame fr, Thread* t, char* buf, int buf_size); |
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
24424
diff
changeset
|
292 |
|
7397 | 293 |
#endif // SHARE_VM_UTILITIES_DEBUG_HPP |