summaryrefslogtreecommitdiff
path: root/cmdline/cmdline_types.h
diff options
context:
space:
mode:
authorEric Holk <eholk@google.com>2021-01-30 02:03:29 +0000
committerTreehugger Robot <treehugger-gerrit@google.com>2021-02-17 15:05:02 +0000
commit3dba023d4fb47882fa215715c196cfa3be30c098 (patch)
treeda22f82b7cde87f37100f715a0e05f332b377f73 /cmdline/cmdline_types.h
parent381d35c1b01401e193544f679bfaf4f5c197f7cd (diff)
Add a server-configurable flags API
Adds a new set of flags that can be set by the command line, server configuration, or system properties. These flags can be used to enable or disable certain features or otherwise change their behavior. The flexible configuration options facilitate both development and also experimentation. As an example of their use, this CL also moves the -Xwrite-metrics-to-log command line option to the flags system instead. Future work will migrate the rest of the metrics settings. Test: ./test/run-test --host --jit 2232-write-metrics-to-log Bug: 175050458 Change-Id: I1ef37e7d355204a3172b7aa5c0baa4cbd8c7076b
Diffstat (limited to 'cmdline/cmdline_types.h')
-rw-r--r--cmdline/cmdline_types.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h
index 2d7d5f1b78..7f01be6472 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|0|1|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