summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2015-08-10 18:55:34 +0200
committerSebastien Hertz <shertz@google.com>2015-08-10 20:39:13 +0200
commit7a09b8322cab26d6e3da1362d3c74964ae66b5d4 (patch)
tree268e2334d28f33d87c2b4d8492b9e9726094e603 /core
parent90b030bae8cc1f13da7948fef4aff1d171a2885a (diff)
downloadframeworks_base-7a09b8322cab26d6e3da1362d3c74964ae66b5d4.zip
frameworks_base-7a09b8322cab26d6e3da1362d3c74964ae66b5d4.tar.gz
frameworks_base-7a09b8322cab26d6e3da1362d3c74964ae66b5d4.tar.bz2
Allow debugging only for apps forked from zygote
When starting the runtime from app_process, we only pass JDWP options if starting zygote. It prevents from opening a JDWP connection in non-zygote programs while Android apps (forked from zygote) remain debuggable. Bug: 23050463 Change-Id: If8ea719063a65db4cdeed69a838b52e87b078b08
Diffstat (limited to 'core')
-rw-r--r--core/jni/AndroidRuntime.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index bae2cde..bcf20c9 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -535,7 +535,7 @@ bool AndroidRuntime::parseCompilerRuntimeOption(const char* property,
*
* Returns 0 on success.
*/
-int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
+int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote)
{
JavaVMInitArgs initArgs;
char propBuf[PROPERTY_VALUE_MAX];
@@ -671,9 +671,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC=");
- /* enable debugging; set suspend=y to pause during VM init */
- /* use android ADB transport */
- addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
+ /*
+ * Enable debugging only for apps forked from zygote.
+ * Set suspend=y to pause during VM init and use android ADB transport.
+ */
+ if (zygote) {
+ addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
+ }
parseRuntimeOption("dalvik.vm.lockprof.threshold",
lockProfThresholdBuf,
@@ -968,7 +972,7 @@ jstring AndroidRuntime::NewStringLatin1(JNIEnv* env, const char* bytes) {
* Passes the main function two arguments, the class name and the specified
* options string.
*/
-void AndroidRuntime::start(const char* className, const Vector<String8>& options)
+void AndroidRuntime::start(const char* className, const Vector<String8>& options, bool zygote)
{
ALOGD(">>>>>> START %s uid %d <<<<<<\n",
className != NULL ? className : "(unknown)", getuid());
@@ -1004,7 +1008,7 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options
JniInvocation jni_invocation;
jni_invocation.Init(NULL);
JNIEnv* env;
- if (startVm(&mJavaVM, &env) != 0) {
+ if (startVm(&mJavaVM, &env, zygote) != 0) {
return;
}
onVmCreated(env);