diff options
author | 2019-09-11 09:48:51 -0700 | |
---|---|---|
committer | 2019-09-11 19:41:04 +0000 | |
commit | 3b08bcce2d9c32e469ce11d247bed46439977cac (patch) | |
tree | cc719c563515446f647c01fbf170302ca349996c | |
parent | 0054aa59c50374751cc65e8de31a1d813912e67d (diff) |
Fixup inconsistency due to change in Plugin loading requirements.
Some time ago plugin loading was changed to always occur with the
thread in kNative (see commit 3a256b1d3689). This adds asserts that
to plugin loading that the state is correct, fixes an incorrect
lock-annotation and fixes a test plugin that was missed.
Test: ./test.py --host
Test: atest CtsJdwpTunnelHostTestCases
Test: atest CtsJvmtiAttachingHostTestCases
Change-Id: Ib27ab58e9a357fa308a33da13a86e8d65575e9f4
-rw-r--r-- | adbconnection/adbconnection.cc | 2 | ||||
-rw-r--r-- | runtime/plugin.cc | 5 | ||||
-rw-r--r-- | tools/tracefast-plugin/tracefast.cc | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/adbconnection/adbconnection.cc b/adbconnection/adbconnection.cc index db65d9c362..0824eb459b 100644 --- a/adbconnection/adbconnection.cc +++ b/adbconnection/adbconnection.cc @@ -878,7 +878,7 @@ void AdbConnectionState::StopDebuggerThreads() { } // The plugin initialization function. -extern "C" bool ArtPlugin_Initialize() REQUIRES_SHARED(art::Locks::mutator_lock_) { +extern "C" bool ArtPlugin_Initialize() { DCHECK(art::Runtime::Current()->GetJdwpProvider() == art::JdwpProvider::kAdbConnection); // TODO Provide some way for apps to set this maybe? DCHECK(gState == nullptr); diff --git a/runtime/plugin.cc b/runtime/plugin.cc index 6f1c5179f9..6b9e0081cf 100644 --- a/runtime/plugin.cc +++ b/runtime/plugin.cc @@ -19,6 +19,9 @@ #include <dlfcn.h> #include "android-base/stringprintf.h" +#include "base/locks.h" +#include "base/mutex.h" +#include "thread-current-inl.h" namespace art { @@ -32,6 +35,7 @@ Plugin::Plugin(const Plugin& other) : library_(other.library_), dlopen_handle_(n } bool Plugin::Load(/*out*/std::string* error_msg) { + Locks::mutator_lock_->AssertNotHeld(Thread::Current()); DCHECK(!IsLoaded()); void* res = dlopen(library_.c_str(), RTLD_LAZY); if (res == nullptr) { @@ -55,6 +59,7 @@ bool Plugin::Load(/*out*/std::string* error_msg) { } bool Plugin::Unload() { + Locks::mutator_lock_->AssertNotHeld(Thread::Current()); DCHECK(IsLoaded()); bool ret = true; void* handle = dlopen_handle_; diff --git a/tools/tracefast-plugin/tracefast.cc b/tools/tracefast-plugin/tracefast.cc index 45dfe5f1c6..782b5fe347 100644 --- a/tools/tracefast-plugin/tracefast.cc +++ b/tools/tracefast-plugin/tracefast.cc @@ -156,10 +156,10 @@ class TraceFastPhaseCB : public art::RuntimePhaseCallback { TraceFastPhaseCB gPhaseCallback; // The plugin initialization function. -extern "C" bool ArtPlugin_Initialize() REQUIRES_SHARED(art::Locks::mutator_lock_) { +extern "C" bool ArtPlugin_Initialize() { art::Runtime* runtime = art::Runtime::Current(); - art::ScopedThreadSuspension stsc(art::Thread::Current(), - art::ThreadState::kWaitingForMethodTracingStart); + art::ScopedThreadStateChange stsc(art::Thread::Current(), + art::ThreadState::kWaitingForMethodTracingStart); art::ScopedSuspendAll ssa("Add phase callback"); runtime->GetRuntimeCallbacks()->AddRuntimePhaseCallback(&gPhaseCallback); return true; |