< prev index next >
src/os/windows/vm/os_windows.cpp
Print this page
rev 10257 : 8149036: Add tracing for thread related events at os level
Reviewed-by: coleenp, mlarsson
@@ -33,10 +33,11 @@
#include "code/vtableStubs.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/disassembler.hpp"
#include "interpreter/interpreter.hpp"
#include "jvm_windows.h"
+#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp"
#include "mutex_windows.inline.hpp"
#include "oops/oop.inline.hpp"
#include "os_share_windows.hpp"
@@ -434,20 +435,24 @@
int res = 30115; // non-java thread
if (thread->is_Java_thread()) {
res = 20115; // java thread
}
+ log_debug(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").", os::current_thread_id());
+
// Install a win32 structured exception handler around every thread created
// by VM, so VM can generate error dump when an exception occurred in non-
// Java thread (e.g. VM thread).
__try {
thread->run();
} __except(topLevelExceptionFilter(
(_EXCEPTION_POINTERS*)_exception_info())) {
// Nothing to do.
}
+ log_debug(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
+
// One less thread is executing
// When the VMThread gets here, the main thread may have already exited
// which frees the CodeHeap containing the Atomic::add code
if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
Atomic::dec_ptr((intptr_t*)&os::win32::_os_thread_count);
@@ -507,10 +512,14 @@
// Initial thread state is RUNNABLE
osthread->set_state(RUNNABLE);
thread->set_osthread(osthread);
+
+ log_debug(os, thread)("Thread attached (tid: " UINTX_FORMAT ").",
+ os::current_thread_id());
+
return true;
}
bool os::create_main_thread(JavaThread* thread) {
#ifdef ASSERT
@@ -603,15 +612,20 @@
thread,
CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION,
&thread_id);
if (thread_handle == NULL) {
+ log_warning(os, thread)("Failed to start thread - _beginthreadex failed (%s).",
+ strerror(errno));
+
// Need to clean up stuff we've allocated so far
CloseHandle(osthread->interrupt_event());
thread->set_osthread(NULL);
delete osthread;
return NULL;
+ } else {
+ log_debug(os, thread)("Thread started (tid: %u)", thread_id);
}
Atomic::inc_ptr((intptr_t*)&os::win32::_os_thread_count);
// Store info on the Win32 thread into the OSThread
< prev index next >