src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot-rt Sdiff src/share/vm/runtime

src/share/vm/runtime/thread.cpp

Print this page




 819   // Do oop for ThreadShadow
 820   f->do_oop((oop*)&_pending_exception);
 821   handle_area()->oops_do(f);
 822 }
 823 
 824 void Thread::nmethods_do(CodeBlobClosure* cf) {
 825   // no nmethods in a generic thread...
 826 }
 827 
 828 void Thread::metadata_do(void f(Metadata*)) {
 829   if (metadata_handles() != NULL) {
 830     for (int i = 0; i< metadata_handles()->length(); i++) {
 831       f(metadata_handles()->at(i));
 832     }
 833   }
 834 }
 835 
 836 void Thread::print_on(outputStream* st) const {
 837   // get_priority assumes osthread initialized
 838   if (osthread() != NULL) {
 839     st->print("prio=%d tid=" INTPTR_FORMAT " ", get_priority(this), this);




 840     osthread()->print_on(st);
 841   }
 842   debug_only(if (WizardMode) print_owned_locks_on(st);)
 843 }
 844 
 845 // Thread::print_on_error() is called by fatal error handler. Don't use
 846 // any lock or allocate memory.
 847 void Thread::print_on_error(outputStream* st, char* buf, int buflen) const {
 848   if      (is_VM_thread())                  st->print("VMThread");
 849   else if (is_Compiler_thread())            st->print("CompilerThread");
 850   else if (is_Java_thread())                st->print("JavaThread");
 851   else if (is_GC_task_thread())             st->print("GCTaskThread");
 852   else if (is_Watcher_thread())             st->print("WatcherThread");
 853   else if (is_ConcurrentGC_thread())        st->print("ConcurrentGCThread");
 854   else st->print("Thread");
 855 
 856   st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]",
 857             _stack_base - _stack_size, _stack_base);
 858 
 859   if (osthread()) {


2726   case _thread_in_Java_trans:     return "_thread_in_Java_trans";
2727   case _thread_blocked:           return "_thread_blocked";
2728   case _thread_blocked_trans:     return "_thread_blocked_trans";
2729   default:                        return "unknown thread state";
2730   }
2731 }
2732 
2733 #ifndef PRODUCT
2734 void JavaThread::print_thread_state_on(outputStream *st) const {
2735   st->print_cr("   JavaThread state: %s", _get_thread_state_name(_thread_state));
2736 };
2737 void JavaThread::print_thread_state() const {
2738   print_thread_state_on(tty);
2739 };
2740 #endif // PRODUCT
2741 
2742 // Called by Threads::print() for VM_PrintThreads operation
2743 void JavaThread::print_on(outputStream *st) const {
2744   st->print("\"%s\" ", get_thread_name());
2745   oop thread_oop = threadObj();
2746   if (thread_oop != NULL && java_lang_Thread::is_daemon(thread_oop))  st->print("daemon ");




2747   Thread::print_on(st);
2748   // print guess for valid stack memory region (assume 4K pages); helps lock debugging
2749   st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
2750   if (thread_oop != NULL && JDK_Version::is_gte_jdk15x_version()) {
2751     st->print_cr("   java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
2752   }
2753 #ifndef PRODUCT
2754   print_thread_state_on(st);
2755   _safepoint_state->print_on(st);
2756 #endif // PRODUCT
2757 }
2758 
2759 // Called by fatal error handler. The difference between this and
2760 // JavaThread::print() is that we can't grab lock or allocate memory.
2761 void JavaThread::print_on_error(outputStream* st, char *buf, int buflen) const {
2762   st->print("JavaThread \"%s\"",  get_thread_name_string(buf, buflen));
2763   oop thread_obj = threadObj();
2764   if (thread_obj != NULL) {
2765      if (java_lang_Thread::is_daemon(thread_obj)) st->print(" daemon");
2766   }


4253     p->print_on(st);
4254     if (print_stacks) {
4255       if (internal_format) {
4256         p->trace_stack();
4257       } else {
4258         p->print_stack_on(st);
4259       }
4260     }
4261     st->cr();
4262 #ifndef SERIALGC
4263     if (print_concurrent_locks) {
4264       concurrent_locks.print_locks_on(p, st);
4265     }
4266 #endif // SERIALGC
4267   }
4268 
4269   VMThread::vm_thread()->print_on(st);
4270   st->cr();
4271   Universe::heap()->print_gc_threads_on(st);
4272   WatcherThread* wt = WatcherThread::watcher_thread();
4273   if (wt != NULL) wt->print_on(st);

4274   st->cr();

4275   CompileBroker::print_compiler_threads_on(st);
4276   st->flush();
4277 }
4278 
4279 // Threads::print_on_error() is called by fatal error handler. It's possible
4280 // that VM is not at safepoint and/or current thread is inside signal handler.
4281 // Don't print stack trace, as the stack may not be walkable. Don't allocate
4282 // memory (even in resource area), it might deadlock the error handler.
4283 void Threads::print_on_error(outputStream* st, Thread* current, char* buf, int buflen) {
4284   bool found_current = false;
4285   st->print_cr("Java Threads: ( => current thread )");
4286   ALL_JAVA_THREADS(thread) {
4287     bool is_current = (current == thread);
4288     found_current = found_current || is_current;
4289 
4290     st->print("%s", is_current ? "=>" : "  ");
4291 
4292     st->print(PTR_FORMAT, thread);
4293     st->print(" ");
4294     thread->print_on_error(st, buf, buflen);




 819   // Do oop for ThreadShadow
 820   f->do_oop((oop*)&_pending_exception);
 821   handle_area()->oops_do(f);
 822 }
 823 
 824 void Thread::nmethods_do(CodeBlobClosure* cf) {
 825   // no nmethods in a generic thread...
 826 }
 827 
 828 void Thread::metadata_do(void f(Metadata*)) {
 829   if (metadata_handles() != NULL) {
 830     for (int i = 0; i< metadata_handles()->length(); i++) {
 831       f(metadata_handles()->at(i));
 832     }
 833   }
 834 }
 835 
 836 void Thread::print_on(outputStream* st) const {
 837   // get_priority assumes osthread initialized
 838   if (osthread() != NULL) {
 839     int os_prio;
 840     if (os::get_native_priority(this, &os_prio) == OS_OK) {
 841       st->print("os_prio=%d ", os_prio);
 842     }
 843     st->print("tid=" INTPTR_FORMAT " ", this);
 844     osthread()->print_on(st);
 845   }
 846   debug_only(if (WizardMode) print_owned_locks_on(st);)
 847 }
 848 
 849 // Thread::print_on_error() is called by fatal error handler. Don't use
 850 // any lock or allocate memory.
 851 void Thread::print_on_error(outputStream* st, char* buf, int buflen) const {
 852   if      (is_VM_thread())                  st->print("VMThread");
 853   else if (is_Compiler_thread())            st->print("CompilerThread");
 854   else if (is_Java_thread())                st->print("JavaThread");
 855   else if (is_GC_task_thread())             st->print("GCTaskThread");
 856   else if (is_Watcher_thread())             st->print("WatcherThread");
 857   else if (is_ConcurrentGC_thread())        st->print("ConcurrentGCThread");
 858   else st->print("Thread");
 859 
 860   st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]",
 861             _stack_base - _stack_size, _stack_base);
 862 
 863   if (osthread()) {


2730   case _thread_in_Java_trans:     return "_thread_in_Java_trans";
2731   case _thread_blocked:           return "_thread_blocked";
2732   case _thread_blocked_trans:     return "_thread_blocked_trans";
2733   default:                        return "unknown thread state";
2734   }
2735 }
2736 
2737 #ifndef PRODUCT
2738 void JavaThread::print_thread_state_on(outputStream *st) const {
2739   st->print_cr("   JavaThread state: %s", _get_thread_state_name(_thread_state));
2740 };
2741 void JavaThread::print_thread_state() const {
2742   print_thread_state_on(tty);
2743 };
2744 #endif // PRODUCT
2745 
2746 // Called by Threads::print() for VM_PrintThreads operation
2747 void JavaThread::print_on(outputStream *st) const {
2748   st->print("\"%s\" ", get_thread_name());
2749   oop thread_oop = threadObj();
2750   if (thread_oop != NULL) {
2751     st->print("#" INT64_FORMAT " ", java_lang_Thread::thread_id(thread_oop));
2752     if (java_lang_Thread::is_daemon(thread_oop))  st->print("daemon ");
2753     st->print("prio=%d ", java_lang_Thread::priority(thread_oop));
2754   }
2755   Thread::print_on(st);
2756   // print guess for valid stack memory region (assume 4K pages); helps lock debugging
2757   st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
2758   if (thread_oop != NULL && JDK_Version::is_gte_jdk15x_version()) {
2759     st->print_cr("   java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
2760   }
2761 #ifndef PRODUCT
2762   print_thread_state_on(st);
2763   _safepoint_state->print_on(st);
2764 #endif // PRODUCT
2765 }
2766 
2767 // Called by fatal error handler. The difference between this and
2768 // JavaThread::print() is that we can't grab lock or allocate memory.
2769 void JavaThread::print_on_error(outputStream* st, char *buf, int buflen) const {
2770   st->print("JavaThread \"%s\"",  get_thread_name_string(buf, buflen));
2771   oop thread_obj = threadObj();
2772   if (thread_obj != NULL) {
2773      if (java_lang_Thread::is_daemon(thread_obj)) st->print(" daemon");
2774   }


4261     p->print_on(st);
4262     if (print_stacks) {
4263       if (internal_format) {
4264         p->trace_stack();
4265       } else {
4266         p->print_stack_on(st);
4267       }
4268     }
4269     st->cr();
4270 #ifndef SERIALGC
4271     if (print_concurrent_locks) {
4272       concurrent_locks.print_locks_on(p, st);
4273     }
4274 #endif // SERIALGC
4275   }
4276 
4277   VMThread::vm_thread()->print_on(st);
4278   st->cr();
4279   Universe::heap()->print_gc_threads_on(st);
4280   WatcherThread* wt = WatcherThread::watcher_thread();
4281   if (wt != NULL) {
4282     wt->print_on(st);
4283     st->cr();
4284   }
4285   CompileBroker::print_compiler_threads_on(st);
4286   st->flush();
4287 }
4288 
4289 // Threads::print_on_error() is called by fatal error handler. It's possible
4290 // that VM is not at safepoint and/or current thread is inside signal handler.
4291 // Don't print stack trace, as the stack may not be walkable. Don't allocate
4292 // memory (even in resource area), it might deadlock the error handler.
4293 void Threads::print_on_error(outputStream* st, Thread* current, char* buf, int buflen) {
4294   bool found_current = false;
4295   st->print_cr("Java Threads: ( => current thread )");
4296   ALL_JAVA_THREADS(thread) {
4297     bool is_current = (current == thread);
4298     found_current = found_current || is_current;
4299 
4300     st->print("%s", is_current ? "=>" : "  ");
4301 
4302     st->print(PTR_FORMAT, thread);
4303     st->print(" ");
4304     thread->print_on_error(st, buf, buflen);


src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File