diff options
| author | 2019-02-01 01:09:08 +0000 | |
|---|---|---|
| committer | 2019-02-01 01:09:08 +0000 | |
| commit | ec120a33c3385345e42e18199bf61d6b3cccb3dd (patch) | |
| tree | 930f3405f6cd753c9ad68c7c51f98fd569a740dc | |
| parent | f7207298a7b786222efae3ece65b8f2ff70b13b9 (diff) | |
| parent | 4d8546d4ba5ad7871766115fc2d2d77e1257b156 (diff) | |
Merge "Make profileable_from_shell apps dumpable."
| -rw-r--r-- | core/java/com/android/internal/os/Zygote.java | 5 | ||||
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 8 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ProcessList.java | 4 |
3 files changed, 16 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index 474d4d7cd90e..b881aef221ce 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -94,6 +94,11 @@ public final class Zygote { */ 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. */ public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE; /** Default external storage should be mounted. */ diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 6ee960668a3e..b7837ef77337 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -276,6 +276,7 @@ enum MountExternalKind { // Must match values in com.android.internal.os.Zygote. enum RuntimeFlags : uint32_t { DEBUG_ENABLE_JDWP = 1, + PROFILE_FROM_SHELL = 1 << 15, }; // 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) { 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()) { // Work around ARM kernel ASLR lossage (http://b/5817320). diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 9cbd065e7cfe..f90c0cab984a 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -58,7 +58,6 @@ import android.content.res.Resources; import android.graphics.Point; import android.net.LocalSocket; import android.net.LocalSocketAddress; -import android.net.Uri; import android.os.AppZygote; import android.os.Binder; import android.os.Build; @@ -1481,6 +1480,9 @@ public final class ProcessList { mService.mSafeMode == true) { 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"))) { runtimeFlags |= Zygote.DEBUG_ENABLE_CHECKJNI; } |