author | twisti |
Tue, 04 Sep 2012 18:01:20 -0700 | |
changeset 13732 | a9865f5514fc |
parent 13728 | 882756847a04 |
child 13761 | 46489cdfa479 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10739
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, 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 |
#include "precompiled.hpp" |
26 |
#include "classfile/systemDictionary.hpp" |
|
27 |
#include "code/codeCache.hpp" |
|
28 |
#include "code/icBuffer.hpp" |
|
29 |
#include "code/nmethod.hpp" |
|
30 |
#include "code/vtableStubs.hpp" |
|
31 |
#include "compiler/compileBroker.hpp" |
|
32 |
#include "compiler/disassembler.hpp" |
|
33 |
#include "gc_implementation/shared/markSweep.hpp" |
|
34 |
#include "gc_interface/collectedHeap.hpp" |
|
35 |
#include "interpreter/bytecodeHistogram.hpp" |
|
36 |
#include "interpreter/interpreter.hpp" |
|
37 |
#include "memory/resourceArea.hpp" |
|
38 |
#include "memory/universe.hpp" |
|
39 |
#include "oops/oop.inline.hpp" |
|
40 |
#include "prims/privilegedStack.hpp" |
|
41 |
#include "runtime/arguments.hpp" |
|
42 |
#include "runtime/frame.hpp" |
|
43 |
#include "runtime/java.hpp" |
|
44 |
#include "runtime/sharedRuntime.hpp" |
|
45 |
#include "runtime/stubCodeGenerator.hpp" |
|
46 |
#include "runtime/stubRoutines.hpp" |
|
47 |
#include "runtime/vframe.hpp" |
|
48 |
#include "services/heapDumper.hpp" |
|
49 |
#include "utilities/defaultStream.hpp" |
|
50 |
#include "utilities/events.hpp" |
|
51 |
#include "utilities/top.hpp" |
|
52 |
#include "utilities/vmError.hpp" |
|
53 |
#ifdef TARGET_OS_FAMILY_linux |
|
54 |
# include "os_linux.inline.hpp" |
|
55 |
# include "thread_linux.inline.hpp" |
|
56 |
#endif |
|
57 |
#ifdef TARGET_OS_FAMILY_solaris |
|
58 |
# include "os_solaris.inline.hpp" |
|
59 |
# include "thread_solaris.inline.hpp" |
|
60 |
#endif |
|
61 |
#ifdef TARGET_OS_FAMILY_windows |
|
62 |
# include "os_windows.inline.hpp" |
|
63 |
# include "thread_windows.inline.hpp" |
|
64 |
#endif |
|
10565 | 65 |
#ifdef TARGET_OS_FAMILY_bsd |
66 |
# include "os_bsd.inline.hpp" |
|
67 |
# include "thread_bsd.inline.hpp" |
|
68 |
#endif |
|
1 | 69 |
|
70 |
#ifndef ASSERT |
|
71 |
# ifdef _DEBUG |
|
72 |
// NOTE: don't turn the lines below into a comment -- if you're getting |
|
73 |
// a compile error here, change the settings to define ASSERT |
|
74 |
ASSERT should be defined when _DEBUG is defined. It is not intended to be used for debugging |
|
75 |
functions that do not slow down the system too much and thus can be left in optimized code. |
|
76 |
On the other hand, the code should not be included in a production version. |
|
77 |
# endif // _DEBUG |
|
78 |
#endif // ASSERT |
|
79 |
||
80 |
||
81 |
#ifdef _DEBUG |
|
82 |
# ifndef ASSERT |
|
83 |
configuration error: ASSERT must be defined in debug version |
|
84 |
# endif // ASSERT |
|
85 |
#endif // _DEBUG |
|
86 |
||
87 |
||
88 |
#ifdef PRODUCT |
|
89 |
# if -defined _DEBUG || -defined ASSERT |
|
90 |
configuration error: ASSERT et al. must not be defined in PRODUCT version |
|
91 |
# endif |
|
92 |
#endif // PRODUCT |
|
93 |
||
13393
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
94 |
FormatBufferResource::FormatBufferResource(const char * format, ...) |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
95 |
: FormatBufferBase((char*)resource_allocate_bytes(RES_BUFSZ)) { |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
96 |
va_list argp; |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
97 |
va_start(argp, format); |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
98 |
jio_vsnprintf(_buf, RES_BUFSZ, format, argp); |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
99 |
va_end(argp); |
f0344cc50a90
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
11788
diff
changeset
|
100 |
} |
1 | 101 |
|
102 |
void warning(const char* format, ...) { |
|
6967
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
103 |
if (PrintWarnings) { |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
104 |
// In case error happens before init or during shutdown |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
105 |
if (tty == NULL) ostream_init(); |
1 | 106 |
|
6967
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
107 |
tty->print("%s warning: ", VM_Version::vm_name()); |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
108 |
va_list ap; |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
109 |
va_start(ap, format); |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
110 |
tty->vprint_cr(format, ap); |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
111 |
va_end(ap); |
c5ebdcf8372e
6392697: Additional flag needed to supress Hotspot warning messages
kamg
parents:
6445
diff
changeset
|
112 |
} |
1 | 113 |
if (BreakAtWarning) BREAKPOINT; |
114 |
} |
|
115 |
||
116 |
#ifndef PRODUCT |
|
117 |
||
118 |
#define is_token_break(ch) (isspace(ch) || (ch) == ',') |
|
119 |
||
120 |
static const char* last_file_name = NULL; |
|
121 |
static int last_line_no = -1; |
|
122 |
||
123 |
// assert/guarantee/... may happen very early during VM initialization. |
|
124 |
// Don't rely on anything that is initialized by Threads::create_vm(). For |
|
125 |
// example, don't use tty. |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
126 |
bool error_is_suppressed(const char* file_name, int line_no) { |
1 | 127 |
// The following 1-element cache requires that passed-in |
128 |
// file names are always only constant literals. |
|
129 |
if (file_name == last_file_name && line_no == last_line_no) return true; |
|
130 |
||
131 |
int file_name_len = (int)strlen(file_name); |
|
132 |
char separator = os::file_separator()[0]; |
|
133 |
const char* base_name = strrchr(file_name, separator); |
|
134 |
if (base_name == NULL) |
|
135 |
base_name = file_name; |
|
136 |
||
137 |
// scan the SuppressErrorAt option |
|
138 |
const char* cp = SuppressErrorAt; |
|
139 |
for (;;) { |
|
140 |
const char* sfile; |
|
141 |
int sfile_len; |
|
142 |
int sline; |
|
143 |
bool noisy; |
|
144 |
while ((*cp) != '\0' && is_token_break(*cp)) cp++; |
|
145 |
if ((*cp) == '\0') break; |
|
146 |
sfile = cp; |
|
147 |
while ((*cp) != '\0' && !is_token_break(*cp) && (*cp) != ':') cp++; |
|
148 |
sfile_len = cp - sfile; |
|
149 |
if ((*cp) == ':') cp++; |
|
150 |
sline = 0; |
|
151 |
while ((*cp) != '\0' && isdigit(*cp)) { |
|
152 |
sline *= 10; |
|
153 |
sline += (*cp) - '0'; |
|
154 |
cp++; |
|
155 |
} |
|
156 |
// "file:line!" means the assert suppression is not silent |
|
157 |
noisy = ((*cp) == '!'); |
|
158 |
while ((*cp) != '\0' && !is_token_break(*cp)) cp++; |
|
159 |
// match the line |
|
160 |
if (sline != 0) { |
|
161 |
if (sline != line_no) continue; |
|
162 |
} |
|
163 |
// match the file |
|
164 |
if (sfile_len > 0) { |
|
165 |
const char* look = file_name; |
|
166 |
const char* look_max = file_name + file_name_len - sfile_len; |
|
167 |
const char* foundp; |
|
168 |
bool match = false; |
|
169 |
while (!match |
|
170 |
&& (foundp = strchr(look, sfile[0])) != NULL |
|
171 |
&& foundp <= look_max) { |
|
172 |
match = true; |
|
173 |
for (int i = 1; i < sfile_len; i++) { |
|
174 |
if (sfile[i] != foundp[i]) { |
|
175 |
match = false; |
|
176 |
break; |
|
177 |
} |
|
178 |
} |
|
179 |
look = foundp + 1; |
|
180 |
} |
|
181 |
if (!match) continue; |
|
182 |
} |
|
183 |
// got a match! |
|
184 |
if (noisy) { |
|
185 |
fdStream out(defaultStream::output_fd()); |
|
186 |
out.print_raw("[error suppressed at "); |
|
187 |
out.print_raw(base_name); |
|
188 |
char buf[16]; |
|
189 |
jio_snprintf(buf, sizeof(buf), ":%d]", line_no); |
|
190 |
out.print_raw_cr(buf); |
|
191 |
} else { |
|
192 |
// update 1-element cache for fast silent matches |
|
193 |
last_file_name = file_name; |
|
194 |
last_line_no = line_no; |
|
195 |
} |
|
196 |
return true; |
|
197 |
} |
|
198 |
||
199 |
if (!is_error_reported()) { |
|
200 |
// print a friendly hint: |
|
201 |
fdStream out(defaultStream::output_fd()); |
|
202 |
out.print_raw_cr("# To suppress the following error report, specify this argument"); |
|
203 |
out.print_raw ("# after -XX: or in .hotspotrc: SuppressErrorAt="); |
|
204 |
out.print_raw (base_name); |
|
205 |
char buf[16]; |
|
206 |
jio_snprintf(buf, sizeof(buf), ":%d", line_no); |
|
207 |
out.print_raw_cr(buf); |
|
208 |
} |
|
209 |
return false; |
|
210 |
} |
|
211 |
||
212 |
#undef is_token_break |
|
213 |
||
214 |
#else |
|
215 |
||
216 |
// Place-holder for non-existent suppression check: |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
217 |
#define error_is_suppressed(file_name, line_no) (false) |
1 | 218 |
|
10739 | 219 |
#endif // !PRODUCT |
1 | 220 |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
221 |
void report_vm_error(const char* file, int line, const char* error_msg, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
222 |
const char* detail_msg) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
223 |
{ |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
224 |
if (Debugging || error_is_suppressed(file, line)) return; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
225 |
Thread* const thread = ThreadLocalStorage::get_thread_slow(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
226 |
VMError err(thread, file, line, error_msg, detail_msg); |
1 | 227 |
err.report_and_die(); |
228 |
} |
|
229 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
230 |
void report_fatal(const char* file, int line, const char* message) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
231 |
{ |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
232 |
report_vm_error(file, line, "fatal error", message); |
1 | 233 |
} |
234 |
||
235 |
// Used by report_vm_out_of_memory to detect recursion. |
|
236 |
static jint _exiting_out_of_mem = 0; |
|
237 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
238 |
void report_vm_out_of_memory(const char* file, int line, size_t size, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
239 |
const char* message) { |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7433
diff
changeset
|
240 |
if (Debugging) return; |
1 | 241 |
|
242 |
// We try to gather additional information for the first out of memory |
|
243 |
// error only; gathering additional data might cause an allocation and a |
|
244 |
// recursive out_of_memory condition. |
|
245 |
||
246 |
const jint exiting = 1; |
|
247 |
// If we succeed in changing the value, we're the first one in. |
|
248 |
bool first_time_here = Atomic::xchg(exiting, &_exiting_out_of_mem) != exiting; |
|
249 |
||
250 |
if (first_time_here) { |
|
251 |
Thread* thread = ThreadLocalStorage::get_thread_slow(); |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
252 |
VMError(thread, file, line, size, message).report_and_die(); |
1 | 253 |
} |
773
01daf7c809b1
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
360
diff
changeset
|
254 |
|
01daf7c809b1
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
360
diff
changeset
|
255 |
// Dump core and abort |
01daf7c809b1
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
360
diff
changeset
|
256 |
vm_abort(true); |
1 | 257 |
} |
258 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
259 |
void report_should_not_call(const char* file, int line) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
260 |
report_vm_error(file, line, "ShouldNotCall()"); |
1 | 261 |
} |
262 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
263 |
void report_should_not_reach_here(const char* file, int line) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
264 |
report_vm_error(file, line, "ShouldNotReachHere()"); |
1 | 265 |
} |
266 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
267 |
void report_should_not_reach_here2(const char* file, int line, const char* message) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
268 |
report_vm_error(file, line, "ShouldNotReachHere()", message); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
269 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
270 |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
271 |
void report_unimplemented(const char* file, int line) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
272 |
report_vm_error(file, line, "Unimplemented()"); |
1 | 273 |
} |
274 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
275 |
void report_untested(const char* file, int line, const char* message) { |
1 | 276 |
#ifndef PRODUCT |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
277 |
warning("Untested: %s in %s: %d\n", message, file, line); |
10739 | 278 |
#endif // !PRODUCT |
1 | 279 |
} |
280 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
281 |
void report_out_of_shared_space(SharedSpaceType shared_space) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
282 |
static const char* name[] = { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
283 |
"native memory for metadata", |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
284 |
"shared read only space", |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
285 |
"shared read write space", |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
286 |
"shared miscellaneous data space" |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
287 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
288 |
static const char* flag[] = { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
289 |
"Metaspace", |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
290 |
"SharedReadOnlySize", |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
291 |
"SharedReadWriteSize", |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
292 |
"SharedMiscDataSize" |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
293 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
294 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
295 |
warning("\nThe %s is not large enough\n" |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
296 |
"to preload requested classes. Use -XX:%s=\n" |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
297 |
"to increase the initial size of %s.\n", |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
298 |
name[shared_space], flag[shared_space], name[shared_space]); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
299 |
exit(2); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
300 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7719
diff
changeset
|
301 |
|
1 | 302 |
void report_java_out_of_memory(const char* message) { |
303 |
static jint out_of_memory_reported = 0; |
|
304 |
||
305 |
// A number of threads may attempt to report OutOfMemoryError at around the |
|
306 |
// same time. To avoid dumping the heap or executing the data collection |
|
307 |
// commands multiple times we just do it once when the first threads reports |
|
308 |
// the error. |
|
309 |
if (Atomic::cmpxchg(1, &out_of_memory_reported, 0) == 0) { |
|
310 |
// create heap dump before OnOutOfMemoryError commands are executed |
|
311 |
if (HeapDumpOnOutOfMemoryError) { |
|
312 |
tty->print_cr("java.lang.OutOfMemoryError: %s", message); |
|
6445
64694b1e56e7
6765718: Indicate which thread throwing OOME when generating the heap dump at OOME
thurka
parents:
6176
diff
changeset
|
313 |
HeapDumper::dump_heap_from_oome(); |
1 | 314 |
} |
315 |
||
316 |
if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { |
|
317 |
VMError err(message); |
|
318 |
err.report_java_out_of_memory(); |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
static bool error_reported = false; |
|
324 |
||
325 |
// call this when the VM is dying--it might loosen some asserts |
|
326 |
void set_error_reported() { |
|
327 |
error_reported = true; |
|
328 |
} |
|
329 |
||
330 |
bool is_error_reported() { |
|
331 |
return error_reported; |
|
332 |
} |
|
333 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
334 |
#ifndef PRODUCT |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
335 |
#include <signal.h> |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
336 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
337 |
void test_error_handler(size_t test_num) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
338 |
{ |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
339 |
if (test_num == 0) return; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
340 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
341 |
// If asserts are disabled, use the corresponding guarantee instead. |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
342 |
size_t n = test_num; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
343 |
NOT_DEBUG(if (n <= 2) n += 2); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
344 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
345 |
const char* const str = "hello"; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
346 |
const size_t num = (size_t)os::vm_page_size(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
347 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
348 |
const char* const eol = os::line_separator(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
349 |
const char* const msg = "this message should be truncated during formatting"; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
350 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
351 |
// Keep this in sync with test/runtime/6888954/vmerrors.sh. |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
352 |
switch (n) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
353 |
case 1: assert(str == NULL, "expected null"); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
354 |
case 2: assert(num == 1023 && *str == 'X', |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
355 |
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
356 |
case 3: guarantee(str == NULL, "expected null"); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
357 |
case 4: guarantee(num == 1023 && *str == 'X', |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
358 |
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
359 |
case 5: fatal("expected null"); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
360 |
case 6: fatal(err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str)); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
361 |
case 7: fatal(err_msg("%s%s# %s%s# %s%s# %s%s# %s%s# " |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
362 |
"%s%s# %s%s# %s%s# %s%s# %s%s# " |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
363 |
"%s%s# %s%s# %s%s# %s%s# %s", |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
364 |
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
365 |
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
366 |
msg, eol, msg, eol, msg, eol, msg, eol, msg)); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
367 |
case 8: vm_exit_out_of_memory(num, "ChunkPool::allocate"); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
368 |
case 9: ShouldNotCallThis(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
369 |
case 10: ShouldNotReachHere(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
370 |
case 11: Unimplemented(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
371 |
// This is last because it does not generate an hs_err* file on Windows. |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
372 |
case 12: os::signal_raise(SIGSEGV); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
373 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
374 |
default: ShouldNotReachHere(); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
375 |
} |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
376 |
} |
10739 | 377 |
#endif // !PRODUCT |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
3908
diff
changeset
|
378 |
|
1 | 379 |
// ------ helper functions for debugging go here ------------ |
380 |
||
381 |
// All debug entries should be wrapped with a stack allocated |
|
382 |
// Command object. It makes sure a resource mark is set and |
|
383 |
// flushes the logfile to prevent file sharing problems. |
|
384 |
||
385 |
class Command : public StackObj { |
|
386 |
private: |
|
387 |
ResourceMark rm; |
|
388 |
ResetNoHandleMark rnhm; |
|
389 |
HandleMark hm; |
|
390 |
bool debug_save; |
|
391 |
public: |
|
392 |
static int level; |
|
393 |
Command(const char* str) { |
|
394 |
debug_save = Debugging; |
|
395 |
Debugging = true; |
|
396 |
if (level++ > 0) return; |
|
397 |
tty->cr(); |
|
398 |
tty->print_cr("\"Executing %s\"", str); |
|
399 |
} |
|
400 |
||
10739 | 401 |
~Command() { |
402 |
tty->flush(); |
|
403 |
Debugging = debug_save; |
|
404 |
level--; |
|
405 |
} |
|
1 | 406 |
}; |
407 |
||
408 |
int Command::level = 0; |
|
409 |
||
10739 | 410 |
#ifndef PRODUCT |
411 |
||
1 | 412 |
extern "C" void blob(CodeBlob* cb) { |
413 |
Command c("blob"); |
|
414 |
cb->print(); |
|
415 |
} |
|
416 |
||
417 |
||
418 |
extern "C" void dump_vtable(address p) { |
|
419 |
Command c("dump_vtable"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
420 |
Klass* k = (Klass*)p; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
421 |
InstanceKlass::cast(k)->vtable()->print(); |
1 | 422 |
} |
423 |
||
424 |
||
425 |
extern "C" void nm(intptr_t p) { |
|
426 |
// Actually we look through all CodeBlobs (the nm name has been kept for backwards compatability) |
|
427 |
Command c("nm"); |
|
428 |
CodeBlob* cb = CodeCache::find_blob((address)p); |
|
429 |
if (cb == NULL) { |
|
430 |
tty->print_cr("NULL"); |
|
431 |
} else { |
|
432 |
cb->print(); |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
||
437 |
extern "C" void disnm(intptr_t p) { |
|
438 |
Command c("disnm"); |
|
439 |
CodeBlob* cb = CodeCache::find_blob((address) p); |
|
7433 | 440 |
nmethod* nm = cb->as_nmethod_or_null(); |
441 |
if (nm) { |
|
442 |
nm->print(); |
|
443 |
Disassembler::decode(nm); |
|
444 |
} else { |
|
445 |
cb->print(); |
|
446 |
Disassembler::decode(cb); |
|
447 |
} |
|
1 | 448 |
} |
449 |
||
450 |
||
451 |
extern "C" void printnm(intptr_t p) { |
|
452 |
char buffer[256]; |
|
453 |
sprintf(buffer, "printnm: " INTPTR_FORMAT, p); |
|
454 |
Command c(buffer); |
|
455 |
CodeBlob* cb = CodeCache::find_blob((address) p); |
|
456 |
if (cb->is_nmethod()) { |
|
457 |
nmethod* nm = (nmethod*)cb; |
|
458 |
nm->print_nmethod(true); |
|
459 |
} |
|
460 |
} |
|
461 |
||
462 |
||
463 |
extern "C" void universe() { |
|
464 |
Command c("universe"); |
|
465 |
Universe::print(); |
|
466 |
} |
|
467 |
||
468 |
||
469 |
extern "C" void verify() { |
|
470 |
// try to run a verify on the entire system |
|
471 |
// note: this may not be safe if we're not at a safepoint; for debugging, |
|
472 |
// this manipulates the safepoint settings to avoid assertion failures |
|
473 |
Command c("universe verify"); |
|
474 |
bool safe = SafepointSynchronize::is_at_safepoint(); |
|
475 |
if (!safe) { |
|
476 |
tty->print_cr("warning: not at safepoint -- verify may fail"); |
|
477 |
SafepointSynchronize::set_is_at_safepoint(); |
|
478 |
} |
|
479 |
// Ensure Eden top is correct before verification |
|
480 |
Universe::heap()->prepare_for_verify(); |
|
481 |
Universe::verify(true); |
|
482 |
if (!safe) SafepointSynchronize::set_is_not_at_safepoint(); |
|
483 |
} |
|
484 |
||
485 |
||
486 |
extern "C" void pp(void* p) { |
|
487 |
Command c("pp"); |
|
488 |
FlagSetting fl(PrintVMMessages, true); |
|
9437
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
489 |
FlagSetting f2(DisplayVMOutput, true); |
1 | 490 |
if (Universe::heap()->is_in(p)) { |
491 |
oop obj = oop(p); |
|
492 |
obj->print(); |
|
493 |
} else { |
|
10739 | 494 |
tty->print(PTR_FORMAT, p); |
1 | 495 |
} |
496 |
} |
|
497 |
||
498 |
||
499 |
// pv: print vm-printable object |
|
500 |
extern "C" void pa(intptr_t p) { ((AllocatedObj*) p)->print(); } |
|
501 |
extern "C" void findpc(intptr_t x); |
|
502 |
||
10739 | 503 |
#endif // !PRODUCT |
504 |
||
1 | 505 |
extern "C" void ps() { // print stack |
10739 | 506 |
if (Thread::current() == NULL) return; |
1 | 507 |
Command c("ps"); |
508 |
||
509 |
||
510 |
// Prints the stack of the current Java thread |
|
511 |
JavaThread* p = JavaThread::active(); |
|
512 |
tty->print(" for thread: "); |
|
513 |
p->print(); |
|
514 |
tty->cr(); |
|
515 |
||
516 |
if (p->has_last_Java_frame()) { |
|
517 |
// If the last_Java_fp is set we are in C land and |
|
518 |
// can call the standard stack_trace function. |
|
10739 | 519 |
#ifdef PRODUCT |
520 |
p->print_stack(); |
|
521 |
} else { |
|
522 |
tty->print_cr("Cannot find the last Java frame, printing stack disabled."); |
|
523 |
#else // !PRODUCT |
|
1 | 524 |
p->trace_stack(); |
525 |
} else { |
|
526 |
frame f = os::current_frame(); |
|
527 |
RegisterMap reg_map(p); |
|
528 |
f = f.sender(®_map); |
|
529 |
tty->print("(guessing starting frame id=%#p based on current fp)\n", f.id()); |
|
530 |
p->trace_stack_from(vframe::new_vframe(&f, ®_map, p)); |
|
531 |
pd_ps(f); |
|
10739 | 532 |
#endif // PRODUCT |
1 | 533 |
} |
534 |
||
535 |
} |
|
536 |
||
9437
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
537 |
extern "C" void pfl() { |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
538 |
// print frame layout |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
539 |
Command c("pfl"); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
540 |
JavaThread* p = JavaThread::active(); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
541 |
tty->print(" for thread: "); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
542 |
p->print(); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
543 |
tty->cr(); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
544 |
if (p->has_last_Java_frame()) { |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
545 |
p->print_frame_layout(); |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
546 |
} |
9981851b4b8c
7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
never
parents:
8921
diff
changeset
|
547 |
} |
1 | 548 |
|
10739 | 549 |
#ifndef PRODUCT |
550 |
||
1 | 551 |
extern "C" void psf() { // print stack frames |
552 |
{ |
|
553 |
Command c("psf"); |
|
554 |
JavaThread* p = JavaThread::active(); |
|
555 |
tty->print(" for thread: "); |
|
556 |
p->print(); |
|
557 |
tty->cr(); |
|
558 |
if (p->has_last_Java_frame()) { |
|
559 |
p->trace_frames(); |
|
560 |
} |
|
561 |
} |
|
562 |
} |
|
563 |
||
564 |
||
565 |
extern "C" void threads() { |
|
566 |
Command c("threads"); |
|
567 |
Threads::print(false, true); |
|
568 |
} |
|
569 |
||
570 |
||
571 |
extern "C" void psd() { |
|
572 |
Command c("psd"); |
|
573 |
SystemDictionary::print(); |
|
574 |
} |
|
575 |
||
576 |
||
577 |
extern "C" void safepoints() { |
|
578 |
Command c("safepoints"); |
|
579 |
SafepointSynchronize::print_state(); |
|
580 |
} |
|
581 |
||
10739 | 582 |
#endif // !PRODUCT |
1 | 583 |
|
584 |
extern "C" void pss() { // print all stacks |
|
10739 | 585 |
if (Thread::current() == NULL) return; |
1 | 586 |
Command c("pss"); |
10739 | 587 |
Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true)); |
1 | 588 |
} |
589 |
||
10739 | 590 |
#ifndef PRODUCT |
1 | 591 |
|
592 |
extern "C" void debug() { // to set things up for compiler debugging |
|
593 |
Command c("debug"); |
|
594 |
WizardMode = true; |
|
595 |
PrintVMMessages = PrintCompilation = true; |
|
596 |
PrintInlining = PrintAssembly = true; |
|
597 |
tty->flush(); |
|
598 |
} |
|
599 |
||
600 |
||
601 |
extern "C" void ndebug() { // undo debug() |
|
602 |
Command c("ndebug"); |
|
603 |
PrintCompilation = false; |
|
604 |
PrintInlining = PrintAssembly = false; |
|
605 |
tty->flush(); |
|
606 |
} |
|
607 |
||
608 |
||
609 |
extern "C" void flush() { |
|
610 |
Command c("flush"); |
|
611 |
tty->flush(); |
|
612 |
} |
|
613 |
||
11788 | 614 |
extern "C" void events() { |
615 |
Command c("events"); |
|
616 |
Events::print(); |
|
617 |
} |
|
1 | 618 |
|
619 |
// Given a heap address that was valid before the most recent GC, if |
|
620 |
// the oop that used to contain it is still live, prints the new |
|
621 |
// location of the oop and the address. Useful for tracking down |
|
622 |
// certain kinds of naked oop and oop map bugs. |
|
623 |
extern "C" void pnl(intptr_t old_heap_addr) { |
|
624 |
// Print New Location of old heap address |
|
625 |
Command c("pnl"); |
|
626 |
#ifndef VALIDATE_MARK_SWEEP |
|
627 |
tty->print_cr("Requires build with VALIDATE_MARK_SWEEP defined (debug build) and RecordMarkSweepCompaction enabled"); |
|
628 |
#else |
|
629 |
MarkSweep::print_new_location_of_heap_address((HeapWord*) old_heap_addr); |
|
630 |
#endif |
|
631 |
} |
|
632 |
||
633 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
634 |
extern "C" Method* findm(intptr_t pc) { |
1 | 635 |
Command c("findm"); |
636 |
nmethod* nm = CodeCache::find_nmethod((address)pc); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
637 |
return (nm == NULL) ? (Method*)NULL : nm->method(); |
1 | 638 |
} |
639 |
||
640 |
||
641 |
extern "C" nmethod* findnm(intptr_t addr) { |
|
642 |
Command c("findnm"); |
|
643 |
return CodeCache::find_nmethod((address)addr); |
|
644 |
} |
|
645 |
||
646 |
static address same_page(address x, address y) { |
|
647 |
intptr_t page_bits = -os::vm_page_size(); |
|
648 |
if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) { |
|
649 |
return x; |
|
650 |
} else if (x > y) { |
|
651 |
return (address)(intptr_t(y) | ~page_bits) + 1; |
|
652 |
} else { |
|
653 |
return (address)(intptr_t(y) & page_bits); |
|
654 |
} |
|
655 |
} |
|
656 |
||
657 |
||
658 |
// Another interface that isn't ambiguous in dbx. |
|
659 |
// Can we someday rename the other find to hsfind? |
|
660 |
extern "C" void hsfind(intptr_t x) { |
|
661 |
Command c("hsfind"); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
662 |
os::print_location(tty, x, false); |
1 | 663 |
} |
664 |
||
665 |
||
666 |
extern "C" void find(intptr_t x) { |
|
667 |
Command c("find"); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
668 |
os::print_location(tty, x, false); |
1 | 669 |
} |
670 |
||
671 |
||
672 |
extern "C" void findpc(intptr_t x) { |
|
673 |
Command c("findpc"); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
674 |
os::print_location(tty, x, true); |
1 | 675 |
} |
676 |
||
677 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
678 |
// Need method pointer to find bcp, when not in permgen. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
679 |
extern "C" void findbcp(intptr_t method, intptr_t bcp) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
680 |
Command c("findbcp"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
681 |
Method* mh = (Method*)method; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
682 |
if (!mh->is_native()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
683 |
tty->print_cr("bci_from(%p) = %d; print_codes():", |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
684 |
mh, mh->bci_from(address(bcp))); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
685 |
mh->print_codes_on(tty); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
686 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
687 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
688 |
|
1 | 689 |
// int versions of all methods to avoid having to type type casts in the debugger |
690 |
||
691 |
void pp(intptr_t p) { pp((void*)p); } |
|
692 |
void pp(oop p) { pp((void*)p); } |
|
693 |
||
694 |
void help() { |
|
695 |
Command c("help"); |
|
696 |
tty->print_cr("basic"); |
|
697 |
tty->print_cr(" pp(void* p) - try to make sense of p"); |
|
698 |
tty->print_cr(" pv(intptr_t p)- ((PrintableResourceObj*) p)->print()"); |
|
699 |
tty->print_cr(" ps() - print current thread stack"); |
|
700 |
tty->print_cr(" pss() - print all thread stacks"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
701 |
tty->print_cr(" pm(int pc) - print Method* given compiled PC"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
702 |
tty->print_cr(" findm(intptr_t pc) - finds Method*"); |
1 | 703 |
tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it"); |
704 |
||
705 |
tty->print_cr("misc."); |
|
706 |
tty->print_cr(" flush() - flushes the log file"); |
|
11788 | 707 |
tty->print_cr(" events() - dump events from ring buffers"); |
1 | 708 |
|
709 |
||
710 |
tty->print_cr("compiler debugging"); |
|
711 |
tty->print_cr(" debug() - to set things up for compiler debugging"); |
|
712 |
tty->print_cr(" ndebug() - undo debug"); |
|
713 |
} |
|
714 |
||
715 |
#if 0 |
|
716 |
||
717 |
// BobV's command parser for debugging on windows when nothing else works. |
|
718 |
||
719 |
enum CommandID { |
|
720 |
CMDID_HELP, |
|
721 |
CMDID_QUIT, |
|
722 |
CMDID_HSFIND, |
|
723 |
CMDID_PSS, |
|
724 |
CMDID_PS, |
|
725 |
CMDID_PSF, |
|
726 |
CMDID_FINDM, |
|
727 |
CMDID_FINDNM, |
|
728 |
CMDID_PP, |
|
729 |
CMDID_BPT, |
|
730 |
CMDID_EXIT, |
|
731 |
CMDID_VERIFY, |
|
732 |
CMDID_THREADS, |
|
733 |
CMDID_ILLEGAL = 99 |
|
734 |
}; |
|
735 |
||
736 |
struct CommandParser { |
|
737 |
char *name; |
|
738 |
CommandID code; |
|
739 |
char *description; |
|
740 |
}; |
|
741 |
||
742 |
struct CommandParser CommandList[] = { |
|
743 |
(char *)"help", CMDID_HELP, " Dump this list", |
|
744 |
(char *)"quit", CMDID_QUIT, " Return from this routine", |
|
745 |
(char *)"hsfind", CMDID_HSFIND, "Perform an hsfind on an address", |
|
746 |
(char *)"ps", CMDID_PS, " Print Current Thread Stack Trace", |
|
747 |
(char *)"pss", CMDID_PSS, " Print All Thread Stack Trace", |
|
748 |
(char *)"psf", CMDID_PSF, " Print All Stack Frames", |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
749 |
(char *)"findm", CMDID_FINDM, " Find a Method* from a PC", |
1 | 750 |
(char *)"findnm", CMDID_FINDNM, "Find an nmethod from a PC", |
751 |
(char *)"pp", CMDID_PP, " Find out something about a pointer", |
|
752 |
(char *)"break", CMDID_BPT, " Execute a breakpoint", |
|
753 |
(char *)"exitvm", CMDID_EXIT, "Exit the VM", |
|
754 |
(char *)"verify", CMDID_VERIFY, "Perform a Heap Verify", |
|
755 |
(char *)"thread", CMDID_THREADS, "Dump Info on all Threads", |
|
756 |
(char *)0, CMDID_ILLEGAL |
|
757 |
}; |
|
758 |
||
759 |
||
760 |
// get_debug_command() |
|
761 |
// |
|
762 |
// Read a command from standard input. |
|
763 |
// This is useful when you have a debugger |
|
764 |
// which doesn't support calling into functions. |
|
765 |
// |
|
766 |
void get_debug_command() |
|
767 |
{ |
|
768 |
ssize_t count; |
|
769 |
int i,j; |
|
770 |
bool gotcommand; |
|
771 |
intptr_t addr; |
|
772 |
char buffer[256]; |
|
773 |
nmethod *nm; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
774 |
Method* m; |
1 | 775 |
|
776 |
tty->print_cr("You have entered the diagnostic command interpreter"); |
|
777 |
tty->print("The supported commands are:\n"); |
|
778 |
for ( i=0; ; i++ ) { |
|
779 |
if ( CommandList[i].code == CMDID_ILLEGAL ) |
|
780 |
break; |
|
781 |
tty->print_cr(" %s \n", CommandList[i].name ); |
|
782 |
} |
|
783 |
||
784 |
while ( 1 ) { |
|
785 |
gotcommand = false; |
|
786 |
tty->print("Please enter a command: "); |
|
787 |
count = scanf("%s", buffer) ; |
|
788 |
if ( count >=0 ) { |
|
789 |
for ( i=0; ; i++ ) { |
|
790 |
if ( CommandList[i].code == CMDID_ILLEGAL ) { |
|
791 |
if (!gotcommand) tty->print("Invalid command, please try again\n"); |
|
792 |
break; |
|
793 |
} |
|
794 |
if ( strcmp(buffer, CommandList[i].name) == 0 ) { |
|
795 |
gotcommand = true; |
|
796 |
switch ( CommandList[i].code ) { |
|
797 |
case CMDID_PS: |
|
798 |
ps(); |
|
799 |
break; |
|
800 |
case CMDID_PSS: |
|
801 |
pss(); |
|
802 |
break; |
|
803 |
case CMDID_PSF: |
|
804 |
psf(); |
|
805 |
break; |
|
806 |
case CMDID_FINDM: |
|
807 |
tty->print("Please enter the hex addr to pass to findm: "); |
|
808 |
scanf("%I64X", &addr); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13393
diff
changeset
|
809 |
m = (Method*)findm(addr); |
1 | 810 |
tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m); |
811 |
break; |
|
812 |
case CMDID_FINDNM: |
|
813 |
tty->print("Please enter the hex addr to pass to findnm: "); |
|
814 |
scanf("%I64X", &addr); |
|
815 |
nm = (nmethod*)findnm(addr); |
|
816 |
tty->print("findnm(0x%I64X) returned 0x%I64X\n", addr, nm); |
|
817 |
break; |
|
818 |
case CMDID_PP: |
|
819 |
tty->print("Please enter the hex addr to pass to pp: "); |
|
820 |
scanf("%I64X", &addr); |
|
821 |
pp((void*)addr); |
|
822 |
break; |
|
823 |
case CMDID_EXIT: |
|
824 |
exit(0); |
|
825 |
case CMDID_HELP: |
|
826 |
tty->print("Here are the supported commands: "); |
|
827 |
for ( j=0; ; j++ ) { |
|
828 |
if ( CommandList[j].code == CMDID_ILLEGAL ) |
|
829 |
break; |
|
830 |
tty->print_cr(" %s -- %s\n", CommandList[j].name, |
|
831 |
CommandList[j].description ); |
|
832 |
} |
|
833 |
break; |
|
834 |
case CMDID_QUIT: |
|
835 |
return; |
|
836 |
break; |
|
837 |
case CMDID_BPT: |
|
838 |
BREAKPOINT; |
|
839 |
break; |
|
840 |
case CMDID_VERIFY: |
|
841 |
verify();; |
|
842 |
break; |
|
843 |
case CMDID_THREADS: |
|
844 |
threads();; |
|
845 |
break; |
|
846 |
case CMDID_HSFIND: |
|
847 |
tty->print("Please enter the hex addr to pass to hsfind: "); |
|
848 |
scanf("%I64X", &addr); |
|
849 |
tty->print("Calling hsfind(0x%I64X)\n", addr); |
|
850 |
hsfind(addr); |
|
851 |
break; |
|
852 |
default: |
|
853 |
case CMDID_ILLEGAL: |
|
854 |
break; |
|
855 |
} |
|
856 |
} |
|
857 |
} |
|
858 |
} |
|
859 |
} |
|
860 |
} |
|
861 |
#endif |
|
862 |
||
10739 | 863 |
#endif // !PRODUCT |