src/hotspot/share/runtime/vmOperations.cpp
changeset 53504 391d671f222b
parent 52877 9e041366c764
child 54623 1126f0607c70
equal deleted inserted replaced
53503:1ffc0fa0e98b 53504:391d671f222b
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, 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.
   331       }
   331       }
   332       ThreadConcurrentLocks* tcl = NULL;
   332       ThreadConcurrentLocks* tcl = NULL;
   333       if (_with_locked_synchronizers) {
   333       if (_with_locked_synchronizers) {
   334         tcl = concurrent_locks.thread_concurrent_locks(jt);
   334         tcl = concurrent_locks.thread_concurrent_locks(jt);
   335       }
   335       }
   336       ThreadSnapshot* ts = snapshot_thread(jt, tcl);
   336       snapshot_thread(jt, tcl);
   337       _result->add_thread_snapshot(ts);
       
   338     }
   337     }
   339   } else {
   338   } else {
   340     // Snapshot threads in the given _threads array
   339     // Snapshot threads in the given _threads array
   341     // A dummy snapshot is created if a thread doesn't exist
   340     // A dummy snapshot is created if a thread doesn't exist
   342 
   341 
   343     for (int i = 0; i < _num_threads; i++) {
   342     for (int i = 0; i < _num_threads; i++) {
   344       instanceHandle th = _threads->at(i);
   343       instanceHandle th = _threads->at(i);
   345       if (th() == NULL) {
   344       if (th() == NULL) {
   346         // skip if the thread doesn't exist
   345         // skip if the thread doesn't exist
   347         // Add a dummy snapshot
   346         // Add a dummy snapshot
   348         _result->add_thread_snapshot(new ThreadSnapshot());
   347         _result->add_thread_snapshot();
   349         continue;
   348         continue;
   350       }
   349       }
   351 
   350 
   352       // Dump thread stack only if the thread is alive and not exiting
   351       // Dump thread stack only if the thread is alive and not exiting
   353       // and not VM internal thread.
   352       // and not VM internal thread.
   360       }
   359       }
   361       if (jt == NULL || /* thread not alive */
   360       if (jt == NULL || /* thread not alive */
   362           jt->is_exiting() ||
   361           jt->is_exiting() ||
   363           jt->is_hidden_from_external_view())  {
   362           jt->is_hidden_from_external_view())  {
   364         // add a NULL snapshot if skipped
   363         // add a NULL snapshot if skipped
   365         _result->add_thread_snapshot(new ThreadSnapshot());
   364         _result->add_thread_snapshot();
   366         continue;
   365         continue;
   367       }
   366       }
   368       ThreadConcurrentLocks* tcl = NULL;
   367       ThreadConcurrentLocks* tcl = NULL;
   369       if (_with_locked_synchronizers) {
   368       if (_with_locked_synchronizers) {
   370         tcl = concurrent_locks.thread_concurrent_locks(jt);
   369         tcl = concurrent_locks.thread_concurrent_locks(jt);
   371       }
   370       }
   372       ThreadSnapshot* ts = snapshot_thread(jt, tcl);
   371       snapshot_thread(jt, tcl);
   373       _result->add_thread_snapshot(ts);
   372     }
   374     }
   373   }
   375   }
   374 }
   376 }
   375 
   377 
   376 void VM_ThreadDump::snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl) {
   378 ThreadSnapshot* VM_ThreadDump::snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl) {
   377   ThreadSnapshot* snapshot = _result->add_thread_snapshot(java_thread);
   379   ThreadSnapshot* snapshot = new ThreadSnapshot(_result->t_list(), java_thread);
       
   380   snapshot->dump_stack_at_safepoint(_max_depth, _with_locked_monitors);
   378   snapshot->dump_stack_at_safepoint(_max_depth, _with_locked_monitors);
   381   snapshot->set_concurrent_locks(tcl);
   379   snapshot->set_concurrent_locks(tcl);
   382   return snapshot;
       
   383 }
   380 }
   384 
   381 
   385 volatile bool VM_Exit::_vm_exited = false;
   382 volatile bool VM_Exit::_vm_exited = false;
   386 Thread * volatile VM_Exit::_shutdown_thread = NULL;
   383 Thread * volatile VM_Exit::_shutdown_thread = NULL;
   387 
   384