Loading cmds/dumpstate/dumpstate.cpp +11 −10 Original line number Original line Diff line number Diff line Loading @@ -118,8 +118,9 @@ static const int32_t WEIGHT_FILE = 5; // TODO: temporary variables and functions used during C++ refactoring // TODO: temporary variables and functions used during C++ refactoring static Dumpstate& ds = Dumpstate::GetInstance(); static Dumpstate& ds = Dumpstate::GetInstance(); static int RunCommand(const std::string& title, const std::vector<std::string>& full_command, static int RunCommand(const std::string& title, const std::vector<std::string>& full_command, const CommandOptions& options = CommandOptions::DEFAULT) { const CommandOptions& options = CommandOptions::DEFAULT, return ds.RunCommand(title, full_command, options); bool verbose_duration = false) { return ds.RunCommand(title, full_command, options, verbose_duration); } } // Reasonable value for max stats. // Reasonable value for max stats. Loading Loading @@ -898,17 +899,17 @@ static void DoLogcat() { RunCommand( RunCommand( "EVENT LOG", "EVENT LOG", {"logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"stats"}); timeout_ms = logcat_timeout({"stats"}); RunCommand( RunCommand( "STATS LOG", "STATS LOG", {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"radio"}); timeout_ms = logcat_timeout({"radio"}); RunCommand( RunCommand( "RADIO LOG", "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); Loading Loading @@ -2852,8 +2853,8 @@ Dumpstate& Dumpstate::GetInstance() { return singleton_; return singleton_; } } DurationReporter::DurationReporter(const std::string& title, bool logcat_only) DurationReporter::DurationReporter(const std::string& title, bool logcat_only, bool verbose) : title_(title), logcat_only_(logcat_only) { : title_(title), logcat_only_(logcat_only), verbose_(verbose) { if (!title_.empty()) { if (!title_.empty()) { started_ = Nanotime(); started_ = Nanotime(); } } Loading @@ -2862,7 +2863,7 @@ DurationReporter::DurationReporter(const std::string& title, bool logcat_only) DurationReporter::~DurationReporter() { DurationReporter::~DurationReporter() { if (!title_.empty()) { if (!title_.empty()) { float elapsed = (float)(Nanotime() - started_) / NANOS_PER_SEC; float elapsed = (float)(Nanotime() - started_) / NANOS_PER_SEC; if (elapsed < .5f) { if (elapsed < .5f && !verbose_) { return; return; } } MYLOGD("Duration of '%s': %.2fs\n", title_.c_str(), elapsed); MYLOGD("Duration of '%s': %.2fs\n", title_.c_str(), elapsed); Loading Loading @@ -3455,8 +3456,8 @@ int dump_file_from_fd(const char *title, const char *path, int fd) { } } int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& full_command, int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& full_command, const CommandOptions& options) { const CommandOptions& options, bool verbose_duration) { DurationReporter duration_reporter(title); DurationReporter duration_reporter(title, false /* logcat_only */, verbose_duration); int status = RunCommandToFd(STDOUT_FILENO, title, full_command, options); int status = RunCommandToFd(STDOUT_FILENO, title, full_command, options); Loading cmds/dumpstate/dumpstate.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -73,13 +73,15 @@ extern "C" { */ */ class DurationReporter { class DurationReporter { public: public: explicit DurationReporter(const std::string& title, bool logcat_only = false); explicit DurationReporter(const std::string& title, bool logcat_only = false, bool verbose = false); ~DurationReporter(); ~DurationReporter(); private: private: std::string title_; std::string title_; bool logcat_only_; bool logcat_only_; bool verbose_; uint64_t started_; uint64_t started_; DISALLOW_COPY_AND_ASSIGN(DurationReporter); DISALLOW_COPY_AND_ASSIGN(DurationReporter); Loading Loading @@ -224,7 +226,8 @@ class Dumpstate { */ */ int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand, int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand, const android::os::dumpstate::CommandOptions& options = const android::os::dumpstate::CommandOptions& options = android::os::dumpstate::CommandOptions::DEFAULT); android::os::dumpstate::CommandOptions::DEFAULT, bool verbose_duration = false); /* /* * Runs `dumpsys` with the given arguments, automatically setting its timeout * Runs `dumpsys` with the given arguments, automatically setting its timeout Loading Loading
cmds/dumpstate/dumpstate.cpp +11 −10 Original line number Original line Diff line number Diff line Loading @@ -118,8 +118,9 @@ static const int32_t WEIGHT_FILE = 5; // TODO: temporary variables and functions used during C++ refactoring // TODO: temporary variables and functions used during C++ refactoring static Dumpstate& ds = Dumpstate::GetInstance(); static Dumpstate& ds = Dumpstate::GetInstance(); static int RunCommand(const std::string& title, const std::vector<std::string>& full_command, static int RunCommand(const std::string& title, const std::vector<std::string>& full_command, const CommandOptions& options = CommandOptions::DEFAULT) { const CommandOptions& options = CommandOptions::DEFAULT, return ds.RunCommand(title, full_command, options); bool verbose_duration = false) { return ds.RunCommand(title, full_command, options, verbose_duration); } } // Reasonable value for max stats. // Reasonable value for max stats. Loading Loading @@ -898,17 +899,17 @@ static void DoLogcat() { RunCommand( RunCommand( "EVENT LOG", "EVENT LOG", {"logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"stats"}); timeout_ms = logcat_timeout({"stats"}); RunCommand( RunCommand( "STATS LOG", "STATS LOG", {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"radio"}); timeout_ms = logcat_timeout({"radio"}); RunCommand( RunCommand( "RADIO LOG", "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build()); CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); Loading Loading @@ -2852,8 +2853,8 @@ Dumpstate& Dumpstate::GetInstance() { return singleton_; return singleton_; } } DurationReporter::DurationReporter(const std::string& title, bool logcat_only) DurationReporter::DurationReporter(const std::string& title, bool logcat_only, bool verbose) : title_(title), logcat_only_(logcat_only) { : title_(title), logcat_only_(logcat_only), verbose_(verbose) { if (!title_.empty()) { if (!title_.empty()) { started_ = Nanotime(); started_ = Nanotime(); } } Loading @@ -2862,7 +2863,7 @@ DurationReporter::DurationReporter(const std::string& title, bool logcat_only) DurationReporter::~DurationReporter() { DurationReporter::~DurationReporter() { if (!title_.empty()) { if (!title_.empty()) { float elapsed = (float)(Nanotime() - started_) / NANOS_PER_SEC; float elapsed = (float)(Nanotime() - started_) / NANOS_PER_SEC; if (elapsed < .5f) { if (elapsed < .5f && !verbose_) { return; return; } } MYLOGD("Duration of '%s': %.2fs\n", title_.c_str(), elapsed); MYLOGD("Duration of '%s': %.2fs\n", title_.c_str(), elapsed); Loading Loading @@ -3455,8 +3456,8 @@ int dump_file_from_fd(const char *title, const char *path, int fd) { } } int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& full_command, int Dumpstate::RunCommand(const std::string& title, const std::vector<std::string>& full_command, const CommandOptions& options) { const CommandOptions& options, bool verbose_duration) { DurationReporter duration_reporter(title); DurationReporter duration_reporter(title, false /* logcat_only */, verbose_duration); int status = RunCommandToFd(STDOUT_FILENO, title, full_command, options); int status = RunCommandToFd(STDOUT_FILENO, title, full_command, options); Loading
cmds/dumpstate/dumpstate.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -73,13 +73,15 @@ extern "C" { */ */ class DurationReporter { class DurationReporter { public: public: explicit DurationReporter(const std::string& title, bool logcat_only = false); explicit DurationReporter(const std::string& title, bool logcat_only = false, bool verbose = false); ~DurationReporter(); ~DurationReporter(); private: private: std::string title_; std::string title_; bool logcat_only_; bool logcat_only_; bool verbose_; uint64_t started_; uint64_t started_; DISALLOW_COPY_AND_ASSIGN(DurationReporter); DISALLOW_COPY_AND_ASSIGN(DurationReporter); Loading Loading @@ -224,7 +226,8 @@ class Dumpstate { */ */ int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand, int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand, const android::os::dumpstate::CommandOptions& options = const android::os::dumpstate::CommandOptions& options = android::os::dumpstate::CommandOptions::DEFAULT); android::os::dumpstate::CommandOptions::DEFAULT, bool verbose_duration = false); /* /* * Runs `dumpsys` with the given arguments, automatically setting its timeout * Runs `dumpsys` with the given arguments, automatically setting its timeout Loading