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

Commit 4d8546d4 authored by Yabin Cui's avatar Yabin Cui
Browse files

Make profileable_from_shell apps dumpable.

It is needed to enable linux perf events based profiling
on the profileable apps.

Bug: 118835348
Test: build and boot blueline.
Test: test profiling profileable apps manually using simpleperf.
Change-Id: Iba11fef81151f0c9e30b0478f1dd9e4ab1c5ac8d
parent 6f68d494
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,11 @@ public final class Zygote {
     */
     */
    public static final int PROFILE_SYSTEM_SERVER = 1 << 14;
    public static final int PROFILE_SYSTEM_SERVER = 1 << 14;


    /**
     * Enable profiling from shell.
     */
    public static final int PROFILE_FROM_SHELL = 1 << 15;

    /** No external storage should be mounted. */
    /** No external storage should be mounted. */
    public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE;
    public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE;
    /** Default external storage should be mounted. */
    /** Default external storage should be mounted. */
+8 −0
Original line number Original line Diff line number Diff line
@@ -276,6 +276,7 @@ enum MountExternalKind {
// Must match values in com.android.internal.os.Zygote.
// Must match values in com.android.internal.os.Zygote.
enum RuntimeFlags : uint32_t {
enum RuntimeFlags : uint32_t {
  DEBUG_ENABLE_JDWP = 1,
  DEBUG_ENABLE_JDWP = 1,
  PROFILE_FROM_SHELL = 1 << 15,
};
};


// Forward declaration so we don't have to move the signal handler.
// Forward declaration so we don't have to move the signal handler.
@@ -1224,6 +1225,13 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
  if ((runtime_flags & RuntimeFlags::DEBUG_ENABLE_JDWP) != 0) {
  if ((runtime_flags & RuntimeFlags::DEBUG_ENABLE_JDWP) != 0) {
    EnableDebugger();
    EnableDebugger();
  }
  }
  if ((runtime_flags & RuntimeFlags::PROFILE_FROM_SHELL) != 0) {
    // simpleperf needs the process to be dumpable to profile it.
    if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
      ALOGE("prctl(PR_SET_DUMPABLE) failed: %s", strerror(errno));
      RuntimeAbort(env, __LINE__, "prctl(PR_SET_DUMPABLE, 1) failed");
    }
  }


  if (NeedsNoRandomizeWorkaround()) {
  if (NeedsNoRandomizeWorkaround()) {
    // Work around ARM kernel ASLR lossage (http://b/5817320).
    // Work around ARM kernel ASLR lossage (http://b/5817320).
+3 −1
Original line number Original line Diff line number Diff line
@@ -58,7 +58,6 @@ import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Point;
import android.net.LocalSocket;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.net.LocalSocketAddress;
import android.net.Uri;
import android.os.AppZygote;
import android.os.AppZygote;
import android.os.Binder;
import android.os.Binder;
import android.os.Build;
import android.os.Build;
@@ -1481,6 +1480,9 @@ public final class ProcessList {
                    mService.mSafeMode == true) {
                    mService.mSafeMode == true) {
                runtimeFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
                runtimeFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
            }
            }
            if ((app.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_PROFILEABLE_BY_SHELL) != 0) {
                runtimeFlags |= Zygote.PROFILE_FROM_SHELL;
            }
            if ("1".equals(SystemProperties.get("debug.checkjni"))) {
            if ("1".equals(SystemProperties.get("debug.checkjni"))) {
                runtimeFlags |= Zygote.DEBUG_ENABLE_CHECKJNI;
                runtimeFlags |= Zygote.DEBUG_ENABLE_CHECKJNI;
            }
            }