Index: vm/vmcore/include/jvmti_internal.h =================================================================== --- vm/vmcore/include/jvmti_internal.h (revision 467325) +++ vm/vmcore/include/jvmti_internal.h (working copy) @@ -151,6 +151,7 @@ Lock_Manager TIenvs_lock; Lock_Manager dcList_lock; VMBreakPoints* vm_brpt; + hythread_tls_key_t TL_ti_enabled; //thread local TI flag DebugUtilsTI(); @@ -166,6 +167,10 @@ void setEnabled(); void setDisabled(); + bool isLocallyEnabled(); + void setLocallyEnabled(); + void setLocallyDisabled(); + jvmtiPhase getPhase() { return phase; Index: vm/vmcore/src/jvmti/jvmti_thread.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_thread.cpp (revision 467325) +++ vm/vmcore/src/jvmti/jvmti_thread.cpp (working copy) @@ -481,6 +481,7 @@ jvmtiThreadInfo* info_ptr) { TRACE2("jvmti.thread", "GetThreadInfo called"); + DebugUtilsTI *ti = VM_Global_State::loader_env->TI; SuspendEnabledChecker sec; /* * Check given env & current phase. @@ -500,6 +501,8 @@ else thread = jthread_self(); + ti->setLocallyDisabled();//-----------------------------------V + jclass cl = GetObjectClass(jvmti_test_jenv, thread); jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "getName","()Ljava/lang/String;"); jstring name = jvmti_test_jenv -> CallObjectMethod (thread, id); @@ -517,6 +520,8 @@ id = jvmti_test_jenv -> GetMethodID(cl, "getContextClassLoader","()Ljava/lang/ClassLoader;"); info_ptr -> context_class_loader = jvmti_test_jenv -> CallObjectMethod (thread, id); + ti->setLocallyEnabled();//------------------------------------^ + return JVMTI_ERROR_NONE; } @@ -652,6 +657,7 @@ JNIEnv * jni_env; TRACE2("jvmti.thread", "RunAgentThread called"); + DebugUtilsTI *ti = VM_Global_State::loader_env->TI; SuspendEnabledChecker sec; /* * Check given env & current phase. @@ -670,6 +676,8 @@ return JVMTI_ERROR_NULL_POINTER; } + ti->setLocallyDisabled();//-----------------------------------V + // Set daemon flag for the thread jclass thread_class = GetObjectClass(jvmti_test_jenv, thread); assert(thread_class); @@ -688,6 +696,8 @@ attrs.jvmti_env = env; jthread_create_with_function(jni_env, thread, &attrs, proc, arg); + ti->setLocallyEnabled();//-----------------------------------^ + return JVMTI_ERROR_NONE; } Index: vm/vmcore/src/jvmti/jvmti.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti.cpp (revision 467325) +++ vm/vmcore/src/jvmti/jvmti.cpp (working copy) @@ -317,12 +317,16 @@ assert(res == JVMTI_ERROR_NONE); vm_brpt = new VMBreakPoints(); assert(vm_brpt); + IDATA status = hythread_tls_alloc(&TL_ti_enabled); + assert(status == TM_ERROR_NONE); + return; } DebugUtilsTI::~DebugUtilsTI() { ReleaseNotifyLists(); + hythread_tls_free(TL_ti_enabled); delete vm_brpt; return; } @@ -690,8 +694,22 @@ this->agents = agents; } +bool DebugUtilsTI::isLocallyEnabled() { + //default value is that ti enabled on thread level + return hythread_tls_get(hythread_self(), this->TL_ti_enabled) == NULL; +} + +void DebugUtilsTI::setLocallyEnabled() { + //default value is that ti enabled on thread level + hythread_tls_set(hythread_self(), this->TL_ti_enabled, NULL); +} + +void DebugUtilsTI::setLocallyDisabled() { + hythread_tls_set(hythread_self(), this->TL_ti_enabled, this); +} + bool DebugUtilsTI::isEnabled() { - return status; + return status && isLocallyEnabled(); } void DebugUtilsTI::setEnabled() { Index: vm/vmcore/src/jvmti/jvmti_thread_group.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_thread_group.cpp (revision 467325) +++ vm/vmcore/src/jvmti/jvmti_thread_group.cpp (working copy) @@ -46,6 +46,7 @@ { TRACE2("jvmti.thread.group", "GetTopThreadGroups called"); SuspendEnabledChecker sec; + DebugUtilsTI *ti = VM_Global_State::loader_env->TI; /* * Check given env & current phase. */ @@ -58,6 +59,8 @@ return JVMTI_ERROR_NULL_POINTER; } + ti->setLocallyDisabled();//-----------------------------------V + jclass cl = struct_Class_to_java_lang_Class_Handle(VM_Global_State::loader_env->java_lang_Thread_Class); jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "getThreadGroup","()Ljava/lang/ThreadGroup;"); @@ -75,6 +78,8 @@ parent = jvmti_test_jenv -> CallObjectMethod (group, id); } + ti->setLocallyEnabled();//-----------------------------------^ + jvmtiError jvmti_error = _allocate(sizeof(jthreadGroup*), (unsigned char **)groups_ptr); @@ -104,6 +109,7 @@ { TRACE2("jvmti.thread.group", "GetThreadGroupInfo called"); SuspendEnabledChecker sec; + DebugUtilsTI *ti = VM_Global_State::loader_env->TI; /* * Check given env & current phase. */ @@ -120,6 +126,8 @@ return JVMTI_ERROR_NULL_POINTER; } + ti->setLocallyDisabled();//-----------------------------------V + jclass cl = GetObjectClass(jvmti_test_jenv, group); jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "getParent","()Ljava/lang/ThreadGroup;"); info_ptr -> parent = jvmti_test_jenv -> CallObjectMethod (group, id); @@ -134,6 +142,8 @@ id = jvmti_test_jenv -> GetMethodID(cl, "isDaemon","()Z"); info_ptr -> is_daemon = jvmti_test_jenv -> CallBooleanMethod (group, id); + ti->setLocallyEnabled();//-----------------------------------^ + return JVMTI_ERROR_NONE; } @@ -154,6 +164,7 @@ { TRACE2("jvmti.thread.group", "GetThreadGroupChildren called"); SuspendEnabledChecker sec; + DebugUtilsTI *ti = VM_Global_State::loader_env->TI; /* * Check given env & current phase. */ @@ -171,6 +182,8 @@ return JVMTI_ERROR_NULL_POINTER; } + ti->setLocallyDisabled();//-----------------------------------V + jclass cl = GetObjectClass(jvmti_test_jenv, group); jobjectArray jg = jvmti_test_jenv -> NewObjectArray(10, cl, 0); jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "enumerate","([Ljava/lang/ThreadGroup;)I"); @@ -181,6 +194,8 @@ if (JVMTI_ERROR_NONE != jvmti_error) { + + ti->setLocallyEnabled();//-----------------------------------^ return jvmti_error; } @@ -198,6 +213,9 @@ jobjectArray jt = jvmti_test_jenv -> NewObjectArray(10, cll, 0); id = jvmti_test_jenv -> GetMethodID(cl, "enumerate","([Ljava/lang/Thread;Z)I"); cc = jvmti_test_jenv -> CallIntMethod (group, id, jt, JNI_FALSE); + + ti->setLocallyEnabled();//-----------------------------------^ + jthread * threads = NULL; jvmti_error = _allocate(sizeof(jthread) * cc, (unsigned char **)&threads);