Fixed C++ style on refactored function and variable names.
As described on
https://google.github.io/styleguide/cppguide.html#Function_Names :
"Ordinarily, functions should start with a capital letter and have a
capital letter for each new word (a.k.a. "upper camel case" or "Pascal
case")."
and
"Data members of classes (but not structs) additionally have trailing underscores. "
BUG: 26379932
Test: manual
Change-Id: I4b7f34b941c99547af667316d4b7d5e2749827d0
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 0cd06e5..fb508af 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -190,7 +190,7 @@
continue;
}
snprintf(path, sizeof(path), "%s/%s/%s", driverpath, de->d_name, filename);
- dumpFile(title, path);
+ DumpFile(title, path);
}
closedir(d);
@@ -258,7 +258,7 @@
// send SIGUSR1 to the anrd to generate a trace.
sprintf(buf, "%u", pid);
- if (runCommand("ANRD_DUMP", {"kill", "-SIGUSR1", buf},
+ if (RunCommand("ANRD_DUMP", {"kill", "-SIGUSR1", buf},
CommandOptions::WithTimeout(1).Build())) {
MYLOGE("anrd signal timed out. Please manually collect trace\n");
return false;
@@ -349,13 +349,13 @@
MYLOGD("Running '/system/bin/atrace --async_dump -o %s', which can take several minutes",
systrace_path.c_str());
- if (runCommand("SYSTRACE", {"/system/bin/atrace", "--async_dump", "-o", systrace_path},
+ if (RunCommand("SYSTRACE", {"/system/bin/atrace", "--async_dump", "-o", systrace_path},
CommandOptions::WithTimeout(120).Build())) {
MYLOGE("systrace timed out, its zip entry will be incomplete\n");
// TODO: run_command tries to kill the process, but atrace doesn't die
// peacefully; ideally, we should call strace to stop itself, but there is no such option
// yet (just a --async_stop, which stops and dump
- // if (runCommand("SYSTRACE", {"/system/bin/atrace", "--kill"})) {
+ // if (RunCommand("SYSTRACE", {"/system/bin/atrace", "--kill"})) {
// MYLOGE("could not stop systrace ");
// }
}
@@ -388,11 +388,11 @@
CommandOptions options = CommandOptions::WithTimeout(600).Build();
if (!zip_writer) {
// Write compressed and encoded raft logs to stdout if not zip_writer.
- runCommand("RAFT LOGS", {"logcompressor", "-r", RAFT_DIR}, options);
+ RunCommand("RAFT LOGS", {"logcompressor", "-r", RAFT_DIR}, options);
return;
}
- runCommand("RAFT LOGS", {"logcompressor", "-n", "-r", RAFT_DIR, "-o", raft_log_path}, options);
+ RunCommand("RAFT LOGS", {"logcompressor", "-n", "-r", RAFT_DIR, "-o", raft_log_path}, options);
if (!add_zip_entry("raft_log.txt", raft_log_path)) {
MYLOGE("Unable to add raft log %s to zip file\n", raft_log_path.c_str());
} else {
@@ -708,7 +708,7 @@
printf("Network: %s\n", network.c_str());
printf("Kernel: ");
- dumpFile(nullptr, "/proc/version");
+ DumpFile(nullptr, "/proc/version");
printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
printf("Bugreport format version: %s\n", version.c_str());
printf("Dumpstate info: id=%lu pid=%d dryRun=%d args=%s extraOptions=%s\n", id, getpid(),
@@ -836,14 +836,14 @@
}
static void dump_iptables() {
- runCommand("IPTABLES", {"iptables", "-L", "-nvx"});
- runCommand("IP6TABLES", {"ip6tables", "-L", "-nvx"});
- runCommand("IPTABLE NAT", {"iptables", "-t", "nat", "-L", "-nvx"});
+ RunCommand("IPTABLES", {"iptables", "-L", "-nvx"});
+ RunCommand("IP6TABLES", {"ip6tables", "-L", "-nvx"});
+ RunCommand("IPTABLE NAT", {"iptables", "-t", "nat", "-L", "-nvx"});
/* no ip6 nat */
- runCommand("IPTABLE MANGLE", {"iptables", "-t", "mangle", "-L", "-nvx"});
- runCommand("IP6TABLE MANGLE", {"ip6tables", "-t", "mangle", "-L", "-nvx"});
- runCommand("IPTABLE RAW", {"iptables", "-t", "raw", "-L", "-nvx"});
- runCommand("IP6TABLE RAW", {"ip6tables", "-t", "raw", "-L", "-nvx"});
+ RunCommand("IPTABLE MANGLE", {"iptables", "-t", "mangle", "-L", "-nvx"});
+ RunCommand("IP6TABLE MANGLE", {"ip6tables", "-t", "mangle", "-L", "-nvx"});
+ RunCommand("IPTABLE RAW", {"iptables", "-t", "raw", "-L", "-nvx"});
+ RunCommand("IP6TABLE RAW", {"ip6tables", "-t", "raw", "-L", "-nvx"});
}
static void dumpstate(const std::string& screenshot_path, const std::string& version) {
@@ -851,41 +851,41 @@
unsigned long timeout;
dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
- runCommand("UPTIME", {"uptime"});
+ RunCommand("UPTIME", {"uptime"});
dump_files("UPTIME MMC PERF", mmcblk0, skip_not_stat, dump_stat_from_fd);
dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
- dumpFile("MEMORY INFO", "/proc/meminfo");
- runCommand("CPU INFO", {"top", "-b", "-n", "1", "-H", "-s", "6", "-o",
+ DumpFile("MEMORY INFO", "/proc/meminfo");
+ RunCommand("CPU INFO", {"top", "-b", "-n", "1", "-H", "-s", "6", "-o",
"pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name"});
- runCommand("PROCRANK", {"procrank"}, CommandOptions::AS_ROOT_20);
- dumpFile("VIRTUAL MEMORY STATS", "/proc/vmstat");
- dumpFile("VMALLOC INFO", "/proc/vmallocinfo");
- dumpFile("SLAB INFO", "/proc/slabinfo");
- dumpFile("ZONEINFO", "/proc/zoneinfo");
- dumpFile("PAGETYPEINFO", "/proc/pagetypeinfo");
- dumpFile("BUDDYINFO", "/proc/buddyinfo");
- dumpFile("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
+ RunCommand("PROCRANK", {"procrank"}, CommandOptions::AS_ROOT_20);
+ DumpFile("VIRTUAL MEMORY STATS", "/proc/vmstat");
+ DumpFile("VMALLOC INFO", "/proc/vmallocinfo");
+ DumpFile("SLAB INFO", "/proc/slabinfo");
+ DumpFile("ZONEINFO", "/proc/zoneinfo");
+ DumpFile("PAGETYPEINFO", "/proc/pagetypeinfo");
+ DumpFile("BUDDYINFO", "/proc/buddyinfo");
+ DumpFile("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
- dumpFile("KERNEL WAKE SOURCES", "/d/wakeup_sources");
- dumpFile("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
- dumpFile("KERNEL SYNC", "/d/sync");
+ DumpFile("KERNEL WAKE SOURCES", "/d/wakeup_sources");
+ DumpFile("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
+ DumpFile("KERNEL SYNC", "/d/sync");
- runCommand("PROCESSES AND THREADS",
+ RunCommand("PROCESSES AND THREADS",
{"ps", "-A", "-T", "-Z", "-O", "pri,nice,rtprio,sched,pcy"});
- runCommand("LIBRANK", {"librank"}, CommandOptions::AS_ROOT_10);
+ RunCommand("LIBRANK", {"librank"}, CommandOptions::AS_ROOT_10);
- runCommand("PRINTENV", {"printenv"});
- runCommand("NETSTAT", {"netstat", "-n"});
+ RunCommand("PRINTENV", {"printenv"});
+ RunCommand("NETSTAT", {"netstat", "-n"});
struct stat s;
if (stat("/proc/modules", &s) != 0) {
MYLOGD("Skipping 'lsmod' because /proc/modules does not exist\n");
} else {
- runCommand("LSMOD", {"lsmod"});
+ RunCommand("LSMOD", {"lsmod"});
}
do_dmesg();
- runCommand("LIST OF OPEN FILES", {"lsof"}, CommandOptions::AS_ROOT_10);
+ RunCommand("LIST OF OPEN FILES", {"lsof"}, CommandOptions::AS_ROOT_10);
for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
@@ -899,34 +899,34 @@
MYLOGI("wrote screenshot: %s\n", screenshot_path.c_str());
}
- // dumpFile("EVENT LOG TAGS", "/etc/event-log-tags");
+ // DumpFile("EVENT LOG TAGS", "/etc/event-log-tags");
// calculate timeout
timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash");
if (timeout < 20000) {
timeout = 20000;
}
- runCommand("SYSTEM LOG", {"logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v"},
+ RunCommand("SYSTEM LOG", {"logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v"},
CommandOptions::WithTimeout(timeout / 1000).Build());
timeout = logcat_timeout("events");
if (timeout < 20000) {
timeout = 20000;
}
- runCommand("EVENT LOG",
+ RunCommand("EVENT LOG",
{"logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-d", "*:v"},
CommandOptions::WithTimeout(timeout / 1000).Build());
timeout = logcat_timeout("radio");
if (timeout < 20000) {
timeout = 20000;
}
- runCommand("RADIO LOG",
+ RunCommand("RADIO LOG",
{"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-d", "*:v"},
CommandOptions::WithTimeout(timeout / 1000).Build());
- runCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"});
+ RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"});
/* show the traces we collected in main(), if that was done */
if (dump_traces_path != NULL) {
- dumpFile("VM TRACES JUST NOW", dump_traces_path);
+ DumpFile("VM TRACES JUST NOW", dump_traces_path);
}
/* only show ANR traces if they're less than 15 minutes old */
@@ -958,7 +958,7 @@
// No traces file at this index, done with the files.
break;
}
- dumpFile("VM TRACES WHEN SLOW", anrTracesPath.c_str());
+ DumpFile("VM TRACES WHEN SLOW", anrTracesPath.c_str());
i++;
}
}
@@ -984,94 +984,94 @@
printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR);
}
- dumpFile("NETWORK DEV INFO", "/proc/net/dev");
- dumpFile("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
- dumpFile("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt");
- dumpFile("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
- dumpFile("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
+ DumpFile("NETWORK DEV INFO", "/proc/net/dev");
+ DumpFile("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
+ DumpFile("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt");
+ DumpFile("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
+ DumpFile("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
if (!stat(PSTORE_LAST_KMSG, &st)) {
/* Also TODO: Make console-ramoops CAP_SYSLOG protected. */
- dumpFile("LAST KMSG", PSTORE_LAST_KMSG);
+ DumpFile("LAST KMSG", PSTORE_LAST_KMSG);
} else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) {
- dumpFile("LAST KMSG", ALT_PSTORE_LAST_KMSG);
+ DumpFile("LAST KMSG", ALT_PSTORE_LAST_KMSG);
} else {
/* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */
- dumpFile("LAST KMSG", "/proc/last_kmsg");
+ DumpFile("LAST KMSG", "/proc/last_kmsg");
}
/* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */
- runCommand("LAST LOGCAT",
+ RunCommand("LAST LOGCAT",
{"logcat", "-L", "-b", "all", "-v", "threadtime", "-v", "printable", "-d", "*:v"});
/* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */
- runCommand("NETWORK INTERFACES", {"ip", "link"});
+ RunCommand("NETWORK INTERFACES", {"ip", "link"});
- runCommand("IPv4 ADDRESSES", {"ip", "-4", "addr", "show"});
- runCommand("IPv6 ADDRESSES", {"ip", "-6", "addr", "show"});
+ RunCommand("IPv4 ADDRESSES", {"ip", "-4", "addr", "show"});
+ RunCommand("IPv6 ADDRESSES", {"ip", "-6", "addr", "show"});
- runCommand("IP RULES", {"ip", "rule", "show"});
- runCommand("IP RULES v6", {"ip", "-6", "rule", "show"});
+ RunCommand("IP RULES", {"ip", "rule", "show"});
+ RunCommand("IP RULES v6", {"ip", "-6", "rule", "show"});
dump_route_tables();
- runCommand("ARP CACHE", {"ip", "-4", "neigh", "show"});
- runCommand("IPv6 ND CACHE", {"ip", "-6", "neigh", "show"});
- runCommand("MULTICAST ADDRESSES", {"ip", "maddr"});
- runCommand("WIFI NETWORKS", {"wpa_cli", "IFNAME=wlan0", "list_networks"},
+ RunCommand("ARP CACHE", {"ip", "-4", "neigh", "show"});
+ RunCommand("IPv6 ND CACHE", {"ip", "-6", "neigh", "show"});
+ RunCommand("MULTICAST ADDRESSES", {"ip", "maddr"});
+ RunCommand("WIFI NETWORKS", {"wpa_cli", "IFNAME=wlan0", "list_networks"},
CommandOptions::WithTimeout(20).Build());
#ifdef FWDUMP_bcmdhd
- runCommand("ND OFFLOAD TABLE", {WLUTIL, "nd_hostip"}, CommandOptions::AS_ROOT_5);
+ RunCommand("ND OFFLOAD TABLE", {WLUTIL, "nd_hostip"}, CommandOptions::AS_ROOT_5);
- runCommand("DUMP WIFI INTERNAL COUNTERS (1)", {WLUTIL, "counters"}, CommandOptions::AS_ROOT_20);
+ RunCommand("DUMP WIFI INTERNAL COUNTERS (1)", {WLUTIL, "counters"}, CommandOptions::AS_ROOT_20);
- runCommand("ND OFFLOAD STATUS (1)", {WLUTIL, "nd_status"}, CommandOptions::AS_ROOT_5);
+ RunCommand("ND OFFLOAD STATUS (1)", {WLUTIL, "nd_status"}, CommandOptions::AS_ROOT_5);
#endif
- dumpFile("INTERRUPTS (1)", "/proc/interrupts");
+ DumpFile("INTERRUPTS (1)", "/proc/interrupts");
- runDumpsys("NETWORK DIAGNOSTICS", {"connectivity", "--diag"},
+ RunDumpsys("NETWORK DIAGNOSTICS", {"connectivity", "--diag"},
CommandOptions::WithTimeout(10).Build());
#ifdef FWDUMP_bcmdhd
- runCommand("DUMP WIFI STATUS", {"dhdutil", "-i", "wlan0", "dump"}, CommandOptions::AS_ROOT_20);
+ RunCommand("DUMP WIFI STATUS", {"dhdutil", "-i", "wlan0", "dump"}, CommandOptions::AS_ROOT_20);
- runCommand("DUMP WIFI INTERNAL COUNTERS (2)", {WLUTIL, "counters"}, CommandOptions::AS_ROOT_20);
+ RunCommand("DUMP WIFI INTERNAL COUNTERS (2)", {WLUTIL, "counters"}, CommandOptions::AS_ROOT_20);
- runCommand("ND OFFLOAD STATUS (2)", {WLUTIL, "nd_status"}, CommandOptions::AS_ROOT_5);
+ RunCommand("ND OFFLOAD STATUS (2)", {WLUTIL, "nd_status"}, CommandOptions::AS_ROOT_5);
#endif
- dumpFile("INTERRUPTS (2)", "/proc/interrupts");
+ DumpFile("INTERRUPTS (2)", "/proc/interrupts");
print_properties();
- runCommand("VOLD DUMP", {"vdc", "dump"});
- runCommand("SECURE CONTAINERS", {"vdc", "asec", "list"});
+ RunCommand("VOLD DUMP", {"vdc", "dump"});
+ RunCommand("SECURE CONTAINERS", {"vdc", "asec", "list"});
- runCommand("FILESYSTEMS & FREE SPACE", {"df"});
+ RunCommand("FILESYSTEMS & FREE SPACE", {"df"});
- runCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"});
+ RunCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"});
printf("------ BACKLIGHTS ------\n");
printf("LCD brightness=");
- dumpFile(nullptr, "/sys/class/leds/lcd-backlight/brightness");
+ DumpFile(nullptr, "/sys/class/leds/lcd-backlight/brightness");
printf("Button brightness=");
- dumpFile(nullptr, "/sys/class/leds/button-backlight/brightness");
+ DumpFile(nullptr, "/sys/class/leds/button-backlight/brightness");
printf("Keyboard brightness=");
- dumpFile(nullptr, "/sys/class/leds/keyboard-backlight/brightness");
+ DumpFile(nullptr, "/sys/class/leds/keyboard-backlight/brightness");
printf("ALS mode=");
- dumpFile(nullptr, "/sys/class/leds/lcd-backlight/als");
+ DumpFile(nullptr, "/sys/class/leds/lcd-backlight/als");
printf("LCD driver registers:\n");
- dumpFile(nullptr, "/sys/class/leds/lcd-backlight/registers");
+ DumpFile(nullptr, "/sys/class/leds/lcd-backlight/registers");
printf("\n");
/* Binder state is expensive to look at as it uses a lot of memory. */
- dumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
- dumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
- dumpFile("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
- dumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats");
- dumpFile("BINDER STATE", "/sys/kernel/debug/binder/state");
+ DumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
+ DumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
+ DumpFile("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
+ DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats");
+ DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state");
printf("========================================================\n");
printf("== Board\n");
@@ -1094,43 +1094,43 @@
if (!is_user_build()) {
options.AsRoot();
}
- runCommand("DUMP VENDOR RIL LOGS", {"vril-dump"}, options.Build());
+ RunCommand("DUMP VENDOR RIL LOGS", {"vril-dump"}, options.Build());
}
printf("========================================================\n");
printf("== Android Framework Services\n");
printf("========================================================\n");
- runDumpsys("DUMPSYS", {"--skip", "meminfo", "cpuinfo"}, CommandOptions::WithTimeout(60).Build());
+ RunDumpsys("DUMPSYS", {"--skip", "meminfo", "cpuinfo"}, CommandOptions::WithTimeout(60).Build());
printf("========================================================\n");
printf("== Checkins\n");
printf("========================================================\n");
- runDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"});
- runDumpsys("CHECKIN MEMINFO", {"meminfo", "--checkin"});
- runDumpsys("CHECKIN NETSTATS", {"netstats", "--checkin"});
- runDumpsys("CHECKIN PROCSTATS", {"procstats", "-c"});
- runDumpsys("CHECKIN USAGESTATS", {"usagestats", "-c"});
- runDumpsys("CHECKIN PACKAGE", {"package", "--checkin"});
+ RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"});
+ RunDumpsys("CHECKIN MEMINFO", {"meminfo", "--checkin"});
+ RunDumpsys("CHECKIN NETSTATS", {"netstats", "--checkin"});
+ RunDumpsys("CHECKIN PROCSTATS", {"procstats", "-c"});
+ RunDumpsys("CHECKIN USAGESTATS", {"usagestats", "-c"});
+ RunDumpsys("CHECKIN PACKAGE", {"package", "--checkin"});
printf("========================================================\n");
printf("== Running Application Activities\n");
printf("========================================================\n");
- runDumpsys("APP ACTIVITIES", {"activity", "all"});
+ RunDumpsys("APP ACTIVITIES", {"activity", "all"});
printf("========================================================\n");
printf("== Running Application Services\n");
printf("========================================================\n");
- runDumpsys("APP SERVICES", {"activity", "service", "all"});
+ RunDumpsys("APP SERVICES", {"activity", "service", "all"});
printf("========================================================\n");
printf("== Running Application Providers\n");
printf("========================================================\n");
- runDumpsys("APP PROVIDERS", {"activity", "provider", "all"});
+ RunDumpsys("APP PROVIDERS", {"activity", "provider", "all"});
printf("========================================================\n");
printf("== Final progress (pid %d): %d/%d (originally %d)\n",
@@ -1578,9 +1578,9 @@
// Invoking the following dumpsys calls before dump_traces() to try and
// keep the system stats as close to its initial state as possible.
- runDumpsys("DUMPSYS MEMINFO", {"meminfo", "-a"},
+ RunDumpsys("DUMPSYS MEMINFO", {"meminfo", "-a"},
CommandOptions::WithTimeout(90).DropRoot().Build());
- runDumpsys("DUMPSYS CPUINFO", {"cpuinfo", "-a"},
+ RunDumpsys("DUMPSYS CPUINFO", {"cpuinfo", "-a"},
CommandOptions::WithTimeout(10).DropRoot().Build());
/* collect stack traces from Dalvik and native processes (needs root) */
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 3b51152..3b7c362 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -86,14 +86,14 @@
~DurationReporter();
- static uint64_t nanotime();
+ static uint64_t Nanotime();
private:
// TODO: use std::string for title, once dump_files() and other places that pass a char* are
// refactored as well.
- const char* mTitle;
- FILE* mOut;
- uint64_t mStarted;
+ const char* title_;
+ FILE* out_;
+ uint64_t started_;
};
/*
@@ -111,7 +111,7 @@
* if (!is_user_build()) {
* options.AsRoot();
* }
- * runCommand("command", {"args"}, options.Build());
+ * RunCommand("command", {"args"}, options.Build());
*/
class CommandOptions {
private:
@@ -119,11 +119,11 @@
private:
CommandOptionsValues(long timeout);
- long mTimeout;
- bool mAlways;
- RootMode mRootMode;
- StdoutMode mStdoutMode;
- std::string mLoggingMessage;
+ long timeout_;
+ bool always_;
+ RootMode rootMode_;
+ StdoutMode stdoutMode_;
+ std::string loggingMessage_;
friend class CommandOptions;
friend class CommandOptionsBuilder;
@@ -131,7 +131,7 @@
CommandOptions(const CommandOptionsValues& values);
- const CommandOptionsValues mValues;
+ const CommandOptionsValues values_;
public:
class CommandOptionsBuilder {
@@ -152,7 +152,7 @@
private:
CommandOptionsBuilder(long timeout);
- CommandOptionsValues mValues;
+ CommandOptionsValues values_;
friend class CommandOptions;
};
@@ -228,7 +228,7 @@
/* Prints the contents of a file. */
// TODO: use std::string for title once other char* title references are refactored.
-int dumpFile(const char* title, const std::string& path);
+int DumpFile(const char* title, const std::string& path);
/* saves the the contents of a file as a long */
int read_file_as_long(const char *path, long int *output);
@@ -263,7 +263,7 @@
* |options| optional argument defining the command's behavior.
*/
// TODO: use std::string for title once other char* title references are refactored.
-int runCommand(const char* title, const std::vector<std::string>& fullCommand,
+int RunCommand(const char* title, const std::vector<std::string>& fullCommand,
const CommandOptions& options = CommandOptions::DEFAULT);
/*
@@ -275,7 +275,7 @@
* |dumpsys_args| `dumpsys` arguments (except `-t`).
* |options| optional argument defining the command's behavior.
*/
-void runDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
+void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
const CommandOptions& options = CommandOptions::DEFAULT_DUMPSYS);
/* switch to non-root user and group */
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 5575084..f656266 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -76,68 +76,68 @@
CommandOptions CommandOptions::AS_ROOT_10 = CommandOptions::WithTimeout(10).AsRoot().Build();
CommandOptions CommandOptions::AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot().Build();
-CommandOptions::CommandOptionsBuilder::CommandOptionsBuilder(long timeout) : mValues(timeout) {
+CommandOptions::CommandOptionsBuilder::CommandOptionsBuilder(long timeout) : values_(timeout) {
}
CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::Always() {
- mValues.mAlways = true;
+ values_.always_ = true;
return *this;
}
CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::AsRoot() {
- mValues.mRootMode = SU_ROOT;
+ values_.rootMode_ = SU_ROOT;
return *this;
}
CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::DropRoot() {
- mValues.mRootMode = DROP_ROOT;
+ values_.rootMode_ = DROP_ROOT;
return *this;
}
CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::RedirectStderr() {
- mValues.mStdoutMode = REDIRECT_TO_STDERR;
+ values_.stdoutMode_ = REDIRECT_TO_STDERR;
return *this;
}
CommandOptions::CommandOptionsBuilder& CommandOptions::CommandOptionsBuilder::Log(
const std::string& message) {
- mValues.mLoggingMessage = message;
+ values_.loggingMessage_ = message;
return *this;
}
CommandOptions CommandOptions::CommandOptionsBuilder::Build() {
- return CommandOptions(mValues);
+ return CommandOptions(values_);
}
CommandOptions::CommandOptionsValues::CommandOptionsValues(long timeout)
- : mTimeout(timeout),
- mAlways(false),
- mRootMode(DONT_DROP_ROOT),
- mStdoutMode(NORMAL_STDOUT),
- mLoggingMessage("") {
+ : timeout_(timeout),
+ always_(false),
+ rootMode_(DONT_DROP_ROOT),
+ stdoutMode_(NORMAL_STDOUT),
+ loggingMessage_("") {
}
-CommandOptions::CommandOptions(const CommandOptionsValues& values) : mValues(values) {
+CommandOptions::CommandOptions(const CommandOptionsValues& values) : values_(values) {
}
long CommandOptions::Timeout() const {
- return mValues.mTimeout;
+ return values_.timeout_;
}
bool CommandOptions::Always() const {
- return mValues.mAlways;
+ return values_.always_;
}
RootMode CommandOptions::RootMode() const {
- return mValues.mRootMode;
+ return values_.rootMode_;
}
StdoutMode CommandOptions::StdoutMode() const {
- return mValues.mStdoutMode;
+ return values_.stdoutMode_;
}
std::string CommandOptions::LoggingMessage() const {
- return mValues.mLoggingMessage;
+ return values_.loggingMessage_;
}
CommandOptions::CommandOptionsBuilder CommandOptions::WithTimeout(long timeout) {
@@ -147,27 +147,27 @@
DurationReporter::DurationReporter(const char *title) : DurationReporter(title, stdout) {}
DurationReporter::DurationReporter(const char *title, FILE *out) {
- mTitle = title;
+ title_ = title;
if (title != nullptr) {
- mStarted = DurationReporter::nanotime();
+ started_ = DurationReporter::Nanotime();
}
- mOut = out;
+ out_ = out;
}
DurationReporter::~DurationReporter() {
- if (mTitle != nullptr) {
- uint64_t elapsed = DurationReporter::nanotime() - mStarted;
+ if (title_ != nullptr) {
+ uint64_t elapsed = DurationReporter::Nanotime() - started_;
// Use "Yoda grammar" to make it easier to grep|sort sections.
- if (mOut != nullptr) {
- fprintf(mOut, "------ %.3fs was the duration of '%s' ------\n",
- (float)elapsed / NANOS_PER_SEC, mTitle);
+ if (out_ != nullptr) {
+ fprintf(out_, "------ %.3fs was the duration of '%s' ------\n",
+ (float)elapsed / NANOS_PER_SEC, title_);
} else {
- MYLOGD("Duration of '%s': %.3fs\n", mTitle, (float)elapsed / NANOS_PER_SEC);
+ MYLOGD("Duration of '%s': %.3fs\n", title_, (float)elapsed / NANOS_PER_SEC);
}
}
}
-uint64_t DurationReporter::DurationReporter::nanotime() {
+uint64_t DurationReporter::DurationReporter::Nanotime() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t) ts.tv_sec * NANOS_PER_SEC + ts.tv_nsec;
@@ -483,7 +483,7 @@
snprintf(title, sizeof(title), "SHOW MAP %d (%s)", pid, name);
snprintf(arg, sizeof(arg), "%d", pid);
- runCommand(title, {"showmap", "-q", arg}, CommandOptions::AS_ROOT_10);
+ RunCommand(title, {"showmap", "-q", arg}, CommandOptions::AS_ROOT_10);
}
static int _dump_file_from_fd(const char *title, const char *path, int fd) {
@@ -519,14 +519,14 @@
/* Timeout if no data is read for 30 seconds. */
tm.tv_sec = 30;
tm.tv_usec = 0;
- uint64_t elapsed = DurationReporter::nanotime();
+ uint64_t elapsed = DurationReporter::Nanotime();
int ret = TEMP_FAILURE_RETRY(select(fd + 1, &read_set, NULL, NULL, &tm));
if (ret == -1) {
printf("*** %s: select failed: %s\n", path, strerror(errno));
newline = true;
break;
} else if (ret == 0) {
- elapsed = DurationReporter::nanotime() - elapsed;
+ elapsed = DurationReporter::Nanotime() - elapsed;
printf("*** %s: Timed out after %.3fs\n", path,
(float) elapsed / NANOS_PER_SEC);
newline = true;
@@ -555,10 +555,10 @@
}
int dump_file(const char *title, const char *path) {
- return dumpFile(title, path);
+ return DumpFile(title, path);
}
-int dumpFile(const char* title, const std::string& path) {
+int DumpFile(const char* title, const std::string& path) {
DurationReporter durationReporter(title);
int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC));
if (fd < 0) {
@@ -740,10 +740,10 @@
}
va_end(ap);
- return runCommand(title, fullCommand, CommandOptions::WithTimeout(timeout_seconds).Build());
+ return RunCommand(title, fullCommand, CommandOptions::WithTimeout(timeout_seconds).Build());
}
-int runCommand(const char* title, const std::vector<std::string>& fullCommand,
+int RunCommand(const char* title, const std::vector<std::string>& fullCommand,
const CommandOptions& options) {
if (fullCommand.empty()) {
MYLOGE("No arguments on command '%s'\n", title);
@@ -805,7 +805,7 @@
* Ideally, it should use a options.EstimatedDuration() instead...*/
int weight = options.Timeout();
- uint64_t start = DurationReporter::nanotime();
+ uint64_t start = DurationReporter::Nanotime();
pid_t pid = fork();
/* handle error case */
@@ -851,7 +851,7 @@
/* handle parent case */
int status;
bool ret = waitpid_with_timeout(pid, options.Timeout(), &status);
- uint64_t elapsed = DurationReporter::nanotime() - start;
+ uint64_t elapsed = DurationReporter::Nanotime() - start;
if (!ret) {
if (errno == ETIMEDOUT) {
if (!silent)
@@ -893,12 +893,12 @@
return status;
}
-void runDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
+void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
const CommandOptions& options) {
std::vector<std::string> dumpsys = {"/system/bin/dumpsys", "-t",
std::to_string(options.Timeout())};
dumpsys.insert(dumpsys.end(), dumpsysArgs.begin(), dumpsysArgs.end());
- runCommand(title.c_str(), dumpsys, options);
+ RunCommand(title.c_str(), dumpsys, options);
}
bool drop_root_user() {
@@ -955,7 +955,7 @@
am.insert(am.end(), args.begin(), args.end());
- runCommand(nullptr, am, CommandOptions::WithTimeout(20)
+ RunCommand(nullptr, am, CommandOptions::WithTimeout(20)
.Log("Sending broadcast: '%s'\n")
.Always()
.DropRoot()
@@ -1172,7 +1172,7 @@
}
++dalvik_found;
- uint64_t start = DurationReporter::nanotime();
+ uint64_t start = DurationReporter::Nanotime();
if (kill(pid, SIGQUIT)) {
MYLOGE("kill(%d, SIGQUIT): %s\n", pid, strerror(errno));
continue;
@@ -1193,8 +1193,8 @@
if (lseek(fd, 0, SEEK_END) < 0) {
MYLOGE("lseek: %s\n", strerror(errno));
} else {
- dprintf(fd, "[dump dalvik stack %d: %.3fs elapsed]\n",
- pid, (float)(DurationReporter::nanotime() - start) / NANOS_PER_SEC);
+ dprintf(fd, "[dump dalvik stack %d: %.3fs elapsed]\n", pid,
+ (float)(DurationReporter::Nanotime() - start) / NANOS_PER_SEC);
}
} else if (should_dump_native_traces(data)) {
/* dump native process if appropriate */
@@ -1202,7 +1202,7 @@
MYLOGE("lseek: %s\n", strerror(errno));
} else {
static uint16_t timeout_failures = 0;
- uint64_t start = DurationReporter::nanotime();
+ uint64_t start = DurationReporter::Nanotime();
/* If 3 backtrace dumps fail in a row, consider debuggerd dead. */
if (timeout_failures == 3) {
@@ -1213,8 +1213,8 @@
} else {
timeout_failures = 0;
}
- dprintf(fd, "[dump native stack %d: %.3fs elapsed]\n",
- pid, (float)(DurationReporter::nanotime() - start) / NANOS_PER_SEC);
+ dprintf(fd, "[dump native stack %d: %.3fs elapsed]\n", pid,
+ (float)(DurationReporter::Nanotime() - start) / NANOS_PER_SEC);
}
}
}
@@ -1255,8 +1255,8 @@
// need the table number. It's a 32-bit unsigned number, so max 10 chars. Skip the table name.
// Add a fixed max limit so this doesn't go awry.
for (int i = 0; i < 64 && fscanf(fp, " %10s %*s", table) == 1; ++i) {
- runCommand("ROUTE TABLE IPv4", {"ip", "-4", "route", "show", "table", table});
- runCommand("ROUTE TABLE IPv6", {"ip", "-6", "route", "show", "table", table});
+ RunCommand("ROUTE TABLE IPv4", {"ip", "-4", "route", "show", "table", table});
+ RunCommand("ROUTE TABLE IPv6", {"ip", "-6", "route", "show", "table", table});
}
fclose(fp);
}
@@ -1314,7 +1314,7 @@
}
void take_screenshot(const std::string& path) {
- runCommand(nullptr, {"/system/bin/screencap", "-p", path},
+ RunCommand(nullptr, {"/system/bin/screencap", "-p", path},
CommandOptions::WithTimeout(10).Always().RedirectStderr().Build());
}