diff options
author | Martijn Coenen <maco@google.com> | 2015-09-07 07:30:19 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-07 07:30:19 +0000 |
commit | 5ca0c2ede8a8d3f499dd7d27832713d4ce16d4ba (patch) | |
tree | c999591604b70eeafd159362dd80f09bfbe8d6a8 /cmds | |
parent | 3c8a147c8394a32217bb65672387d69a49a31270 (diff) | |
parent | 624408eecb0d278cb1de1bb088699e25b319d15e (diff) | |
download | frameworks_native-5ca0c2ede8a8d3f499dd7d27832713d4ce16d4ba.zip frameworks_native-5ca0c2ede8a8d3f499dd7d27832713d4ce16d4ba.tar.gz frameworks_native-5ca0c2ede8a8d3f499dd7d27832713d4ce16d4ba.tar.bz2 |
am 624408ee: Merge "Map realtime to clock_monotonic." into mnc-dr-dev
* commit '624408eecb0d278cb1de1bb088699e25b319d15e':
Map realtime to clock_monotonic.
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/atrace/atrace.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 9def406..26c5b4a 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -264,9 +264,27 @@ static bool appendStr(const char* filename, const char* str) static void writeClockSyncMarker() { char buffer[128]; + int len = 0; + int fd = open(k_traceMarkerPath, O_WRONLY); + if (fd == -1) { + fprintf(stderr, "error opening %s: %s (%d)\n", k_traceMarkerPath, + strerror(errno), errno); + return; + } float now_in_seconds = systemTime(CLOCK_MONOTONIC) / 1000000000.0f; - snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); - writeStr(k_traceMarkerPath, buffer); + + len = snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + int64_t realtime_in_ms = systemTime(CLOCK_REALTIME) / 1000000; + len = snprintf(buffer, 128, "trace_event_clock_sync: realtime_ts=%" PRId64 "\n", realtime_in_ms); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + close(fd); } // Enable or disable a kernel option by writing a "1" or a "0" into a /sys @@ -646,7 +664,6 @@ static bool startTrace() // Disable tracing in the kernel. static void stopTrace() { - writeClockSyncMarker(); setTracingEnabled(false); } @@ -940,6 +957,7 @@ int main(int argc, char **argv) // another. ok = clearTrace(); + writeClockSyncMarker(); if (ok && !async) { // Sleep to allow the trace to be captured. struct timespec timeLeft; |