summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2021-05-19 17:03:55 -0700
committer Calin Juravle <calin@google.com> 2021-06-03 19:35:14 +0000
commit09eacd9a5d982687b68031a884e4daaa11560f0c (patch)
tree79a7fdac9c3330e850d05028cf95b3de6cb108a3 /cmdline
parent341be9e71c8dbb1f6e29e860336e8e4944d54c63 (diff)
Setup ART experiments infra
Add a flexible class for ART Flags that can take their values from cmdline arguments, system properties or device config settings. (the flags concept is evolved from Eric's previous CL 3dba023d4fb47882fa215715c196cfa3be30c098) Plumb the loading/re-loading of flags in the runtime initialization and after forking from zygote (so that we don't require restarts to refresh the flags). If multiple values are given for the same flag the evaluation order is: 1) device config (configurable from server side) 2) system properties 3) cmdline arguments 4) the default value The existing cmdline arguments are not migrated to the new infra and will be done only on a per need basis. Test: gtest & manual Bug: 181748174 Change-Id: If3940393493af1052367d725a3f2aa94eee927c2
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/cmdline_parser.h18
-rw-r--r--cmdline/cmdline_types.h17
2 files changed, 35 insertions, 0 deletions
diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h
index 22eb44c211..7e343f8ef2 100644
--- a/cmdline/cmdline_parser.h
+++ b/cmdline/cmdline_parser.h
@@ -210,6 +210,24 @@ struct CmdlineParser {
return parent_;
}
+ // Write the results of this argument into a variable pointed to by destination.
+ // An optional is used to tell whether the command line argument was present.
+ CmdlineParser::Builder& IntoLocation(std::optional<TArg>* destination) {
+ save_value_ = [destination](TArg& value) {
+ *destination = value;
+ };
+
+ load_value_ = [destination]() -> TArg& {
+ return destination->value();
+ };
+
+ save_value_specified_ = true;
+ load_value_specified_ = true;
+
+ CompleteArgument();
+ return parent_;
+ }
+
// Ensure we always move this when returning a new builder.
ArgumentBuilder(ArgumentBuilder&&) = default;
diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h
index 43d30222c7..964e2385b6 100644
--- a/cmdline/cmdline_types.h
+++ b/cmdline/cmdline_types.h
@@ -21,6 +21,7 @@
#include <list>
#include <ostream>
+#include "android-base/parsebool.h"
#include "android-base/stringprintf.h"
#include "cmdline_type_parser.h"
#include "detail/cmdline_debug_detail.h"
@@ -67,6 +68,22 @@ struct CmdlineType<Unit> : CmdlineTypeParser<Unit> {
};
template <>
+struct CmdlineType<bool> : CmdlineTypeParser<bool> {
+ Result Parse(const std::string& args) {
+ switch (::android::base::ParseBool(args)) {
+ case ::android::base::ParseBoolResult::kError:
+ return Result::Failure("Could not parse '" + args + "' as boolean");
+ case ::android::base::ParseBoolResult::kTrue:
+ return Result::Success(true);
+ case ::android::base::ParseBoolResult::kFalse:
+ return Result::Success(false);
+ }
+ }
+
+ static const char* DescribeType() { return "true|false|1|0|y|n|yes|no|on|off"; }
+};
+
+template <>
struct CmdlineType<JdwpProvider> : CmdlineTypeParser<JdwpProvider> {
/*
* Handle a single JDWP provider name. Must be either 'internal', 'default', or the file name of