diff options
| author | 2017-11-06 21:12:50 +0000 | |
|---|---|---|
| committer | 2017-11-06 21:12:50 +0000 | |
| commit | 4c10ba499d60f88d24be147beee8ea321a07b34c (patch) | |
| tree | 4001b463ea0e12485b98a993d050932b4573b5a6 | |
| parent | 9c2323199f28c19164c0be971dfbe554f039a28d (diff) | |
| parent | b567ea9ddad6a6486b585f6ed27317561425f2e8 (diff) | |
Merge "Allow to attach jvmti agents from inside of process" am: faffb072a4 am: 491058e089
am: b567ea9dda
Change-Id: Ie2d729a7c46a558597d626d1ebd5227bf56b1f55
| -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 0eb47154638e..f01e9317d59c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -31015,6 +31015,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 1747f23785c4..e7af921382d1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -33756,6 +33756,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 5664391d2c76..9f02bc5b3668 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -31218,6 +31218,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 2e62eb6a5f97..2acf36fed85f 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; @@ -2347,4 +2350,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); + } + } } |