diff options
author | Martijn Coenen <maco@google.com> | 2015-07-15 14:25:23 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2015-08-31 09:25:13 +0000 |
commit | 0bcd97a7485d971c5276e19b1a6c2672539dc38d (patch) | |
tree | 816cd8525e2c8cbd275c6cec0402b11c0dd8d3ca /cmds | |
parent | 8f35ca973063e1449c5ec40b618393187a47ec58 (diff) | |
download | frameworks_native-0bcd97a7485d971c5276e19b1a6c2672539dc38d.zip frameworks_native-0bcd97a7485d971c5276e19b1a6c2672539dc38d.tar.gz frameworks_native-0bcd97a7485d971c5276e19b1a6c2672539dc38d.tar.bz2 |
Map realtime to clock_monotonic.
This maps a monotonic timestamp to the
corresponding real-time timestamp, which
can be used to match up the traces with
other logs that use real-time.
Also write clock_sync records first instead of at
the end, to avoid not being to write it due to the
buffer being full.
Bug: 23668823
Change-Id: I644aeea496197e194ec30f808f754e3e043d905f
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; |