Rename debugFlags to runtimeFlags.
Also now pass the flags to the forked process through --runtime-flags instead
of converting to command line arguments and converting back to an integer.
bug: 30972906
bug: 63920015
Test: builds
Change-Id: I7f10c43dd916ca2d3b9b5141f17261eb7b64f49a
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 91d9d1e..e159495 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -28,7 +28,7 @@
/** @hide */
public final class Zygote {
/*
- * Bit values for "debugFlags" argument. The definitions are duplicated
+ * Bit values for "runtimeFlags" argument. The definitions are duplicated
* in the native code.
*/
@@ -75,7 +75,7 @@
* fork()ing and and before spawning any threads.
* @param gids null-ok; a list of UNIX gids that the new process should
* setgroups() to after fork and before spawning any threads.
- * @param debugFlags bit flags that enable debugging features.
+ * @param runtimeFlags bit flags that enable ART features.
* @param rlimits null-ok an array of rlimit tuples, with the second
* dimension having a length of 3 and representing
* (resource, rlim_cur, rlim_max). These are set via the posix
@@ -96,14 +96,14 @@
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error.
*/
- public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags,
+ public static int forkAndSpecialize(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
int[] fdsToIgnore, String instructionSet, String appDataDir) {
VM_HOOKS.preFork();
// Resets nice priority for zygote process.
resetNicePriority();
int pid = nativeForkAndSpecialize(
- uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
+ uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
fdsToIgnore, instructionSet, appDataDir);
// Enable tracing as soon as possible for the child process.
if (pid == 0) {
@@ -116,7 +116,7 @@
return pid;
}
- native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int debugFlags,
+ native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int runtimeFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
int[] fdsToIgnore, String instructionSet, String appDataDir);
@@ -137,7 +137,7 @@
* fork()ing and and before spawning any threads.
* @param gids null-ok; a list of UNIX gids that the new process should
* setgroups() to after fork and before spawning any threads.
- * @param debugFlags bit flags that enable debugging features.
+ * @param runtimeFlags bit flags that enable ART features.
* @param rlimits null-ok an array of rlimit tuples, with the second
* dimension having a length of 3 and representing
* (resource, rlim_cur, rlim_max). These are set via the posix
@@ -148,13 +148,13 @@
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error.
*/
- public static int forkSystemServer(int uid, int gid, int[] gids, int debugFlags,
+ public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
VM_HOOKS.preFork();
// Resets nice priority for zygote process.
resetNicePriority();
int pid = nativeForkSystemServer(
- uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
+ uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities);
// Enable tracing as soon as we enter the system_server.
if (pid == 0) {
Trace.setTracingEnabled(true);
@@ -163,7 +163,7 @@
return pid;
}
- native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int debugFlags,
+ native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities);
/**
@@ -177,9 +177,9 @@
*/
native protected static void nativeUnmountStorageOnInit();
- private static void callPostForkChildHooks(int debugFlags, boolean isSystemServer,
+ private static void callPostForkChildHooks(int runtimeFlags, boolean isSystemServer,
String instructionSet) {
- VM_HOOKS.postForkChild(debugFlags, isSystemServer, instructionSet);
+ VM_HOOKS.postForkChild(runtimeFlags, isSystemServer, instructionSet);
}
/**
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index 05f43e4..45cb840 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -230,7 +230,7 @@
fd = null;
pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids,
- parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo,
+ parsedArgs.runtimeFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo,
parsedArgs.niceName, fdsToClose, fdsToIgnore, parsedArgs.instructionSet,
parsedArgs.appDataDir);
} catch (ErrnoException ex) {
@@ -363,11 +363,9 @@
int[] gids;
/**
- * From --enable-jdwp, --enable-checkjni, --enable-assert,
- * --enable-safemode, --generate-debug-info, --enable-jni-logging,
- * --java-debuggable, and --native-debuggable.
+ * From --runtime-flags.
*/
- int debugFlags;
+ int runtimeFlags;
/** From --mount-external */
int mountExternal = Zygote.MOUNT_EXTERNAL_NONE;
@@ -483,26 +481,11 @@
targetSdkVersionSpecified = true;
targetSdkVersion = Integer.parseInt(
arg.substring(arg.indexOf('=') + 1));
- } else if (arg.equals("--enable-jdwp")) {
- debugFlags |= Zygote.DEBUG_ENABLE_JDWP;
- } else if (arg.equals("--enable-safemode")) {
- debugFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
- } else if (arg.equals("--enable-checkjni")) {
- debugFlags |= Zygote.DEBUG_ENABLE_CHECKJNI;
- } else if (arg.equals("--generate-debug-info")) {
- debugFlags |= Zygote.DEBUG_GENERATE_DEBUG_INFO;
- } else if (arg.equals("--always-jit")) {
- debugFlags |= Zygote.DEBUG_ALWAYS_JIT;
- } else if (arg.equals("--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")) {
- debugFlags |= Zygote.DEBUG_ENABLE_JNI_LOGGING;
- } else if (arg.equals("--enable-assert")) {
- debugFlags |= Zygote.DEBUG_ENABLE_ASSERT;
} else if (arg.equals("--runtime-args")) {
seenRuntimeArgs = true;
+ } else if (arg.startsWith("--runtime-flags=")) {
+ runtimeFlags = Integer.parseInt(
+ arg.substring(arg.indexOf('=') + 1));
} else if (arg.startsWith("--seinfo=")) {
if (seInfoSpecified) {
throw new IllegalArgumentException(
@@ -718,7 +701,7 @@
*/
public static void applyDebuggerSystemProperty(Arguments args) {
if (RoSystemProperties.DEBUGGABLE) {
- args.debugFlags |= Zygote.DEBUG_ENABLE_JDWP;
+ args.runtimeFlags |= Zygote.DEBUG_ENABLE_JDWP;
}
}
@@ -740,7 +723,7 @@
int peerUid = peer.getUid();
if (args.invokeWith != null && peerUid != 0 &&
- (args.debugFlags & Zygote.DEBUG_ENABLE_JDWP) == 0) {
+ (args.runtimeFlags & Zygote.DEBUG_ENABLE_JDWP) == 0) {
throw new ZygoteSecurityException("Peer is permitted to specify an"
+ "explicit invoke-with wrapper command only for debuggable"
+ "applications.");
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index c8c7ed9..03459c0 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -642,7 +642,7 @@
pid = Zygote.forkSystemServer(
parsedArgs.uid, parsedArgs.gid,
parsedArgs.gids,
- parsedArgs.debugFlags,
+ parsedArgs.runtimeFlags,
null,
parsedArgs.permittedCapabilities,
parsedArgs.effectiveCapabilities);