mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8200720: Print additional information in thread dump (times, allocated bytes etc.)
Reviewed-by: dholmes, clanger, cjplummer, sspitsyn
This commit is contained in:
parent
807c4ae4a3
commit
27896721a0
11 changed files with 130 additions and 25 deletions
|
@ -93,6 +93,7 @@
|
|||
#include "runtime/thread.inline.hpp"
|
||||
#include "runtime/threadCritical.hpp"
|
||||
#include "runtime/threadSMR.inline.hpp"
|
||||
#include "runtime/threadStatisticalInfo.hpp"
|
||||
#include "runtime/timer.hpp"
|
||||
#include "runtime/timerTrace.hpp"
|
||||
#include "runtime/vframe.inline.hpp"
|
||||
|
@ -869,13 +870,29 @@ void Thread::metadata_handles_do(void f(Metadata*)) {
|
|||
}
|
||||
}
|
||||
|
||||
void Thread::print_on(outputStream* st) const {
|
||||
void Thread::print_on(outputStream* st, bool print_extended_info) const {
|
||||
// get_priority assumes osthread initialized
|
||||
if (osthread() != NULL) {
|
||||
int os_prio;
|
||||
if (os::get_native_priority(this, &os_prio) == OS_OK) {
|
||||
st->print("os_prio=%d ", os_prio);
|
||||
}
|
||||
|
||||
st->print("cpu=%.2fms ",
|
||||
os::thread_cpu_time(const_cast<Thread*>(this), true) / 1000000.0
|
||||
);
|
||||
st->print("elapsed=%.2fs ",
|
||||
_statistical_info.getElapsedTime() / 1000.0
|
||||
);
|
||||
if (is_Java_thread() && (PrintExtendedThreadInfo || print_extended_info)) {
|
||||
size_t allocated_bytes = (size_t) const_cast<Thread*>(this)->cooked_allocated_bytes();
|
||||
st->print("allocated=" SIZE_FORMAT "%s ",
|
||||
byte_size_in_proper_unit(allocated_bytes),
|
||||
proper_unit_for_byte_size(allocated_bytes)
|
||||
);
|
||||
st->print("defined_classes=" INT64_FORMAT " ", _statistical_info.getDefineClassCount());
|
||||
}
|
||||
|
||||
st->print("tid=" INTPTR_FORMAT " ", p2i(this));
|
||||
osthread()->print_on(st);
|
||||
}
|
||||
|
@ -2871,7 +2888,7 @@ void JavaThread::print_thread_state() const {
|
|||
#endif // PRODUCT
|
||||
|
||||
// Called by Threads::print() for VM_PrintThreads operation
|
||||
void JavaThread::print_on(outputStream *st) const {
|
||||
void JavaThread::print_on(outputStream *st, bool print_extended_info) const {
|
||||
st->print_raw("\"");
|
||||
st->print_raw(get_thread_name());
|
||||
st->print_raw("\" ");
|
||||
|
@ -2881,7 +2898,7 @@ void JavaThread::print_on(outputStream *st) const {
|
|||
if (java_lang_Thread::is_daemon(thread_oop)) st->print("daemon ");
|
||||
st->print("prio=%d ", java_lang_Thread::priority(thread_oop));
|
||||
}
|
||||
Thread::print_on(st);
|
||||
Thread::print_on(st, print_extended_info);
|
||||
// print guess for valid stack memory region (assume 4K pages); helps lock debugging
|
||||
st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
|
||||
if (thread_oop != NULL) {
|
||||
|
@ -4531,7 +4548,8 @@ JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
|
|||
|
||||
// Threads::print_on() is called at safepoint by VM_PrintThreads operation.
|
||||
void Threads::print_on(outputStream* st, bool print_stacks,
|
||||
bool internal_format, bool print_concurrent_locks) {
|
||||
bool internal_format, bool print_concurrent_locks,
|
||||
bool print_extended_info) {
|
||||
char buf[32];
|
||||
st->print_raw_cr(os::local_time_string(buf, sizeof(buf)));
|
||||
|
||||
|
@ -4554,7 +4572,7 @@ void Threads::print_on(outputStream* st, bool print_stacks,
|
|||
|
||||
ALL_JAVA_THREADS(p) {
|
||||
ResourceMark rm;
|
||||
p->print_on(st);
|
||||
p->print_on(st, print_extended_info);
|
||||
if (print_stacks) {
|
||||
if (internal_format) {
|
||||
p->trace_stack();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue