Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c10ba49 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Merge "Allow to attach jvmti agents from inside of process" am: faffb072 am: 491058e0

am: b567ea9d

Change-Id: Ie2d729a7c46a558597d626d1ebd5227bf56b1f55
parents 9c232319 b567ea9d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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[]);
+1 −0
Original line number Diff line number Diff line
@@ -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[]);
+1 −0
Original line number Diff line number Diff line
@@ -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[]);
+23 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}