* commit 'e9de1b4cef10922180cfe06049cf906160e2c315': Allow debugging only for apps forked from zygote
This commit is contained in:
@@ -304,9 +304,9 @@ int main(int argc, char* const argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (zygote) {
|
if (zygote) {
|
||||||
runtime.start("com.android.internal.os.ZygoteInit", args);
|
runtime.start("com.android.internal.os.ZygoteInit", args, zygote);
|
||||||
} else if (className) {
|
} else if (className) {
|
||||||
runtime.start("com.android.internal.os.RuntimeInit", args);
|
runtime.start("com.android.internal.os.RuntimeInit", args, zygote);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Error: no class name or --zygote supplied.\n");
|
fprintf(stderr, "Error: no class name or --zygote supplied.\n");
|
||||||
app_usage();
|
app_usage();
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ bool AndroidRuntime::parseCompilerRuntimeOption(const char* property,
|
|||||||
*
|
*
|
||||||
* Returns 0 on success.
|
* Returns 0 on success.
|
||||||
*/
|
*/
|
||||||
int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
|
int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote)
|
||||||
{
|
{
|
||||||
JavaVMInitArgs initArgs;
|
JavaVMInitArgs initArgs;
|
||||||
char propBuf[PROPERTY_VALUE_MAX];
|
char propBuf[PROPERTY_VALUE_MAX];
|
||||||
@@ -702,9 +702,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
|
|||||||
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
|
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
|
||||||
parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC=");
|
parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC=");
|
||||||
|
|
||||||
/* enable debugging; set suspend=y to pause during VM init */
|
/*
|
||||||
/* use android ADB transport */
|
* Enable debugging only for apps forked from zygote.
|
||||||
addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
|
* 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",
|
parseRuntimeOption("dalvik.vm.lockprof.threshold",
|
||||||
lockProfThresholdBuf,
|
lockProfThresholdBuf,
|
||||||
@@ -1000,7 +1004,7 @@ jstring AndroidRuntime::NewStringLatin1(JNIEnv* env, const char* bytes) {
|
|||||||
* Passes the main function two arguments, the class name and the specified
|
* Passes the main function two arguments, the class name and the specified
|
||||||
* options string.
|
* 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",
|
ALOGD(">>>>>> START %s uid %d <<<<<<\n",
|
||||||
className != NULL ? className : "(unknown)", getuid());
|
className != NULL ? className : "(unknown)", getuid());
|
||||||
@@ -1036,7 +1040,7 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options
|
|||||||
JniInvocation jni_invocation;
|
JniInvocation jni_invocation;
|
||||||
jni_invocation.Init(NULL);
|
jni_invocation.Init(NULL);
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
if (startVm(&mJavaVM, &env) != 0) {
|
if (startVm(&mJavaVM, &env, zygote) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onVmCreated(env);
|
onVmCreated(env);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static jclass findClass(JNIEnv* env, const char* className);
|
static jclass findClass(JNIEnv* env, const char* className);
|
||||||
|
|
||||||
void start(const char *classname, const Vector<String8>& options);
|
void start(const char *classname, const Vector<String8>& options, bool zygote);
|
||||||
|
|
||||||
void exit(int code);
|
void exit(int code);
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ private:
|
|||||||
const char* runtimeArg,
|
const char* runtimeArg,
|
||||||
const char* quotingArg);
|
const char* quotingArg);
|
||||||
void parseExtraOpts(char* extraOptsBuf, const char* quotingArg);
|
void parseExtraOpts(char* extraOptsBuf, const char* quotingArg);
|
||||||
int startVm(JavaVM** pJavaVM, JNIEnv** pEnv);
|
int startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote);
|
||||||
|
|
||||||
Vector<JavaVMOption> mOptions;
|
Vector<JavaVMOption> mOptions;
|
||||||
bool mExitWithoutCleanup;
|
bool mExitWithoutCleanup;
|
||||||
|
|||||||
Reference in New Issue
Block a user