diff options
author | Mike Ma <yanmin@google.com> | 2019-09-30 16:49:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-09-30 16:49:32 +0000 |
commit | 90b4d056273351fbf777738c3e39805dd1b41436 (patch) | |
tree | 4241fe1b8e0b8b022a61bc9b2d0afd25765a01d1 | |
parent | 636c03ef9f96a1f932dc1e9cf092d25d4541372a (diff) | |
parent | 5c267879191a7a5e9d8c92c7e78174d32eb8f539 (diff) | |
download | native-90b4d056273351fbf777738c3e39805dd1b41436.tar.gz |
Merge "Add a dedicated function to dump incident report"
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 254e14203e..bedf81fb04 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -918,6 +918,31 @@ static void DoLogcat() { "-v", "uid", "-d", "*:v"}); } +static void DumpIncidentReport() { + if (!ds.IsZipping()) { + MYLOGD("Not dumping incident report because it's not a zipped bugreport\n"); + return; + } + DurationReporter duration_reporter("INCIDENT REPORT"); + const std::string path = ds.bugreport_internal_dir_ + "/tmp_incident_report"; + auto fd = android::base::unique_fd(TEMP_FAILURE_RETRY(open(path.c_str(), + O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))); + if (fd < 0) { + MYLOGE("Could not open %s to dump incident report.\n", path.c_str()); + return; + } + RunCommandToFd(fd, "", {"incident", "-u"}, CommandOptions::WithTimeout(120).Build()); + bool empty = 0 == lseek(fd, 0, SEEK_END); + if (!empty) { + // Use a different name from "incident.proto" + // /proto/incident.proto is reserved for incident service dump + // i.e. metadata for debugging. + ds.AddZipEntry(kProtoPath + "incident_report" + kProtoExt, path); + } + unlink(path.c_str()); +} + static void DumpIpTablesAsRoot() { RunCommand("IPTABLES", {"iptables", "-L", "-nvx"}); RunCommand("IP6TABLES", {"ip6tables", "-L", "-nvx"}); @@ -1490,6 +1515,9 @@ static Dumpstate::RunStatus dumpstate() { printf("========================================================\n"); // This differs from the usual dumpsys stats, which is the stats report data. RunDumpsys("STATSDSTATS", {"stats", "--metadata"}); + + RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(DumpIncidentReport); + return Dumpstate::RunStatus::OK; } |