Skip the initialization of kernel event when atrace run with --append option. 72/99472/1
authorGihun Chang <gihun.chang@samsung.com>
Tue, 22 Nov 2016 05:50:20 +0000 (14:50 +0900)
committerGihun Chang <gihun.chang@samsung.com>
Wed, 23 Nov 2016 03:37:49 +0000 (12:37 +0900)
Change-Id: I49fcc426b831cb28b951d0133d2bd61f6c478a8f
Signed-off-by: Gihun Chang <gihun.chang@samsung.com>
src/atrace/atrace.cpp

index c51825d10a65034297bb32f900760e733adc0968..6293b06f0e9ec9871cfee2c73485bc4c8bf51f71 100755 (executable)
@@ -407,7 +407,7 @@ static bool setTracingEnabled(bool enable)
 }
 
 // Clear the contents of the kernel trace.
-static bool clearTrace()
+static bool clearKernelTrace()
 {
     return truncateFile(k_tracePath);
 }
@@ -671,18 +671,17 @@ static bool setUpTrace()
        }
        printf("Tags: 0x%llx, excludedTags: 0x%llx\n", tags, excludedTags);
     }
+
     ok &= startTrace();
-       if(!g_append_trace) {
-               // For debug
-               // printf("\nclear the trace\n");
-               //
-           ok &= clearTrace();
-       }
-    ok &= setTagsProperty(tags);
+    if(!g_append_trace) {
+        // Clear Kernel Trace
+        ok &= clearKernelTrace();
 
-    // Disable all the sysfs enables.  This is done as a separate loop from
-    // the enables to allow the same enable to exist in multiple categories.
-    ok &= disableKernelTraceEvents();
+        // Disable all the sysfs enables.  This is done as a separate loop from
+        // the enables to allow the same enable to exist in multiple categories.
+        ok &= disableKernelTraceEvents();
+    }
+    ok &= setTagsProperty(tags);
 
     // Enable all the sysfs enables that are in an enabled category.
     for (int i = 0; i < NELEM(k_categories); i++) {
@@ -932,7 +931,7 @@ static void showHelp(const char *cmd)
                     "  --async_dump    dump the current contents of circular trace buffer\n"
                     "  --async_stop    stop tracing and dump the current contents of circular\n"
                     "                    trace buffer\n"
-                    "  --append        append traces to the existing traces. do not clear the trace buffer\n"
+                    "  --append        append traces to the existing traces. do not clear the trace buffer\n and kernel trace events set"
                    "  --backup        back up the existing traces to /tmp/trace.backup and then clear the trace buffer\n"
                     "  --list_categories\n"
                     "                  list the available tracing categories\n"
@@ -1113,7 +1112,7 @@ int main(int argc, char **argv)
             printf("\ntrace aborted.\n");
             fflush(stdout);
         }
-        clearTrace();
+        clearKernelTrace();
     } else if (!ok) {
         fprintf(stderr, "unable to start tracing\n");
     }