summaryrefslogtreecommitdiff
path: root/cmds/incident
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-06-22 19:23:11 -0700
committerYi Jin <jinyithu@google.com>2017-07-24 11:50:33 -0700
commit0a3406fc4f8e9a8c8a9155fc7886a0496f692496 (patch)
tree653b35c7b28bb0ed441d42b3a0e1e55f333774d1 /cmds/incident
parent785750817b08794a8160cfb5628036dd30b4fbc0 (diff)
This cl does the following things:
0) Implements a skeleton of incident_helper 1) Implements FileSection class which calls incident_helper to parse file content to protobuf 2) Adds Kernel Wake Sources to incident.proto and makes it parsed by FileSection 3) Adds basic gtests to test FdBuffer, io_utils, FileSection implementation Bug: 62923266 Bug: 62926061 Test: manual - push incidentd, incident_helper and incident to my device and verify kernel wakeup sources file is able to be parsed. Change-Id: I2aa6b6158d962ce70e6fa6c8a9c42213a45ff41c
Diffstat (limited to 'cmds/incident')
-rw-r--r--cmds/incident/main.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp
index 91b7c22b2038..180342c85030 100644
--- a/cmds/incident/main.cpp
+++ b/cmds/incident/main.cpp
@@ -94,6 +94,33 @@ StatusListener::onReportFailed()
}
// ================================================================================
+static void section_list(FILE* out) {
+ IncidentSection sections[INCIDENT_SECTION_COUNT];
+ int i = 0;
+ int j = 0;
+ // sort the sections based on id
+ while (i < INCIDENT_SECTION_COUNT) {
+ IncidentSection curr = INCIDENT_SECTIONS[i];
+ for (int k = 0; k < j; k++) {
+ if (curr.id > sections[k].id) {
+ continue;
+ }
+ IncidentSection tmp = curr;
+ curr = sections[k];
+ sections[k] = tmp;
+ }
+ sections[j] = curr;
+ i++;
+ j++;
+ }
+
+ fprintf(out, "available sections:\n");
+ for (int i = 0; i < INCIDENT_SECTION_COUNT; ++i) {
+ fprintf(out, "id: %4d, name: %s\n", sections[i].id, sections[i].name);
+ }
+}
+
+// ================================================================================
static IncidentSection const*
find_section(const char* name)
{
@@ -127,6 +154,7 @@ usage(FILE* out)
fprintf(out, "OPTIONS\n");
fprintf(out, " -b (default) print the report to stdout (in proto format)\n");
fprintf(out, " -d send the report into dropbox\n");
+ fprintf(out, " -l list available sections\n");
fprintf(out, "\n");
fprintf(out, " SECTION the field numbers of the incident report fields to include\n");
fprintf(out, "\n");
@@ -141,14 +169,17 @@ main(int argc, char** argv)
// Parse the args
int opt;
- while ((opt = getopt(argc, argv, "bhd")) != -1) {
+ while ((opt = getopt(argc, argv, "bhdl")) != -1) {
switch (opt) {
- case 'b':
- destination = DEST_STDOUT;
- break;
case 'h':
usage(stdout);
return 0;
+ case 'l':
+ section_list(stdout);
+ return 0;
+ case 'b':
+ destination = DEST_STDOUT;
+ break;
case 'd':
destination = DEST_DROPBOX;
break;