Mercurial > hg > truffle
annotate src/share/vm/utilities/debug.hpp @ 7521:d4bc143c575a
replaced use of <br> in javadoc with <p>
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 22 Jan 2013 21:06:57 +0100 |
parents | 679e6584c177 |
children | b8f261ba79c6 96a337d307bd |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
2 * Copyright (c) 1997, 2012, 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 |
6999
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
33 #ifdef GRAAL |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
34 // Scopes a value that may be of interest in a crash log. |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
35 class DebugScopedValue { |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
36 protected: |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
37 DebugScopedValue *_parent; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
38 const char* _file; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
39 int _line; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
40 public: |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
41 DebugScopedValue(const char* file, int line); |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
42 ~DebugScopedValue(); |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
43 void print(outputStream* st); |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
44 virtual void print_on(outputStream* st) = 0; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
45 DebugScopedValue* parent() { return _parent; } |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
46 }; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
47 |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
48 class DebugScopedScalar : DebugScopedValue { |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
49 private: |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
50 void* _value; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
51 public: |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
52 DebugScopedScalar(const char* file, int line, void* v) : DebugScopedValue(file, line), _value(v) {} |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
53 void print_on(outputStream* st); |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
54 }; |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
55 #define DS_SCALAR(val) DebugScopedScalar __dss__(__FILE__, __LINE__, (void*) val) |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
56 #define DS_SCALAR1(name, val) DebugScopedScalar name(__FILE__, __LINE__, (void*) val) |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
57 #else |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
58 #define DS_SCALAR(name) do {} while (0) |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
59 #define DS_SCALAR1(name, val) do {} while (0) |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
60 #endif |
679e6584c177
added ScopedDebugValue to add values of interest to hs_err crash logs
Doug Simon <doug.simon@oracle.com>
parents:
6725
diff
changeset
|
61 |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
62 // 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
|
63 class FormatBufferBase { |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
64 protected: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
65 char* _buf; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
66 inline FormatBufferBase(char* buf) : _buf(buf) {} |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
67 public: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
68 operator const char *() const { return _buf; } |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
69 }; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
70 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
71 // Use resource area for buffer |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
72 #define RES_BUFSZ 256 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
73 class FormatBufferResource : public FormatBufferBase { |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
74 public: |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
75 FormatBufferResource(const char * format, ...); |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
76 }; |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
77 |
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
78 // Use stack for buffer |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
79 template <size_t bufsz = 256> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
80 class FormatBuffer : public FormatBufferBase { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
81 public: |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
82 inline FormatBuffer(const char * format, ...); |
2152 | 83 inline void append(const char* format, ...); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
84 inline void print(const char* format, ...); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
85 inline void printv(const char* format, va_list ap); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
86 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
87 char* buffer() { return _buf; } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
88 int size() { return bufsz; } |
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 private: |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
91 FormatBuffer(const FormatBuffer &); // prevent copies |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
92 char _buffer[bufsz]; |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
93 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
94 protected: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
95 inline FormatBuffer(); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
96 }; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
97 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
98 template <size_t bufsz> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
99 FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) { |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
100 va_list argp; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
101 va_start(argp, format); |
2361 | 102 jio_vsnprintf(_buf, bufsz, format, argp); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
103 va_end(argp); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
104 } |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
105 |
2152 | 106 template <size_t bufsz> |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
107 FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
108 _buf[0] = '\0'; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
109 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
110 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
111 template <size_t bufsz> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
112 void FormatBuffer<bufsz>::print(const char * format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
113 va_list argp; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
114 va_start(argp, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
115 jio_vsnprintf(_buf, bufsz, format, argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
116 va_end(argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
117 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
118 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
119 template <size_t bufsz> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
120 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
|
121 jio_vsnprintf(_buf, bufsz, format, argp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
122 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
123 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
2426
diff
changeset
|
124 template <size_t bufsz> |
2152 | 125 void FormatBuffer<bufsz>::append(const char* format, ...) { |
126 // Given that the constructor does a vsnprintf we can assume that | |
127 // _buf is already initialized. | |
128 size_t len = strlen(_buf); | |
129 char* buf_end = _buf + len; | |
130 | |
131 va_list argp; | |
132 va_start(argp, format); | |
2361 | 133 jio_vsnprintf(buf_end, bufsz - len, format, argp); |
2152 | 134 va_end(argp); |
135 } | |
136 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
137 // Used to format messages for assert(), guarantee(), fatal(), etc. |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
138 typedef FormatBuffer<> err_msg; |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
4872
diff
changeset
|
139 typedef FormatBufferResource err_msg_res; |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
140 |
0 | 141 // assertions |
142 #ifdef ASSERT | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
143 #ifndef USE_REPEATED_ASSERTS |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
144 #define assert(p, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
145 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
146 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
147 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
148 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
149 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
150 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
151 #else // #ifndef USE_REPEATED_ASSERTS |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
152 #define assert(p, msg) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
153 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
154 for (int __i = 0; __i < AssertRepeat; __i++) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
155 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
156 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
157 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
158 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
159 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
160 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
161 #endif // #ifndef USE_REPEATED_ASSERTS |
0 | 162 |
163 // This version of assert is for use with checking return status from | |
164 // library calls that return actual error values eg. EINVAL, | |
165 // ENOMEM etc, rather than returning -1 and setting errno. | |
166 // When the status is not what is expected it is very useful to know | |
167 // what status was actually returned, so we pass the status variable as | |
168 // an extra arg and use strerror to convert it to a meaningful string | |
169 // like "Invalid argument", "out of memory" etc | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
170 #define assert_status(p, status, 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 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
173 report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
174 err_msg("error %s(%d) %s", strerror(status), \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
175 status, msg)); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
176 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
177 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
178 } while (0) |
0 | 179 |
180 // Do not assert this condition if there's already another error reported. | |
181 #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
|
182 #else // #ifdef ASSERT |
0 | 183 #define assert(p,msg) |
184 #define assert_status(p,status,msg) | |
185 #define assert_if_no_error(cond,msg) | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
186 #endif // #ifdef ASSERT |
0 | 187 |
188 // 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
|
189 // cheap tests that catch errors that would otherwise be hard to find. |
0 | 190 // guarantee is also used for Verify options. |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
191 #define guarantee(p, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
192 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
193 if (!(p)) { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
194 report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
195 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
196 } \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
197 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
198 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
199 #define fatal(msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
200 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
201 report_fatal(__FILE__, __LINE__, msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
202 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
203 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
204 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
205 // out of memory |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
206 #define vm_exit_out_of_memory(size, msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
207 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
208 report_vm_out_of_memory(__FILE__, __LINE__, size, msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
209 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
210 } while (0) |
0 | 211 |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
212 #define ShouldNotCallThis() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
213 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
214 report_should_not_call(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
215 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
216 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
217 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
218 #define ShouldNotReachHere() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
219 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
220 report_should_not_reach_here(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
221 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
222 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
223 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
224 #define ShouldNotReachHere2(message) \ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
225 do { \ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
226 report_should_not_reach_here2(__FILE__, __LINE__, message); \ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
227 BREAKPOINT; \ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
228 } while (0) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
229 |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
230 #define Unimplemented() \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
231 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
232 report_unimplemented(__FILE__, __LINE__); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
233 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
234 } while (0) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
235 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
236 #define Untested(msg) \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
237 do { \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
238 report_untested(__FILE__, __LINE__, msg); \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
239 BREAKPOINT; \ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
240 } while (0); |
0 | 241 |
242 // error reporting helper functions | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
243 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
|
244 const char* detail_msg = NULL); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
245 void report_fatal(const char* file, int line, const char* message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
246 void report_vm_out_of_memory(const char* file, int line, size_t size, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
247 const char* message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
248 void report_should_not_call(const char* file, int line); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
249 void report_should_not_reach_here(const char* file, int line); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6268
diff
changeset
|
250 void report_should_not_reach_here2(const char* file, int line, const char* message); |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
251 void report_unimplemented(const char* file, int line); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
252 void report_untested(const char* file, int line, const char* message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
253 |
0 | 254 void warning(const char* format, ...); |
255 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
256 // out of shared space reporting |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
257 enum SharedSpaceType { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
258 SharedPermGen, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
259 SharedReadOnly, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
260 SharedReadWrite, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
261 SharedMiscData |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
262 }; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
263 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2152
diff
changeset
|
264 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
|
265 |
0 | 266 // out of memory reporting |
267 void report_java_out_of_memory(const char* message); | |
268 | |
269 // Support for self-destruct | |
270 bool is_error_reported(); | |
271 void set_error_reported(); | |
272 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
273 /* Test assert(), fatal(), guarantee(), etc. */ |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
274 NOT_PRODUCT(void test_error_handler(size_t test_num);) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
0
diff
changeset
|
275 |
0 | 276 void pd_ps(frame f); |
277 void pd_obfuscate_location(char *buf, size_t buflen); | |
1972 | 278 |
279 #endif // SHARE_VM_UTILITIES_DEBUG_HPP |