diff options
author | 2017-11-06 20:46:12 +0000 | |
---|---|---|
committer | 2017-11-06 20:46:12 +0000 | |
commit | 491058e08968a4deb7b7b04c5af15d3538e032cd (patch) | |
tree | 57aeabdc528ad3a44e10b7fcfe4796274a24815d | |
parent | 50fb8ff6da4dbb29fc10fbb01e8cef41f4f7b7ac (diff) | |
parent | faffb072a4dd922eaa097eb9b638639b0dad8877 (diff) |
Merge "Allow to attach jvmti agents from inside of process"
am: faffb072a4
Change-Id: I1f87e45ad3a7c93ab3ba7fd27ac57a1768885faa
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | api/test-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/os/Debug.java | 23 |
4 files changed, 26 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index a8250e256c97..d43dcb893ef2 100644 --- a/api/current.txt +++ b/api/current.txt @@ -30727,6 +30727,7 @@ package android.os { } public final class Debug { + method public static void attachJvmtiAgent(java.lang.String, java.lang.String) throws java.io.IOException; method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; method public static boolean dumpService(java.lang.String, java.io.FileDescriptor, java.lang.String[]); diff --git a/api/system-current.txt b/api/system-current.txt index 3b0da5ee3438..8f19a687c34d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -33450,6 +33450,7 @@ package android.os { } public final class Debug { + method public static void attachJvmtiAgent(java.lang.String, java.lang.String) throws java.io.IOException; method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; method public static boolean dumpService(java.lang.String, java.io.FileDescriptor, java.lang.String[]); diff --git a/api/test-current.txt b/api/test-current.txt index 97bc448ba1bf..9280e04d3287 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -30837,6 +30837,7 @@ package android.os { } public final class Debug { + method public static void attachJvmtiAgent(java.lang.String, java.lang.String) throws java.io.IOException; method public static deprecated void changeDebugPort(int); method public static void dumpHprofData(java.lang.String) throws java.io.IOException; method public static boolean dumpService(java.lang.String, java.io.FileDescriptor, java.lang.String[]); diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 2efde23275ab..3286e6ec6ef9 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -16,11 +16,14 @@ package android.os; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.AppGlobals; import android.content.Context; import android.util.Log; import com.android.internal.util.FastPrintWriter; +import com.android.internal.util.Preconditions; import com.android.internal.util.TypedProperties; import dalvik.system.VMDebug; @@ -2336,4 +2339,24 @@ public final class Debug public static String getCaller() { return getCaller(Thread.currentThread().getStackTrace(), 0); } + + /** + * Attach a library as a jvmti agent to the current runtime. + * + * @param library library containing the agent + * @param options options passed to the agent + * + * @throws IOException If the agent could not be attached + */ + public static void attachJvmtiAgent(@NonNull String library, @Nullable String options) + throws IOException { + Preconditions.checkNotNull(library); + Preconditions.checkArgument(!library.contains("=")); + + if (options == null) { + VMDebug.attachAgent(library); + } else { + VMDebug.attachAgent(library + "=" + options); + } + } } |