diff options
author | 2017-01-12 10:46:23 +0000 | |
---|---|---|
committer | 2017-01-12 10:46:24 +0000 | |
commit | cf4b86dfe464e520d52d3e5b2bc6472393b43b50 (patch) | |
tree | 354e00610ec25279a8c4b77e8b685e380815813f | |
parent | 1b8de86a54b04a56df97212ca584ff7188d32065 (diff) | |
parent | 98cf7cf8766770dba2718a6131345cc7f57c5bc7 (diff) |
Merge "Revert "ART: Ensure plugin is loaded on AttachAgent""
-rw-r--r-- | runtime/runtime.cc | 48 | ||||
-rw-r--r-- | test/909-attach-agent/expected.txt | 8 | ||||
-rwxr-xr-x | test/909-attach-agent/run | 10 |
3 files changed, 4 insertions, 62 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index df5fc5ce8a..2086d70791 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1364,39 +1364,6 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { return true; } -static bool EnsureJvmtiPlugin(Runtime* runtime, - std::vector<Plugin>* plugins, - std::string* error_msg) { - constexpr const char* plugin_name = kIsDebugBuild ? "libopenjdkjvmtid.so" : "libopenjdkjvmti.so"; - - // Is the plugin already loaded? - for (Plugin p : *plugins) { - if (p.GetLibrary() == plugin_name) { - return true; - } - } - - // Is the process debuggable? Otherwise, do not attempt to load the plugin. - if (!runtime->IsDebuggable()) { - *error_msg = "Process is not debuggable."; - return false; - } - - Plugin new_plugin = Plugin::Create(plugin_name); - - // Suspend all threads to protect ourself somewhat. - Thread* self = Thread::Current(); - ScopedObjectAccess soa(self); // Now we know we have the shared lock. - ScopedThreadSuspension sts(self, art::kWaitingForDebuggerToAttach); - ScopedSuspendAll ssa("EnsureJvmtiPlugin"); - if (!new_plugin.Load(error_msg)) { - return false; - } - - plugins->push_back(std::move(new_plugin)); - return true; -} - // Attach a new agent and add it to the list of runtime agents // // TODO: once we decide on the threading model for agents, @@ -1404,25 +1371,18 @@ static bool EnsureJvmtiPlugin(Runtime* runtime, // (and we synchronize access to any shared data structures like "agents_") // void Runtime::AttachAgent(const std::string& agent_arg) { - std::string error_msg; - if (!EnsureJvmtiPlugin(this, &plugins_, &error_msg)) { - LOG(WARNING) << "Could not load plugin: " << error_msg; - ScopedObjectAccess soa(Thread::Current()); - ThrowIOException("%s", error_msg.c_str()); - return; - } - ti::Agent agent(agent_arg); int res = 0; - ti::Agent::LoadError result = agent.Attach(&res, &error_msg); + std::string err; + ti::Agent::LoadError result = agent.Attach(&res, &err); if (result == ti::Agent::kNoError) { agents_.push_back(std::move(agent)); } else { - LOG(WARNING) << "Agent attach failed (result=" << result << ") : " << error_msg; + LOG(ERROR) << "Agent attach failed (result=" << result << ") : " << err; ScopedObjectAccess soa(Thread::Current()); - ThrowIOException("%s", error_msg.c_str()); + ThrowWrappedIOException("%s", err.c_str()); } } diff --git a/test/909-attach-agent/expected.txt b/test/909-attach-agent/expected.txt index c0bccd6486..eacc595aaf 100644 --- a/test/909-attach-agent/expected.txt +++ b/test/909-attach-agent/expected.txt @@ -1,11 +1,3 @@ Hello, world! Attached Agent for test 909-attach-agent Goodbye! -Hello, world! -Attached Agent for test 909-attach-agent -Goodbye! -Hello, world! -java.io.IOException: Process is not debuggable. - at dalvik.system.VMDebug.attachAgent(Native Method) - at Main.main(Main.java:27) -Goodbye! diff --git a/test/909-attach-agent/run b/test/909-attach-agent/run index 985341bd4f..aed6e83d67 100755 --- a/test/909-attach-agent/run +++ b/test/909-attach-agent/run @@ -24,14 +24,4 @@ fi ./default-run "$@" --experimental agents \ --experimental runtime-plugins \ --android-runtime-option -Xplugin:${plugin} \ - --android-runtime-option -Xfully-deoptable \ - --args agent:${agent}=909-attach-agent - -./default-run "$@" --experimental agents \ - --experimental runtime-plugins \ - --android-runtime-option -Xfully-deoptable \ - --args agent:${agent}=909-attach-agent - -./default-run "$@" --experimental agents \ - --experimental runtime-plugins \ --args agent:${agent}=909-attach-agent |