Mercurial > hg > graal-compiler
comparison src/share/vm/utilities/vmError.cpp @ 1384:c544d979f886
6944503: Improved Zero crash dump
Summary: With Zero on a GC crash the stack was dumped differently to other crashes.
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>
author | twisti |
---|---|
date | Mon, 19 Apr 2010 02:13:06 -0700 |
parents | a2ea687fdc7c |
children | f03d0a26bf83 |
comparison
equal
deleted
inserted
replaced
1383:aa9c266de52a | 1384:c544d979f886 |
---|---|
1 /* | 1 /* |
2 * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
210 } | 210 } |
211 | 211 |
212 return buf; | 212 return buf; |
213 } | 213 } |
214 | 214 |
215 void VMError::print_stack_trace(outputStream* st, JavaThread* jt, | |
216 char* buf, int buflen, bool verbose) { | |
217 #ifdef ZERO | |
218 if (jt->zero_stack()->sp() && jt->top_zero_frame()) { | |
219 // StackFrameStream uses the frame anchor, which may not have | |
220 // been set up. This can be done at any time in Zero, however, | |
221 // so if it hasn't been set up then we just set it up now and | |
222 // clear it again when we're done. | |
223 bool has_last_Java_frame = jt->has_last_Java_frame(); | |
224 if (!has_last_Java_frame) | |
225 jt->set_last_Java_frame(); | |
226 st->print("Java frames:"); | |
227 | |
228 // If the top frame is a Shark frame and the frame anchor isn't | |
229 // set up then it's possible that the information in the frame | |
230 // is garbage: it could be from a previous decache, or it could | |
231 // simply have never been written. So we print a warning... | |
232 StackFrameStream sfs(jt); | |
233 if (!has_last_Java_frame && !sfs.is_done()) { | |
234 if (sfs.current()->zeroframe()->is_shark_frame()) { | |
235 st->print(" (TOP FRAME MAY BE JUNK)"); | |
236 } | |
237 } | |
238 st->cr(); | |
239 | |
240 // Print the frames | |
241 for(int i = 0; !sfs.is_done(); sfs.next(), i++) { | |
242 sfs.current()->zero_print_on_error(i, st, buf, buflen); | |
243 st->cr(); | |
244 } | |
245 | |
246 // Reset the frame anchor if necessary | |
247 if (!has_last_Java_frame) | |
248 jt->reset_last_Java_frame(); | |
249 } | |
250 #else | |
251 if (jt->has_last_Java_frame()) { | |
252 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); | |
253 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { | |
254 sfs.current()->print_on_error(st, buf, buflen, verbose); | |
255 st->cr(); | |
256 } | |
257 } | |
258 #endif // ZERO | |
259 } | |
215 | 260 |
216 // This is the main function to report a fatal error. Only one thread can | 261 // This is the main function to report a fatal error. Only one thread can |
217 // call this function, so we don't need to worry about MT-safety. But it's | 262 // call this function, so we don't need to worry about MT-safety. But it's |
218 // possible that the error handler itself may crash or die on an internal | 263 // possible that the error handler itself may crash or die on an internal |
219 // error, for example, when the stack/heap is badly damaged. We must be | 264 // error, for example, when the stack/heap is badly damaged. We must be |
455 } | 500 } |
456 | 501 |
457 STEP(130, "(printing Java stack)" ) | 502 STEP(130, "(printing Java stack)" ) |
458 | 503 |
459 if (_verbose && _thread && _thread->is_Java_thread()) { | 504 if (_verbose && _thread && _thread->is_Java_thread()) { |
460 JavaThread* jt = (JavaThread*)_thread; | 505 print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); |
461 #ifdef ZERO | |
462 if (jt->zero_stack()->sp() && jt->top_zero_frame()) { | |
463 // StackFrameStream uses the frame anchor, which may not have | |
464 // been set up. This can be done at any time in Zero, however, | |
465 // so if it hasn't been set up then we just set it up now and | |
466 // clear it again when we're done. | |
467 bool has_last_Java_frame = jt->has_last_Java_frame(); | |
468 if (!has_last_Java_frame) | |
469 jt->set_last_Java_frame(); | |
470 st->print("Java frames:"); | |
471 | |
472 // If the top frame is a Shark frame and the frame anchor isn't | |
473 // set up then it's possible that the information in the frame | |
474 // is garbage: it could be from a previous decache, or it could | |
475 // simply have never been written. So we print a warning... | |
476 StackFrameStream sfs(jt); | |
477 if (!has_last_Java_frame && !sfs.is_done()) { | |
478 if (sfs.current()->zeroframe()->is_shark_frame()) { | |
479 st->print(" (TOP FRAME MAY BE JUNK)"); | |
480 } | |
481 } | |
482 st->cr(); | |
483 | |
484 // Print the frames | |
485 for(int i = 0; !sfs.is_done(); sfs.next(), i++) { | |
486 sfs.current()->zero_print_on_error(i, st, buf, sizeof(buf)); | |
487 st->cr(); | |
488 } | |
489 | |
490 // Reset the frame anchor if necessary | |
491 if (!has_last_Java_frame) | |
492 jt->reset_last_Java_frame(); | |
493 } | |
494 #else | |
495 if (jt->has_last_Java_frame()) { | |
496 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); | |
497 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { | |
498 sfs.current()->print_on_error(st, buf, sizeof(buf)); | |
499 st->cr(); | |
500 } | |
501 } | |
502 #endif // ZERO | |
503 } | 506 } |
504 | 507 |
505 STEP(135, "(printing target Java thread stack)" ) | 508 STEP(135, "(printing target Java thread stack)" ) |
506 | 509 |
507 // printing Java thread stack trace if it is involved in GC crash | 510 // printing Java thread stack trace if it is involved in GC crash |
508 if (_verbose && (_thread->is_Named_thread())) { | 511 if (_verbose && (_thread->is_Named_thread())) { |
509 JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); | 512 JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); |
510 if (jt != NULL) { | 513 if (jt != NULL) { |
511 st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id()); | 514 st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id()); |
512 if (jt->has_last_Java_frame()) { | 515 print_stack_trace(st, jt, buf, sizeof(buf), true); |
513 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); | |
514 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { | |
515 sfs.current()->print_on_error(st, buf, sizeof(buf), true); | |
516 st->cr(); | |
517 } | |
518 } | |
519 } | 516 } |
520 } | 517 } |
521 | 518 |
522 STEP(140, "(printing VM operation)" ) | 519 STEP(140, "(printing VM operation)" ) |
523 | 520 |