diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 01ad2f0..ec20e91 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -444,7 +444,7 @@ void AndroidRuntime::parseExtraOpts(char* extraOptsBuf) * * Returns 0 on success. */ -int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) +int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote) { int result = -1; JavaVMInitArgs initArgs; @@ -634,25 +634,29 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) } } - /* enable debugging; set suspend=y to pause during VM init */ - /* use android ADB transport */ - opt.optionString = - "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y"; - mOptions.add(opt); + /* + * Enable debugging only for apps forked from zygote. + * Set suspend=y to pause during VM init and use android ADB transport. + */ + if (zygote) { + opt.optionString = + "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y"; + mOptions.add(opt); - ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF"); - if (checkJni) { - /* extended JNI checking */ - opt.optionString = "-Xcheck:jni"; - mOptions.add(opt); + ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF"); + if (checkJni) { + /* extended JNI checking */ + opt.optionString = "-Xcheck:jni"; + mOptions.add(opt); - /* set a cap on JNI global references */ - opt.optionString = "-Xjnigreflimit:2000"; - mOptions.add(opt); + /* set a cap on JNI global references */ + opt.optionString = "-Xjnigreflimit:2000"; + mOptions.add(opt); - /* with -Xcheck:jni, this provides a JNI function call trace */ - //opt.optionString = "-verbose:jni"; - //mOptions.add(opt); + /* with -Xcheck:jni, this provides a JNI function call trace */ + //opt.optionString = "-verbose:jni"; + //mOptions.add(opt); + } } char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:") + sizeof(propBuf)]; @@ -807,7 +811,7 @@ char* AndroidRuntime::toSlashClassName(const char* className) * Passes the main function two arguments, the class name and the specified * options string. */ -void AndroidRuntime::start(const char* className, const char* options) +void AndroidRuntime::start(const char* className, const char* options, bool zygote) { ALOGD("\n>>>>>> AndroidRuntime START %s <<<<<<\n", className != NULL ? className : "(unknown)"); @@ -840,7 +844,7 @@ void AndroidRuntime::start(const char* className, const char* options) /* start the virtual machine */ JNIEnv* env; - if (startVm(&mJavaVM, &env) != 0) { + if (startVm(&mJavaVM, &env, zygote) != 0) { return; } onVmCreated(env); |