< prev index next >
src/os/solaris/vm/os_solaris.cpp
Print this page
rev 10257 : 8149036: Add tracing for thread related events at os level
Reviewed-by: coleenp, mlarsson, dholmes
*** 30,39 ****
--- 30,40 ----
#include "code/vtableStubs.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/disassembler.hpp"
#include "interpreter/interpreter.hpp"
#include "jvm_solaris.h"
+ #include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp"
#include "mutex_solaris.inline.hpp"
#include "oops/oop.inline.hpp"
#include "os_share_solaris.hpp"
*** 66,75 ****
--- 67,77 ----
#include "services/runtimeService.hpp"
#include "utilities/decoder.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/growableArray.hpp"
+ #include "utilities/macros.hpp"
#include "utilities/vmError.hpp"
// put OS-includes here
# include <dlfcn.h>
# include <errno.h>
*** 734,743 ****
--- 736,748 ----
OSThread* osthr = thread->osthread();
osthr->set_lwp_id(_lwp_self()); // Store lwp in case we are bound
thread->_schedctl = (void *) schedctl_init();
+ log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
+ os::current_thread_id());
+
if (UseNUMA) {
int lgrp_id = os::numa_get_group_id();
if (lgrp_id != -1) {
thread->set_lgrp_id(lgrp_id);
}
*** 779,788 ****
--- 784,795 ----
// which frees the CodeHeap containing the Atomic::dec code
if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
Atomic::dec(&os::Solaris::_os_thread_count);
}
+ log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
+
if (UseDetachedThreads) {
thr_exit(NULL);
ShouldNotReachHere();
}
return NULL;
*** 851,860 ****
--- 858,870 ----
// initialize signal mask for this thread
// and save the caller's signal mask
os::Solaris::hotspot_sigmask(thread);
+ log_info(os, thread)("Thread attached (tid: " UINTX_FORMAT ").",
+ os::current_thread_id());
+
return true;
}
bool os::create_main_thread(JavaThread* thread) {
#ifdef ASSERT
*** 877,886 ****
--- 887,915 ----
os::Solaris::hotspot_sigmask(thread);
return true;
}
+ // Helper function to trace thread attributes, similar to os::Posix::describe_pthread_attr()
+ static char* describe_thr_create_attributes(char* buf, size_t buflen,
+ size_t stacksize, long flags)
+ {
+ stringStream ss(buf, buflen);
+ ss.print("stacksize: " SIZE_FORMAT "k, ", stacksize / 1024);
+ ss.print("flags: ");
+ #define PRINT_FLAG(f) if (flags & f) ss.print( XSTR(f) " ");
+ #define ALL(X) \
+ X(THR_SUSPENDED) \
+ X(THR_DETACHED) \
+ X(THR_BOUND) \
+ X(THR_NEW_LWP) \
+ X(THR_DAEMON)
+ ALL(PRINT_FLAG)
+ #undef ALL
+ #undef PRINT_FLAG
+ return buf;
+ }
bool os::create_thread(Thread* thread, ThreadType thr_type,
size_t stack_size) {
// Allocate the OSThread object
OSThread* osthread = new OSThread(NULL, NULL);
*** 972,985 ****
// In case we attempt to set the priority before the thread starts.
osthread->set_lwp_id(-1);
osthread->set_thread_id(-1);
status = thr_create(NULL, stack_size, java_start, thread, flags, &tid);
! if (status != 0) {
! if (PrintMiscellaneous && (Verbose || WizardMode)) {
! perror("os::create_thread");
}
thread->set_osthread(NULL);
// Need to clean up stuff we've allocated so far
delete osthread;
return false;
}
--- 1001,1021 ----
// In case we attempt to set the priority before the thread starts.
osthread->set_lwp_id(-1);
osthread->set_thread_id(-1);
status = thr_create(NULL, stack_size, java_start, thread, flags, &tid);
!
! char buf[64];
! if (status == 0) {
! log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ",
! (uintx) tid, describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags));
! } else {
! log_warning(os, thread)("Failed to start thread - thr_create failed (%s) for attributes: %s.",
! strerror(status), describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags));
}
+
+ if (status != 0) {
thread->set_osthread(NULL);
// Need to clean up stuff we've allocated so far
delete osthread;
return false;
}
< prev index next >