Mercurial > hg > truffle
annotate src/share/vm/utilities/debug.hpp @ 17541:4aa6fa2864af
Merge
author | asaha |
---|---|
date | Thu, 23 Jan 2014 14:50:08 -0800 |
parents | 9766f73e770d |
children | 3cce976666d9 e2722a66aba7 |
rev | line source |
---|---|
0 | 1 /* |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
10161
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_DEBUG_HPP |
26 #define SHARE_VM_UTILITIES_DEBUG_HPP | |
27 | |
2361 | 28 #include "prims/jvm.h" |
1972 | 29 #include "utilities/globalDefinitions.hpp" |
30 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
31 #include <stdarg.h> |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
32 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
33 // Simple class to format the ctor arguments into a fixed-sized buffer. |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
34 class FormatBufferBase { |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
35 protected: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
36 char* _buf; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
37 inline FormatBufferBase(char* buf) : _buf(buf) {} |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
38 public: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
39 operator const char *() const { return _buf; } |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
40 }; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
41 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
42 // Use resource area for buffer |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
43 #define RES_BUFSZ 256 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
44 class FormatBufferResource : public FormatBufferBase { |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
45 public: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
46 FormatBufferResource(const char * format, ...); |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
47 }; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
48 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
49 // Use stack for buffer |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
50 template <size_t bufsz = 256> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
51 class FormatBuffer : public FormatBufferBase { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
52 public: |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
53 inline FormatBuffer(const char * format, ...); |
2152 | 54 inline void append(const char* format, ...); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
55 inline void print(const char* format, ...); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
56 inline void printv(const char* format, va_list ap); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
57 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
58 char* buffer() { return _buf; } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
59 int size() { return bufsz; } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
60 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
61 private: |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
62 FormatBuffer(const FormatBuffer &); // prevent copies |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
63 char _buffer[bufsz]; |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
64 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
65 protected: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
66 inline FormatBuffer(); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
67 }; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
68 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
69 template <size_t bufsz> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
70 FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) { |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
71 va_list argp; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
72 va_start(argp, format); |
2361 | 73 jio_vsnprintf(_buf, bufsz, format, argp); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
74 va_end(argp); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
75 } |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
76 |
2152 | 77 template <size_t bufsz> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
78 FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
79 _buf[0] = '\0'; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
80 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
81 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
82 template <size_t bufsz> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
83 void FormatBuffer<bufsz>::print(const char * format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
84 va_list argp; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
85 va_start(argp, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
86 jio_vsnprintf(_buf, bufsz, format, argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
87 va_end(argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
88 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
89 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
90 template <size_t bufsz> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
91 void FormatBuffer<bufsz>::printv(const char * format, va_list argp) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
92 jio_vsnprintf(_buf, bufsz, format, argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
93 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
94 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
95 template <size_t bufsz> |
2152 | 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); | |
2361 | 104 jio_vsnprintf(buf_end, bufsz - len, format, argp); |
2152 | 105 va_end(argp); |
106 } | |
107 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
108 // Used to format messages for assert(), guarantee(), fatal(), etc. |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
109 typedef FormatBuffer<> err_msg; |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
110 typedef FormatBufferResource err_msg_res; |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
111 |
0 | 112 // assertions |
113 #ifdef ASSERT | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
114 #ifndef USE_REPEATED_ASSERTS |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
115 #define assert(p, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
116 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
117 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
118 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
119 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
120 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
121 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
122 #else // #ifndef USE_REPEATED_ASSERTS |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
123 #define assert(p, msg) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
124 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
125 for (int __i = 0; __i < AssertRepeat; __i++) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
126 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
127 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
128 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
129 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
130 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
131 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
132 #endif // #ifndef USE_REPEATED_ASSERTS |
0 | 133 |
134 // This version of assert is for use with checking return status from | |
135 // library calls that return actual error values eg. EINVAL, | |
136 // ENOMEM etc, rather than returning -1 and setting errno. | |
137 // When the status is not what is expected it is very useful to know | |
138 // what status was actually returned, so we pass the status variable as | |
139 // an extra arg and use strerror to convert it to a meaningful string | |
140 // like "Invalid argument", "out of memory" etc | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
141 #define assert_status(p, status, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
142 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
143 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
144 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
145 err_msg("error %s(%d) %s", strerror(status), \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
146 status, msg)); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
147 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
148 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
149 } while (0) |
0 | 150 |
151 // Do not assert this condition if there's already another error reported. | |
152 #define assert_if_no_error(cond,msg) assert((cond) || is_error_reported(), msg) | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
153 #else // #ifdef ASSERT |
0 | 154 #define assert(p,msg) |
155 #define assert_status(p,status,msg) | |
156 #define assert_if_no_error(cond,msg) | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
157 #endif // #ifdef ASSERT |
0 | 158 |
159 // guarantee is like assert except it's always executed -- use it for | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
160 // cheap tests that catch errors that would otherwise be hard to find. |
0 | 161 // guarantee is also used for Verify options. |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
162 #define guarantee(p, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
163 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
164 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
165 report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
166 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
167 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
168 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
169 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
170 #define fatal(msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
171 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
172 report_fatal(__FILE__, __LINE__, msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
173 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
174 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
175 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
176 // out of memory |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
177 #define vm_exit_out_of_memory(size, vm_err_type, msg) \ |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
178 do { \ |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
179 report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, msg); \ |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
180 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
181 } while (0) |
0 | 182 |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
183 #define ShouldNotCallThis() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
184 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
185 report_should_not_call(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
186 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
187 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
188 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
189 #define ShouldNotReachHere() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
190 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
191 report_should_not_reach_here(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
192 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
193 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
194 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
195 #define Unimplemented() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
196 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
197 report_unimplemented(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
198 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
199 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
200 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
201 #define Untested(msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
202 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
203 report_untested(__FILE__, __LINE__, msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
204 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
205 } while (0); |
0 | 206 |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
207 |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
208 // types of VM error - originally in vmError.hpp |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
209 enum VMErrorType { |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
210 INTERNAL_ERROR = 0xe0000000, |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
211 OOM_MALLOC_ERROR = 0xe0000001, |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
212 OOM_MMAP_ERROR = 0xe0000002 |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
213 }; |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
214 |
0 | 215 // error reporting helper functions |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
216 void report_vm_error(const char* file, int line, const char* error_msg, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
217 const char* detail_msg = NULL); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
218 void report_fatal(const char* file, int line, const char* message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
219 void report_vm_out_of_memory(const char* file, int line, size_t size, |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
8769
diff
changeset
|
220 VMErrorType vm_err_type, const char* message); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
221 void report_should_not_call(const char* file, int line); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
222 void report_should_not_reach_here(const char* file, int line); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
223 void report_unimplemented(const char* file, int line); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
224 void report_untested(const char* file, int line, const char* message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
225 |
0 | 226 void warning(const char* format, ...); |
227 | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
228 #ifdef ASSERT |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
229 // Compile-time asserts. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
230 template <bool> struct StaticAssert; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
231 template <> struct StaticAssert<true> {}; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
232 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
233 // Only StaticAssert<true> is defined, so if cond evaluates to false we get |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
234 // a compile time exception when trying to use StaticAssert<false>. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
235 #define STATIC_ASSERT(cond) \ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
236 do { \ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
237 StaticAssert<(cond)> DUMMY_STATIC_ASSERT; \ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
238 (void)DUMMY_STATIC_ASSERT; /* ignore */ \ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
239 } while (false) |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
240 #else |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
241 #define STATIC_ASSERT(cond) |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
242 #endif |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
11092
diff
changeset
|
243 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
244 // out of shared space reporting |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
245 enum SharedSpaceType { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
246 SharedPermGen, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
247 SharedReadOnly, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
248 SharedReadWrite, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
249 SharedMiscData |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
250 }; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
251 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
252 void report_out_of_shared_space(SharedSpaceType space_type); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
253 |
0 | 254 // out of memory reporting |
255 void report_java_out_of_memory(const char* message); | |
256 | |
257 // Support for self-destruct | |
258 bool is_error_reported(); | |
259 void set_error_reported(); | |
260 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
261 /* Test assert(), fatal(), guarantee(), etc. */ |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
10161
diff
changeset
|
262 NOT_PRODUCT(void test_error_handler();) |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
263 |
0 | 264 void pd_ps(frame f); |
265 void pd_obfuscate_location(char *buf, size_t buflen); | |
1972 | 266 |
267 #endif // SHARE_VM_UTILITIES_DEBUG_HPP |