OSDN Git Service

Frameworks/base: Add tracing system properties
authorAndreas Gampe <agampe@google.com>
Tue, 23 Jun 2015 04:09:36 +0000 (21:09 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 25 Jun 2015 01:44:05 +0000 (18:44 -0700)
Add system properties to support zygote-started method tracing.
These are needed as the limit on system properties does not allow
the reuse of the runtime extra options system property.

Bug: 21760614

(cherry picked from commit 98f406f6f31660d0f5ee32113ffadc720b426dc6)

Change-Id: I3785cc5715acadbee81ef7b45081ed780f1351d3

core/jni/AndroidRuntime.cpp

index 6e8da65..f73c142 100644 (file)
@@ -587,6 +587,8 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
     char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:")-1 + PROPERTY_VALUE_MAX];
     char nativeBridgeLibrary[sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX];
     char cpuAbiListBuf[sizeof("--cpu-abilist=") + PROPERTY_VALUE_MAX];
+    char methodTraceFileBuf[sizeof("-Xmethod-trace-file:") + PROPERTY_VALUE_MAX];
+    char methodTraceFileSizeBuf[sizeof("-Xmethod-trace-file-size:") + PROPERTY_VALUE_MAX];
 
     bool checkJni = false;
     property_get("dalvik.vm.checkjni", propBuf, "");
@@ -847,6 +849,24 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
                        profileMaxStackDepth,
                        "-Xprofile-max-stack-depth:");
 
+    /*
+     * Tracing options.
+     */
+    property_get("dalvik.vm.method-trace", propBuf, "false");
+    if (strcmp(propBuf, "true") == 0) {
+        addOption("-Xmethod-trace");
+        parseRuntimeOption("dalvik.vm.method-trace-file",
+                           methodTraceFileBuf,
+                           "-Xmethod-trace-file:");
+        parseRuntimeOption("dalvik.vm.method-trace-file-siz",
+                           methodTraceFileSizeBuf,
+                           "-Xmethod-trace-file-size:");
+        property_get("dalvik.vm.method-trace-stream", propBuf, "false");
+        if (strcmp(propBuf, "true") == 0) {
+            addOption("-Xmethod-trace-stream");
+        }
+    }
+
     // Native bridge library. "0" means that native bridge is disabled.
     property_get("ro.dalvik.vm.native.bridge", propBuf, "");
     if (propBuf[0] == '\0') {