diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-06 20:34:34 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-06 20:34:34 +0000 |
| commit | faffb072a4dd922eaa097eb9b638639b0dad8877 (patch) | |
| tree | 57aeabdc528ad3a44e10b7fcfe4796274a24815d /core/java/android/os/Debug.java | |
| parent | 3ef58c56b6569f8a0db1ba82aefe69d30d9d1511 (diff) | |
| parent | fd8ed85adb84b2822eb2a15550b17976758e44dd (diff) | |
Merge "Allow to attach jvmti agents from inside of process"
Diffstat (limited to 'core/java/android/os/Debug.java')
| -rw-r--r-- | core/java/android/os/Debug.java | 23 |
1 files changed, 23 insertions, 0 deletions
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); + } + } } |
