diff options
author | Yabin Cui <yabinc@google.com> | 2018-04-18 13:10:40 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2018-04-20 18:18:45 -0700 |
commit | acf04b213d334df8880aa324711a03a8a91ffa07 (patch) | |
tree | eaf0ca754d9e7b9f0c7d2bf13600faba72e2a3fc /simpleperf/command.cpp | |
parent | ddb48c1cac7442b8aa7b7b2487c074da449eb3a0 (diff) | |
download | extras-acf04b213d334df8880aa324711a03a8a91ffa07.tar.gz |
simpleperf: add --size-limit option in record cmd.
--size-limit option stops recording when the recorded data
reaches the size limit. It is used by
run_simpleperf_without_usb_connection.py to avoid taking too much disk
space.
Bug: http://b/74198167
Test: run simpleperf_unit_test.
Test: run test.py.
Change-Id: I11f0023c342c50e1cf8035430e6af1b3caa329e7
Diffstat (limited to 'simpleperf/command.cpp')
-rw-r--r-- | simpleperf/command.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/simpleperf/command.cpp b/simpleperf/command.cpp index 63a7dfd9..9caadaa4 100644 --- a/simpleperf/command.cpp +++ b/simpleperf/command.cpp @@ -22,6 +22,8 @@ #include <vector> #include <android-base/logging.h> +#include <android-base/parsedouble.h> +#include <android-base/parseint.h> #include <android-base/quick_exit.h> #include "utils.h" @@ -36,6 +38,18 @@ bool Command::NextArgumentOrError(const std::vector<std::string>& args, size_t* return true; } +bool Command::GetDoubleOption(const std::vector<std::string>& args, size_t* pi, double* value, + double min, double max) { + if (!NextArgumentOrError(args, pi)) { + return false; + } + if (!android::base::ParseDouble(args[*pi].c_str(), value, min, max)) { + LOG(ERROR) << "Invalid argument for option " << args[*pi - 1] << ": " << args[*pi]; + return false; + } + return true; +} + void Command::ReportUnknownOption(const std::vector<std::string>& args, size_t i) { LOG(ERROR) << "Unknown option for " << name_ << " command: '" << args[i] << "'. Try `simpleperf help " << name_ << "`"; |