diff options
| author | 2016-03-17 15:43:25 -0700 | |
|---|---|---|
| committer | 2016-03-21 13:51:59 -0700 | |
| commit | 71a74ac75c8687195d27642fa0db31a796102c59 (patch) | |
| tree | 6745eb9e450f27dacaedd82f03c3bf66a201916b /cmds/dumpstate/utils.cpp | |
| parent | 891b1ce1decbeb80081f22513925c14c9c2015ec (diff) | |
Capture systrace buffers.
When tracing is enabled (/sys/kernel/debug/tracing/tracing_on = 1),
dumpstate will run 'atrace --async_dump' and redirect its output to a
systrace.txt entry in the zip file.
BUG: 27419521
Change-Id: Ia6de46a691b25febac31331fe0aa8701c9a84ebb
Diffstat (limited to 'cmds/dumpstate/utils.cpp')
| -rw-r--r-- | cmds/dumpstate/utils.cpp | 22 | 
1 files changed, 21 insertions, 1 deletions
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index d21ef7bd03..7ed51ab035 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -474,6 +474,27 @@ int dump_file(const char *title, const char *path) {      return _dump_file_from_fd(title, path, fd);  } +int read_file_as_long(const char *path, long int *output) { +    int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC)); +    if (fd < 0) { +        int err = errno; +        MYLOGE("Error opening file descriptor for %s: %s\n", path, strerror(err)); +        return -1; +    } +    char buffer[50]; +    ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, sizeof(buffer))); +    if (bytes_read == -1) { +        MYLOGE("Error reading file %s: %s\n", path, strerror(errno)); +        return -2; +    } +    if (bytes_read == 0) { +        MYLOGE("File %s is empty\n", path); +        return -3; +    } +    *output = atoi(buffer); +    return 0; +} +  /* calls skip to gate calling dump_from_fd recursively   * in the specified directory. dump_from_fd defaults to   * dump_file_from_fd above when set to NULL. skip defaults @@ -676,7 +697,6 @@ int run_command_always(const char *title, int timeout_seconds, const char *args[          execvp(command, (char**) args);          // execvp's result will be handled after waitpid_with_timeout() below... -        _exit(-1); // ...but it doesn't hurt to force exit, just in case      }      /* handle parent case */  |