Always allow agent attach on userdebug builds with kArtTiVersion
We added support for the jvmti-alike ArtTi for use by debuggers on
userdebug/eng builds of android. Extend this support to allow any
agent to be loaded on any process of a userdebug device. These agents
will need to make use of kArtTiVersion (0x70010200) envs.
Test: build
Test: ./test.py --host -j50
Test: ensure AS profiler continues to work with userdebug devices
Bug: 78195998
Change-Id: I984d1ea937eb49afb376a48bea3d67085192020e
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index c394fef..8f5295c 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1619,7 +1619,6 @@
}
static bool EnsureJvmtiPlugin(Runtime* runtime,
- bool allow_non_debuggable_tooling,
std::vector<Plugin>* plugins,
std::string* error_msg) {
constexpr const char* plugin_name = kIsDebugBuild ? "libopenjdkjvmtid.so" : "libopenjdkjvmti.so";
@@ -1631,10 +1630,13 @@
}
}
+ // TODO Rename Dbg::IsJdwpAllowed is IsDebuggingAllowed.
+ DCHECK(Dbg::IsJdwpAllowed() || !runtime->IsJavaDebuggable())
+ << "Being debuggable requires that jdwp (i.e. debugging) is allowed.";
// Is the process debuggable? Otherwise, do not attempt to load the plugin unless we are
// specifically allowed.
- if (!allow_non_debuggable_tooling && !runtime->IsJavaDebuggable()) {
- *error_msg = "Process is not debuggable.";
+ if (!Dbg::IsJdwpAllowed()) {
+ *error_msg = "Process is not allowed to load openjdkjvmti plugin. Process must be debuggable";
return false;
}
@@ -1654,12 +1656,9 @@
// revisit this and make sure we're doing this on the right thread
// (and we synchronize access to any shared data structures like "agents_")
//
-void Runtime::AttachAgent(JNIEnv* env,
- const std::string& agent_arg,
- jobject class_loader,
- bool allow_non_debuggable_tooling) {
+void Runtime::AttachAgent(JNIEnv* env, const std::string& agent_arg, jobject class_loader) {
std::string error_msg;
- if (!EnsureJvmtiPlugin(this, allow_non_debuggable_tooling, &plugins_, &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());