Loading cmds/atrace/atrace.cpp +21 −3 Original line number Original line Diff line number Diff line Loading @@ -277,9 +277,27 @@ static bool appendStr(const char* filename, const char* str) static void writeClockSyncMarker() static void writeClockSyncMarker() { { char buffer[128]; 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; 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 // Enable or disable a kernel option by writing a "1" or a "0" into a /sys Loading Loading @@ -706,7 +724,6 @@ static bool startTrace() // Disable tracing in the kernel. // Disable tracing in the kernel. static void stopTrace() static void stopTrace() { { writeClockSyncMarker(); setTracingEnabled(false); setTracingEnabled(false); } } Loading Loading @@ -982,6 +999,7 @@ int main(int argc, char **argv) // another. // another. ok = clearTrace(); ok = clearTrace(); writeClockSyncMarker(); if (ok && !async) { if (ok && !async) { // Sleep to allow the trace to be captured. // Sleep to allow the trace to be captured. struct timespec timeLeft; struct timespec timeLeft; Loading Loading
cmds/atrace/atrace.cpp +21 −3 Original line number Original line Diff line number Diff line Loading @@ -277,9 +277,27 @@ static bool appendStr(const char* filename, const char* str) static void writeClockSyncMarker() static void writeClockSyncMarker() { { char buffer[128]; 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; 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 // Enable or disable a kernel option by writing a "1" or a "0" into a /sys Loading Loading @@ -706,7 +724,6 @@ static bool startTrace() // Disable tracing in the kernel. // Disable tracing in the kernel. static void stopTrace() static void stopTrace() { { writeClockSyncMarker(); setTracingEnabled(false); setTracingEnabled(false); } } Loading Loading @@ -982,6 +999,7 @@ int main(int argc, char **argv) // another. // another. ok = clearTrace(); ok = clearTrace(); writeClockSyncMarker(); if (ok && !async) { if (ok && !async) { // Sleep to allow the trace to be captured. // Sleep to allow the trace to be captured. struct timespec timeLeft; struct timespec timeLeft; Loading