1.1 --- a/src/share/vm/utilities/vmError.cpp Fri Apr 16 05:05:53 2010 -0700 1.2 +++ b/src/share/vm/utilities/vmError.cpp Mon Apr 19 02:13:06 2010 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -212,6 +212,51 @@ 1.11 return buf; 1.12 } 1.13 1.14 +void VMError::print_stack_trace(outputStream* st, JavaThread* jt, 1.15 + char* buf, int buflen, bool verbose) { 1.16 +#ifdef ZERO 1.17 + if (jt->zero_stack()->sp() && jt->top_zero_frame()) { 1.18 + // StackFrameStream uses the frame anchor, which may not have 1.19 + // been set up. This can be done at any time in Zero, however, 1.20 + // so if it hasn't been set up then we just set it up now and 1.21 + // clear it again when we're done. 1.22 + bool has_last_Java_frame = jt->has_last_Java_frame(); 1.23 + if (!has_last_Java_frame) 1.24 + jt->set_last_Java_frame(); 1.25 + st->print("Java frames:"); 1.26 + 1.27 + // If the top frame is a Shark frame and the frame anchor isn't 1.28 + // set up then it's possible that the information in the frame 1.29 + // is garbage: it could be from a previous decache, or it could 1.30 + // simply have never been written. So we print a warning... 1.31 + StackFrameStream sfs(jt); 1.32 + if (!has_last_Java_frame && !sfs.is_done()) { 1.33 + if (sfs.current()->zeroframe()->is_shark_frame()) { 1.34 + st->print(" (TOP FRAME MAY BE JUNK)"); 1.35 + } 1.36 + } 1.37 + st->cr(); 1.38 + 1.39 + // Print the frames 1.40 + for(int i = 0; !sfs.is_done(); sfs.next(), i++) { 1.41 + sfs.current()->zero_print_on_error(i, st, buf, buflen); 1.42 + st->cr(); 1.43 + } 1.44 + 1.45 + // Reset the frame anchor if necessary 1.46 + if (!has_last_Java_frame) 1.47 + jt->reset_last_Java_frame(); 1.48 + } 1.49 +#else 1.50 + if (jt->has_last_Java_frame()) { 1.51 + st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); 1.52 + for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { 1.53 + sfs.current()->print_on_error(st, buf, buflen, verbose); 1.54 + st->cr(); 1.55 + } 1.56 + } 1.57 +#endif // ZERO 1.58 +} 1.59 1.60 // This is the main function to report a fatal error. Only one thread can 1.61 // call this function, so we don't need to worry about MT-safety. But it's 1.62 @@ -457,49 +502,7 @@ 1.63 STEP(130, "(printing Java stack)" ) 1.64 1.65 if (_verbose && _thread && _thread->is_Java_thread()) { 1.66 - JavaThread* jt = (JavaThread*)_thread; 1.67 -#ifdef ZERO 1.68 - if (jt->zero_stack()->sp() && jt->top_zero_frame()) { 1.69 - // StackFrameStream uses the frame anchor, which may not have 1.70 - // been set up. This can be done at any time in Zero, however, 1.71 - // so if it hasn't been set up then we just set it up now and 1.72 - // clear it again when we're done. 1.73 - bool has_last_Java_frame = jt->has_last_Java_frame(); 1.74 - if (!has_last_Java_frame) 1.75 - jt->set_last_Java_frame(); 1.76 - st->print("Java frames:"); 1.77 - 1.78 - // If the top frame is a Shark frame and the frame anchor isn't 1.79 - // set up then it's possible that the information in the frame 1.80 - // is garbage: it could be from a previous decache, or it could 1.81 - // simply have never been written. So we print a warning... 1.82 - StackFrameStream sfs(jt); 1.83 - if (!has_last_Java_frame && !sfs.is_done()) { 1.84 - if (sfs.current()->zeroframe()->is_shark_frame()) { 1.85 - st->print(" (TOP FRAME MAY BE JUNK)"); 1.86 - } 1.87 - } 1.88 - st->cr(); 1.89 - 1.90 - // Print the frames 1.91 - for(int i = 0; !sfs.is_done(); sfs.next(), i++) { 1.92 - sfs.current()->zero_print_on_error(i, st, buf, sizeof(buf)); 1.93 - st->cr(); 1.94 - } 1.95 - 1.96 - // Reset the frame anchor if necessary 1.97 - if (!has_last_Java_frame) 1.98 - jt->reset_last_Java_frame(); 1.99 - } 1.100 -#else 1.101 - if (jt->has_last_Java_frame()) { 1.102 - st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); 1.103 - for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { 1.104 - sfs.current()->print_on_error(st, buf, sizeof(buf)); 1.105 - st->cr(); 1.106 - } 1.107 - } 1.108 -#endif // ZERO 1.109 + print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); 1.110 } 1.111 1.112 STEP(135, "(printing target Java thread stack)" ) 1.113 @@ -509,13 +512,7 @@ 1.114 JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); 1.115 if (jt != NULL) { 1.116 st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id()); 1.117 - if (jt->has_last_Java_frame()) { 1.118 - st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); 1.119 - for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { 1.120 - sfs.current()->print_on_error(st, buf, sizeof(buf), true); 1.121 - st->cr(); 1.122 - } 1.123 - } 1.124 + print_stack_trace(st, jt, buf, sizeof(buf), true); 1.125 } 1.126 } 1.127