Merge "Introduce DEBUG_JAVA_DEBUGGABLE." am: 4df43ad959 am: 27ffe754a4

am: 1852c380e0

Change-Id: I8fcc8b0329269a0b21057f973b3a7dc5d8d80284
This commit is contained in:
Nicolas Geoffray
2017-01-30 15:26:29 +00:00
committed by android-build-merger
4 changed files with 21 additions and 15 deletions

View File

@@ -352,8 +352,8 @@ public class ZygoteProcess {
if ((debugFlags & Zygote.DEBUG_ENABLE_SAFEMODE) != 0) { if ((debugFlags & Zygote.DEBUG_ENABLE_SAFEMODE) != 0) {
argsForZygote.add("--enable-safemode"); argsForZygote.add("--enable-safemode");
} }
if ((debugFlags & Zygote.DEBUG_ENABLE_DEBUGGER) != 0) { if ((debugFlags & Zygote.DEBUG_ENABLE_JDWP) != 0) {
argsForZygote.add("--enable-debugger"); argsForZygote.add("--enable-jdwp");
} }
if ((debugFlags & Zygote.DEBUG_ENABLE_CHECKJNI) != 0) { if ((debugFlags & Zygote.DEBUG_ENABLE_CHECKJNI) != 0) {
argsForZygote.add("--enable-checkjni"); argsForZygote.add("--enable-checkjni");
@@ -367,6 +367,9 @@ public class ZygoteProcess {
if ((debugFlags & Zygote.DEBUG_NATIVE_DEBUGGABLE) != 0) { if ((debugFlags & Zygote.DEBUG_NATIVE_DEBUGGABLE) != 0) {
argsForZygote.add("--native-debuggable"); argsForZygote.add("--native-debuggable");
} }
if ((debugFlags & Zygote.DEBUG_JAVA_DEBUGGABLE) != 0) {
argsForZygote.add("--java-debuggable");
}
if ((debugFlags & Zygote.DEBUG_ENABLE_ASSERT) != 0) { if ((debugFlags & Zygote.DEBUG_ENABLE_ASSERT) != 0) {
argsForZygote.add("--enable-assert"); argsForZygote.add("--enable-assert");
} }
@@ -379,9 +382,6 @@ public class ZygoteProcess {
} }
argsForZygote.add("--target-sdk-version=" + targetSdkVersion); argsForZygote.add("--target-sdk-version=" + targetSdkVersion);
//TODO optionally enable debuger
//argsForZygote.add("--enable-debugger");
// --setgroups is a comma-separated list // --setgroups is a comma-separated list
if (gids != null && gids.length > 0) { if (gids != null && gids.length > 0) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@@ -33,7 +33,7 @@ public final class Zygote {
*/ */
/** enable debugging over JDWP */ /** enable debugging over JDWP */
public static final int DEBUG_ENABLE_DEBUGGER = 1; public static final int DEBUG_ENABLE_JDWP = 1;
/** enable JNI checks */ /** enable JNI checks */
public static final int DEBUG_ENABLE_CHECKJNI = 1 << 1; public static final int DEBUG_ENABLE_CHECKJNI = 1 << 1;
/** enable Java programming language "assert" statements */ /** enable Java programming language "assert" statements */
@@ -46,8 +46,10 @@ public final class Zygote {
public static final int DEBUG_GENERATE_DEBUG_INFO = 1 << 5; public static final int DEBUG_GENERATE_DEBUG_INFO = 1 << 5;
/** Always use JIT-ed code. */ /** Always use JIT-ed code. */
public static final int DEBUG_ALWAYS_JIT = 1 << 6; public static final int DEBUG_ALWAYS_JIT = 1 << 6;
/** Make the code debuggable with turning off some optimizations. */ /** Make the code native debuggable by turning off some optimizations. */
public static final int DEBUG_NATIVE_DEBUGGABLE = 1 << 7; public static final int DEBUG_NATIVE_DEBUGGABLE = 1 << 7;
/** Make the code Java debuggable by turning off some optimizations. */
public static final int DEBUG_JAVA_DEBUGGABLE = 1 << 8;
/** No external storage should be mounted. */ /** No external storage should be mounted. */
public static final int MOUNT_EXTERNAL_NONE = 0; public static final int MOUNT_EXTERNAL_NONE = 0;

View File

@@ -336,8 +336,9 @@ class ZygoteConnection {
int[] gids; int[] gids;
/** /**
* From --enable-debugger, --enable-checkjni, --enable-assert, * From --enable-jdwp, --enable-checkjni, --enable-assert,
* --enable-safemode, --generate-debug-info and --enable-jni-logging. * --enable-safemode, --generate-debug-info, --enable-jni-logging,
* --java-debuggable, and --native-debuggable.
*/ */
int debugFlags; int debugFlags;
@@ -447,8 +448,8 @@ class ZygoteConnection {
targetSdkVersionSpecified = true; targetSdkVersionSpecified = true;
targetSdkVersion = Integer.parseInt( targetSdkVersion = Integer.parseInt(
arg.substring(arg.indexOf('=') + 1)); arg.substring(arg.indexOf('=') + 1));
} else if (arg.equals("--enable-debugger")) { } else if (arg.equals("--enable-jdwp")) {
debugFlags |= Zygote.DEBUG_ENABLE_DEBUGGER; debugFlags |= Zygote.DEBUG_ENABLE_JDWP;
} else if (arg.equals("--enable-safemode")) { } else if (arg.equals("--enable-safemode")) {
debugFlags |= Zygote.DEBUG_ENABLE_SAFEMODE; debugFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
} else if (arg.equals("--enable-checkjni")) { } else if (arg.equals("--enable-checkjni")) {
@@ -459,6 +460,8 @@ class ZygoteConnection {
debugFlags |= Zygote.DEBUG_ALWAYS_JIT; debugFlags |= Zygote.DEBUG_ALWAYS_JIT;
} else if (arg.equals("--native-debuggable")) { } else if (arg.equals("--native-debuggable")) {
debugFlags |= Zygote.DEBUG_NATIVE_DEBUGGABLE; debugFlags |= Zygote.DEBUG_NATIVE_DEBUGGABLE;
} else if (arg.equals("--java-debuggable")) {
debugFlags |= Zygote.DEBUG_JAVA_DEBUGGABLE;
} else if (arg.equals("--enable-jni-logging")) { } else if (arg.equals("--enable-jni-logging")) {
debugFlags |= Zygote.DEBUG_ENABLE_JNI_LOGGING; debugFlags |= Zygote.DEBUG_ENABLE_JNI_LOGGING;
} else if (arg.equals("--enable-assert")) { } else if (arg.equals("--enable-assert")) {
@@ -670,14 +673,14 @@ class ZygoteConnection {
* Applies debugger system properties to the zygote arguments. * Applies debugger system properties to the zygote arguments.
* *
* If "ro.debuggable" is "1", all apps are debuggable. Otherwise, * If "ro.debuggable" is "1", all apps are debuggable. Otherwise,
* the debugger state is specified via the "--enable-debugger" flag * the debugger state is specified via the "--enable-jdwp" flag
* in the spawn request. * in the spawn request.
* *
* @param args non-null; zygote spawner args * @param args non-null; zygote spawner args
*/ */
public static void applyDebuggerSystemProperty(Arguments args) { public static void applyDebuggerSystemProperty(Arguments args) {
if (RoSystemProperties.DEBUGGABLE) { if (RoSystemProperties.DEBUGGABLE) {
args.debugFlags |= Zygote.DEBUG_ENABLE_DEBUGGER; args.debugFlags |= Zygote.DEBUG_ENABLE_JDWP;
} }
} }
@@ -699,7 +702,7 @@ class ZygoteConnection {
int peerUid = peer.getUid(); int peerUid = peer.getUid();
if (args.invokeWith != null && peerUid != 0 && if (args.invokeWith != null && peerUid != 0 &&
(args.debugFlags & Zygote.DEBUG_ENABLE_DEBUGGER) == 0) { (args.debugFlags & Zygote.DEBUG_ENABLE_JDWP) == 0) {
throw new ZygoteSecurityException("Peer is permitted to specify an" throw new ZygoteSecurityException("Peer is permitted to specify an"
+ "explicit invoke-with wrapper command only for debuggable" + "explicit invoke-with wrapper command only for debuggable"
+ "applications."); + "applications.");

View File

@@ -3753,7 +3753,8 @@ public final class ActivityManagerService extends ActivityManagerNative
} }
int debugFlags = 0; int debugFlags = 0;
if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
debugFlags |= Zygote.DEBUG_ENABLE_DEBUGGER; debugFlags |= Zygote.DEBUG_ENABLE_JDWP;
debugFlags |= Zygote.DEBUG_JAVA_DEBUGGABLE;
// Also turn on CheckJNI for debuggable apps. It's quite // Also turn on CheckJNI for debuggable apps. It's quite
// awkward to turn on otherwise. // awkward to turn on otherwise.
debugFlags |= Zygote.DEBUG_ENABLE_CHECKJNI; debugFlags |= Zygote.DEBUG_ENABLE_CHECKJNI;