Loading cmds/atrace/atrace.cpp +8 −32 Original line number Diff line number Diff line Loading @@ -448,8 +448,8 @@ static bool isTraceClock(const char *mode) return false; } char buf[100]; ssize_t n = read(fd, buf, 99); char buf[4097]; ssize_t n = read(fd, buf, 4096); close(fd); if (n == -1) { fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath, Loading @@ -473,38 +473,13 @@ static bool isTraceClock(const char *mode) return strcmp(mode, start) == 0; } // Read the trace_clock sysfs file and return true if it contains the requested // value. The trace_clock file format is: // local [global] counter uptime perf static bool traceClockContains(const char *mode) { int fd = open((g_traceFolder + k_traceClockPath).c_str(), O_RDONLY); if (fd == -1) { fprintf(stderr, "error opening %s: %s (%d)\n", k_traceClockPath, strerror(errno), errno); return false; } char buf[100]; ssize_t n = read(fd, buf, 99); close(fd); if (n == -1) { fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath, strerror(errno), errno); return false; } buf[n] = '\0'; return strstr(buf, mode) != NULL; } // Set the clock to the best available option while tracing. Use 'boot' if it's // available; otherwise, use 'mono'. // Enable or disable the kernel's use of the global clock. Disabling the global // clock will result in the kernel using a per-CPU local clock. // Any write to the trace_clock sysfs file will reset the buffer, so only // update it if the requested value is not the current value. static bool setClock() static bool setGlobalClockEnable(bool enable) { const char* clock = traceClockContains("boot") ? "boot" : "mono"; const char *clock = enable ? "global" : "local"; if (isTraceClock(clock)) { return true; Loading Loading @@ -803,7 +778,7 @@ static bool setUpTrace() ok &= setCategoriesEnableFromFile(g_categoriesFile); ok &= setTraceOverwriteEnable(g_traceOverwrite); ok &= setTraceBufferSizeKB(g_traceBufferSizeKB); ok &= setClock(); ok &= setGlobalClockEnable(true); ok &= setPrintTgidEnableIfPresent(true); ok &= setKernelTraceFuncs(g_kernelTraceFuncs); Loading Loading @@ -877,6 +852,7 @@ static void cleanUpTrace() // Set the options back to their defaults. setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); setGlobalClockEnable(false); setPrintTgidEnableIfPresent(false); setKernelTraceFuncs(NULL); } Loading cmds/atrace/atrace.rc +0 −4 Original line number Diff line number Diff line Loading @@ -124,10 +124,6 @@ on post-fs write /sys/kernel/debug/tracing/tracing_on 0 write /sys/kernel/tracing/tracing_on 0 # Set the trace clock to boot if it exists, falling back to mono if not. write /d/tracing/trace_clock mono write /d/tracing/trace_clock boot # Allow only the shell group to read and truncate the kernel trace. chown root shell /sys/kernel/debug/tracing/trace chown root shell /sys/kernel/tracing/trace Loading Loading
cmds/atrace/atrace.cpp +8 −32 Original line number Diff line number Diff line Loading @@ -448,8 +448,8 @@ static bool isTraceClock(const char *mode) return false; } char buf[100]; ssize_t n = read(fd, buf, 99); char buf[4097]; ssize_t n = read(fd, buf, 4096); close(fd); if (n == -1) { fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath, Loading @@ -473,38 +473,13 @@ static bool isTraceClock(const char *mode) return strcmp(mode, start) == 0; } // Read the trace_clock sysfs file and return true if it contains the requested // value. The trace_clock file format is: // local [global] counter uptime perf static bool traceClockContains(const char *mode) { int fd = open((g_traceFolder + k_traceClockPath).c_str(), O_RDONLY); if (fd == -1) { fprintf(stderr, "error opening %s: %s (%d)\n", k_traceClockPath, strerror(errno), errno); return false; } char buf[100]; ssize_t n = read(fd, buf, 99); close(fd); if (n == -1) { fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath, strerror(errno), errno); return false; } buf[n] = '\0'; return strstr(buf, mode) != NULL; } // Set the clock to the best available option while tracing. Use 'boot' if it's // available; otherwise, use 'mono'. // Enable or disable the kernel's use of the global clock. Disabling the global // clock will result in the kernel using a per-CPU local clock. // Any write to the trace_clock sysfs file will reset the buffer, so only // update it if the requested value is not the current value. static bool setClock() static bool setGlobalClockEnable(bool enable) { const char* clock = traceClockContains("boot") ? "boot" : "mono"; const char *clock = enable ? "global" : "local"; if (isTraceClock(clock)) { return true; Loading Loading @@ -803,7 +778,7 @@ static bool setUpTrace() ok &= setCategoriesEnableFromFile(g_categoriesFile); ok &= setTraceOverwriteEnable(g_traceOverwrite); ok &= setTraceBufferSizeKB(g_traceBufferSizeKB); ok &= setClock(); ok &= setGlobalClockEnable(true); ok &= setPrintTgidEnableIfPresent(true); ok &= setKernelTraceFuncs(g_kernelTraceFuncs); Loading Loading @@ -877,6 +852,7 @@ static void cleanUpTrace() // Set the options back to their defaults. setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); setGlobalClockEnable(false); setPrintTgidEnableIfPresent(false); setKernelTraceFuncs(NULL); } Loading
cmds/atrace/atrace.rc +0 −4 Original line number Diff line number Diff line Loading @@ -124,10 +124,6 @@ on post-fs write /sys/kernel/debug/tracing/tracing_on 0 write /sys/kernel/tracing/tracing_on 0 # Set the trace clock to boot if it exists, falling back to mono if not. write /d/tracing/trace_clock mono write /d/tracing/trace_clock boot # Allow only the shell group to read and truncate the kernel trace. chown root shell /sys/kernel/debug/tracing/trace chown root shell /sys/kernel/tracing/trace Loading