Mercurial > hg > truffle
diff src/share/vm/runtime/thread.cpp @ 1119:547f81740344
6361589: Print out stack trace for target thread of GC crash
Summary: If GC crashed with java thread involved, print out the java stack trace in error report
Reviewed-by: never, ysr, coleenp, dholmes
author | minqi |
---|---|
date | Fri, 11 Dec 2009 11:09:49 -0800 |
parents | 4b966d9946a3 |
children | 9b9c1ee9b3f6 |
line wrap: on
line diff
--- a/src/share/vm/runtime/thread.cpp Wed Dec 02 20:32:27 2009 -0500 +++ b/src/share/vm/runtime/thread.cpp Fri Dec 11 11:09:49 2009 -0800 @@ -991,6 +991,7 @@ // uniquely named instances should derive from this. NamedThread::NamedThread() : Thread() { _name = NULL; + _processed_thread = NULL; } NamedThread::~NamedThread() { @@ -2333,6 +2334,27 @@ frames_do(frame_gc_prologue); } +// If the caller is a NamedThread, then remember, in the current scope, +// the given JavaThread in its _processed_thread field. +class RememberProcessedThread: public StackObj { + NamedThread* _cur_thr; +public: + RememberProcessedThread(JavaThread* jthr) { + Thread* thread = Thread::current(); + if (thread->is_Named_thread()) { + _cur_thr = (NamedThread *)thread; + _cur_thr->set_processed_thread(jthr); + } else { + _cur_thr = NULL; + } + } + + ~RememberProcessedThread() { + if (_cur_thr) { + _cur_thr->set_processed_thread(NULL); + } + } +}; void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { // Flush deferred store-barriers, if any, associated with @@ -2349,6 +2371,8 @@ (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); if (has_last_Java_frame()) { + // Record JavaThread to GC thread + RememberProcessedThread rpt(this); // Traverse the privileged stack if (_privileged_stack_top != NULL) {