summaryrefslogtreecommitdiff
path: root/openjdkjvmti/OpenjdkJvmTi.cc
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-09-22 15:33:41 -0700
committer Alex Light <allight@google.com> 2017-09-25 11:35:38 -0700
commit7ddc23d9ea95848724754eae270a0a1ce108edb9 (patch)
tree3d68e2745d0be0cdf95c05d45edc94859f1438ac /openjdkjvmti/OpenjdkJvmTi.cc
parentba461c3c5b588b0b65d3cc99aa12fe46a673962c (diff)
Consolidate all JVMTI jthread decoding.
We had multiple places where we would decode jthreads. This meant that we did not always check all required constraints before using it. This CL consolidates all jthread decoding into the ThreadUtil::GetNativeThread function and adds a helper ThreadUtil::GetAliveNativeThread function to check the most common requirements on jthreads passed to JVMTI. Bug: 66709480 Test: ./test.py --host -j50 Test: cd openjdkjvmti && git grep -W FromManagedThread Change-Id: Ib6f4bc8510012e0332831bea67e1842a49092917
Diffstat (limited to 'openjdkjvmti/OpenjdkJvmTi.cc')
-rw-r--r--openjdkjvmti/OpenjdkJvmTi.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/openjdkjvmti/OpenjdkJvmTi.cc b/openjdkjvmti/OpenjdkJvmTi.cc
index 4339b2bdef..bac57f9bc6 100644
--- a/openjdkjvmti/OpenjdkJvmTi.cc
+++ b/openjdkjvmti/OpenjdkJvmTi.cc
@@ -1034,14 +1034,13 @@ class JvmtiFunctions {
ENSURE_VALID_ENV(env);
art::Thread* art_thread = nullptr;
if (event_thread != nullptr) {
- // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
+ // TODO The locking around this call is less then what we really want.
art::ScopedObjectAccess soa(art::Thread::Current());
art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
- art_thread = art::Thread::FromManagedThread(soa, event_thread);
-
- if (art_thread == nullptr || // The thread hasn't been started or is already dead.
- art_thread->IsStillStarting()) {
- // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
+ jvmtiError err = ERR(INTERNAL);
+ if (!ThreadUtil::GetAliveNativeThread(event_thread, soa, &art_thread, &err)) {
+ return err;
+ } else if (art_thread->IsStillStarting()) {
return ERR(THREAD_NOT_ALIVE);
}
}