hotspot/src/share/vm/services/threadService.cpp
changeset 15853 1c4e16950e96
parent 13952 e3cf184080bc
child 18085 fb6d02a9e1c5
equal deleted inserted replaced
15851:f8d172011be7 15853:1c4e16950e96
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. 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.
   325       waitingToLockBlocker = jt->current_park_blocker();
   325       waitingToLockBlocker = jt->current_park_blocker();
   326     }
   326     }
   327     while (waitingToLockMonitor != NULL || waitingToLockBlocker != NULL) {
   327     while (waitingToLockMonitor != NULL || waitingToLockBlocker != NULL) {
   328       cycle->add_thread(currentThread);
   328       cycle->add_thread(currentThread);
   329       if (waitingToLockMonitor != NULL) {
   329       if (waitingToLockMonitor != NULL) {
   330         currentThread = Threads::owning_thread_from_monitor_owner((address)waitingToLockMonitor->owner(),
   330         currentThread = Threads::owning_thread_from_monitor_owner(
   331                                                                   false /* no locking needed */);
   331                           (address)waitingToLockMonitor->owner(),
       
   332                           false /* no locking needed */);
       
   333         if (currentThread == NULL) {
       
   334           // This function is called at a safepoint so the JavaThread
       
   335           // that owns waitingToLockMonitor should be findable, but
       
   336           // if it is not findable, then the previous currentThread is
       
   337           // blocked permanently. We record this as a deadlock.
       
   338           num_deadlocks++;
       
   339 
       
   340           cycle->set_deadlock(true);
       
   341 
       
   342           // add this cycle to the deadlocks list
       
   343           if (deadlocks == NULL) {
       
   344             deadlocks = cycle;
       
   345           } else {
       
   346             last->set_next(cycle);
       
   347           }
       
   348           last = cycle;
       
   349           cycle = new DeadlockCycle();
       
   350           break;
       
   351         }
   332       } else {
   352       } else {
   333         if (concurrent_locks) {
   353         if (concurrent_locks) {
   334           if (waitingToLockBlocker->is_a(SystemDictionary::abstract_ownable_synchronizer_klass())) {
   354           if (waitingToLockBlocker->is_a(SystemDictionary::abstract_ownable_synchronizer_klass())) {
   335             oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
   355             oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
   336             currentThread = threadObj != NULL ? java_lang_Thread::thread(threadObj) : NULL;
   356             currentThread = threadObj != NULL ? java_lang_Thread::thread(threadObj) : NULL;
   839       } else {
   859       } else {
   840         // No Java object associated - a JVMTI raw monitor
   860         // No Java object associated - a JVMTI raw monitor
   841         owner_desc = " (JVMTI raw monitor),\n  which is held by";
   861         owner_desc = " (JVMTI raw monitor),\n  which is held by";
   842       }
   862       }
   843       currentThread = Threads::owning_thread_from_monitor_owner(
   863       currentThread = Threads::owning_thread_from_monitor_owner(
   844         (address)waitingToLockMonitor->owner(), false /* no locking needed */);
   864                         (address)waitingToLockMonitor->owner(),
       
   865                         false /* no locking needed */);
       
   866       if (currentThread == NULL) {
       
   867         // The deadlock was detected at a safepoint so the JavaThread
       
   868         // that owns waitingToLockMonitor should be findable, but
       
   869         // if it is not findable, then the previous currentThread is
       
   870         // blocked permanently.
       
   871         st->print("%s UNKNOWN_owner_addr=" PTR_FORMAT, owner_desc,
       
   872                   (address)waitingToLockMonitor->owner());
       
   873         continue;
       
   874       }
   845     } else {
   875     } else {
   846       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
   876       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
   847                 (address)waitingToLockBlocker,
   877                 (address)waitingToLockBlocker,
   848                 (InstanceKlass::cast(waitingToLockBlocker->klass()))->external_name());
   878                 (InstanceKlass::cast(waitingToLockBlocker->klass()))->external_name());
   849       assert(waitingToLockBlocker->is_a(SystemDictionary::abstract_ownable_synchronizer_klass()),
   879       assert(waitingToLockBlocker->is_a(SystemDictionary::abstract_ownable_synchronizer_klass()),