summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2015-08-10 18:55:34 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-10-19 00:12:33 +0200
commite510155dbdebb50048632810b1735d69f9e72638 (patch)
tree068adab1d5aba8f3eb4132d8ff7004a34a9292f0 /core
parent38add157784a2bb5ddb13558573ece99229bb3b0 (diff)
downloadframeworks_base-master.zip
frameworks_base-master.tar.gz
frameworks_base-master.tar.bz2
Allow debugging only for apps forked from zygoteHEADmaster
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 (cherry picked from commit 7a09b8322cab26d6e3da1362d3c74964ae66b5d4) Change-Id: Ib5b6d3bc4d45389993c3c54226df5a7b72479d19 Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'core')
-rw-r--r--core/jni/AndroidRuntime.cpp42
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);