diff options
author | Carmen Jackson <carmenjackson@google.com> | 2018-05-22 10:29:47 -0700 |
---|---|---|
committer | Carmen Jackson <carmenjackson@google.com> | 2018-05-23 11:36:27 -0700 |
commit | 65ecfbba620e4710331b26db4ebf087ca6d92a2b (patch) | |
tree | 2db68e8f984823980dc8e150b68e1cfb5a406a0e | |
parent | 01966a45b694e7e47f12ffbe5891e2168a2cfd40 (diff) | |
download | native-65ecfbba620e4710331b26db4ebf087ca6d92a2b.tar.gz |
Atrace: Add the debug.atrace.user_initiated property.
This will ensure that, when we're tracing, the
debug.atrace.user_initiated tracing property will be set to 1.
We can then reliably use that property to determine whether an atrace
trace is in progress. Previously, we were using the
debug.atrace.tags.enableflags property, which is only set to a value
when a userspace tracepoint is being traced.
Bug: 79998861
Test: Took traces of only the 'sync' tag and verified with logging
that Traceur was representing the trace state correctly when entering
and exiting the app.
Test: Took a trace using the default category list and saw other
userspace tracepoints in the output (such as activityStart).
Change-Id: Iaf807f14ee65dc14e85d3d8d2ba489fcf742e3cc
-rw-r--r-- | cmds/atrace/atrace.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 90609379ff..fe9dd568fc 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -58,6 +58,7 @@ using std::string; #define MAX_SYS_FILES 10 const char* k_traceTagsProperty = "debug.atrace.tags.enableflags"; +const char* k_userInitiatedTraceProperty = "debug.atrace.user_initiated"; const char* k_traceAppsNumberProperty = "debug.atrace.app_number"; const char* k_traceAppsPropertyTemplate = "debug.atrace.app_%d"; @@ -447,6 +448,16 @@ static bool setTraceOverwriteEnable(bool enable) return setKernelOptionEnable(k_tracingOverwriteEnablePath, enable); } +// Set the user initiated trace property +static bool setUserInitiatedTraceProperty(bool enable) +{ + if (!android::base::SetProperty(k_userInitiatedTraceProperty, enable ? "1" : "")) { + fprintf(stderr, "error setting user initiated strace system property\n"); + return false; + } + return true; +} + // Enable or disable kernel tracing. static bool setTracingEnabled(bool enable) { @@ -840,6 +851,8 @@ static bool setUpKernelTracing() { bool ok = true; + ok &= setUserInitiatedTraceProperty(true); + // Set up the tracing options. ok &= setCategoriesEnableFromFile(g_categoriesFile); ok &= setTraceOverwriteEnable(g_traceOverwrite); @@ -887,6 +900,7 @@ static void cleanUpKernelTracing() setTraceBufferSizeKB(1); setPrintTgidEnableIfPresent(false); setKernelTraceFuncs(NULL); + setUserInitiatedTraceProperty(false); } // Enable tracing in the kernel. |