diff options
| author | Zachary Turner <zturner@google.com> | 2016-09-22 20:22:55 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-09-22 20:22:55 +0000 |
| commit | 1f0f5b5b9eeaea93126583b40070091baf3bc92d (patch) | |
| tree | 93be6068ce5a7314fb9bfdf0621f65c03b3cad0b /lldb/source/Plugins/StructuredData | |
| parent | 387eb83a509926ed6bd36591d1f235335ec215c0 (diff) | |
| download | llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.tar.gz llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.tar.bz2 llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.zip | |
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
Diffstat (limited to 'lldb/source/Plugins/StructuredData')
| -rw-r--r-- | lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp | 204 |
1 files changed, 100 insertions, 104 deletions
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 0a6e324d7705..ff87150c67fd 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -398,6 +398,105 @@ static void RegisterFilterOperations() { /// It is valid to run the enable command when logging is already enabled. /// This resets the logging with whatever settings are currently set. // ------------------------------------------------------------------------- + +static OptionDefinition g_enable_option_table[] = { + // Source stream include/exclude options (the first-level filter). + // This one should be made as small as possible as everything that + // goes through here must be processed by the process monitor. + {LLDB_OPT_SET_ALL, false, "any-process", 'a', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Specifies log messages from other related processes should be " + "included."}, + {LLDB_OPT_SET_ALL, false, "debug", 'd', OptionParser::eNoArgument, nullptr, + nullptr, 0, eArgTypeNone, + "Specifies debug-level log messages should be included. Specifying" + " --debug implies --info."}, + {LLDB_OPT_SET_ALL, false, "info", 'i', OptionParser::eNoArgument, nullptr, + nullptr, 0, eArgTypeNone, + "Specifies info-level log messages should be included."}, + {LLDB_OPT_SET_ALL, false, "filter", 'f', OptionParser::eRequiredArgument, + nullptr, nullptr, 0, eArgRawInput, + // There doesn't appear to be a great way for me to have these + // multi-line, formatted tables in help. This looks mostly right + // but there are extra linefeeds added at seemingly random spots, + // and indentation isn't handled properly on those lines. + "Appends a filter rule to the log message filter chain. Multiple " + "rules may be added by specifying this option multiple times, " + "once per filter rule. Filter rules are processed in the order " + "they are specified, with the --no-match-accepts setting used " + "for any message that doesn't match one of the rules.\n" + "\n" + " Filter spec format:\n" + "\n" + " --filter \"{action} {attribute} {op}\"\n" + "\n" + " {action} :=\n" + " accept |\n" + " reject\n" + "\n" + " {attribute} :=\n" + " activity | // message's most-derived activity\n" + " activity-chain | // message's {parent}:{child} activity\n" + " category | // message's category\n" + " message | // message's expanded contents\n" + " subsystem | // message's subsystem\n" + "\n" + " {op} :=\n" + " match {exact-match-text} |\n" + " regex {search-regex}\n" + "\n" + "The regex flavor used is the C++ std::regex ECMAScript format. " + "Prefer character classes like [[:digit:]] to \\d and the like, as " + "getting the backslashes escaped through properly is error-prone."}, + {LLDB_OPT_SET_ALL, false, "live-stream", 'l', + OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, + "Specify whether logging events are live-streamed or buffered. " + "True indicates live streaming, false indicates buffered. The " + "default is true (live streaming). Live streaming will deliver " + "log messages with less delay, but buffered capture mode has less " + "of an observer effect."}, + {LLDB_OPT_SET_ALL, false, "no-match-accepts", 'n', + OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, + "Specify whether a log message that doesn't match any filter rule " + "is accepted or rejected, where true indicates accept. The " + "default is true."}, + {LLDB_OPT_SET_ALL, false, "echo-to-stderr", 'e', + OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, + "Specify whether os_log()/NSLog() messages are echoed to the " + "target program's stderr. When DarwinLog is enabled, we shut off " + "the mirroring of os_log()/NSLog() to the program's stderr. " + "Setting this flag to true will restore the stderr mirroring." + "The default is false."}, + {LLDB_OPT_SET_ALL, false, "broadcast-events", 'b', + OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, + "Specify if the plugin should broadcast events. Broadcasting " + "log events is a requirement for displaying the log entries in " + "LLDB command-line. It is also required if LLDB clients want to " + "process log events. The default is true."}, + // Message formatting options + {LLDB_OPT_SET_ALL, false, "timestamp-relative", 'r', + OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, + "Include timestamp in the message header when printing a log " + "message. The timestamp is relative to the first displayed " + "message."}, + {LLDB_OPT_SET_ALL, false, "subsystem", 's', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Include the subsystem in the the message header when displaying " + "a log message."}, + {LLDB_OPT_SET_ALL, false, "category", 'c', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Include the category in the the message header when displaying " + "a log message."}, + {LLDB_OPT_SET_ALL, false, "activity-chain", 'C', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Include the activity parent-child chain in the the message header " + "when displaying a log message. The activity hierarchy is " + "displayed as {grandparent-activity}:" + "{parent-activity}:{activity}[:...]."}, + {LLDB_OPT_SET_ALL, false, "all-fields", 'A', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Shortcut to specify that all header fields should be displayed."}}; + class EnableOptions : public Options { public: EnableOptions() @@ -492,7 +591,7 @@ public: return error; } - const OptionDefinition *GetDefinitions() override { + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { return g_enable_option_table; } @@ -661,8 +760,6 @@ private: return -1; } - static OptionDefinition g_enable_option_table[]; - bool m_include_debug_level; bool m_include_info_level; bool m_include_any_process; @@ -677,107 +774,6 @@ private: FilterRules m_filter_rules; }; -OptionDefinition EnableOptions::g_enable_option_table[] = { - // Source stream include/exclude options (the first-level filter). - // This one should be made as small as possible as everything that - // goes through here must be processed by the process monitor. - {LLDB_OPT_SET_ALL, false, "any-process", 'a', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Specifies log messages from other related processes should be " - "included."}, - {LLDB_OPT_SET_ALL, false, "debug", 'd', OptionParser::eNoArgument, nullptr, - nullptr, 0, eArgTypeNone, - "Specifies debug-level log messages should be included. Specifying" - " --debug implies --info."}, - {LLDB_OPT_SET_ALL, false, "info", 'i', OptionParser::eNoArgument, nullptr, - nullptr, 0, eArgTypeNone, - "Specifies info-level log messages should be included."}, - {LLDB_OPT_SET_ALL, false, "filter", 'f', OptionParser::eRequiredArgument, - nullptr, nullptr, 0, eArgRawInput, - // There doesn't appear to be a great way for me to have these - // multi-line, formatted tables in help. This looks mostly right - // but there are extra linefeeds added at seemingly random spots, - // and indentation isn't handled properly on those lines. - "Appends a filter rule to the log message filter chain. Multiple " - "rules may be added by specifying this option multiple times, " - "once per filter rule. Filter rules are processed in the order " - "they are specified, with the --no-match-accepts setting used " - "for any message that doesn't match one of the rules.\n" - "\n" - " Filter spec format:\n" - "\n" - " --filter \"{action} {attribute} {op}\"\n" - "\n" - " {action} :=\n" - " accept |\n" - " reject\n" - "\n" - " {attribute} :=\n" - " activity | // message's most-derived activity\n" - " activity-chain | // message's {parent}:{child} activity\n" - " category | // message's category\n" - " message | // message's expanded contents\n" - " subsystem | // message's subsystem\n" - "\n" - " {op} :=\n" - " match {exact-match-text} |\n" - " regex {search-regex}\n" - "\n" - "The regex flavor used is the C++ std::regex ECMAScript format. " - "Prefer character classes like [[:digit:]] to \\d and the like, as " - "getting the backslashes escaped through properly is error-prone."}, - {LLDB_OPT_SET_ALL, false, "live-stream", 'l', - OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, - "Specify whether logging events are live-streamed or buffered. " - "True indicates live streaming, false indicates buffered. The " - "default is true (live streaming). Live streaming will deliver " - "log messages with less delay, but buffered capture mode has less " - "of an observer effect."}, - {LLDB_OPT_SET_ALL, false, "no-match-accepts", 'n', - OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, - "Specify whether a log message that doesn't match any filter rule " - "is accepted or rejected, where true indicates accept. The " - "default is true."}, - {LLDB_OPT_SET_ALL, false, "echo-to-stderr", 'e', - OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, - "Specify whether os_log()/NSLog() messages are echoed to the " - "target program's stderr. When DarwinLog is enabled, we shut off " - "the mirroring of os_log()/NSLog() to the program's stderr. " - "Setting this flag to true will restore the stderr mirroring." - "The default is false."}, - {LLDB_OPT_SET_ALL, false, "broadcast-events", 'b', - OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, - "Specify if the plugin should broadcast events. Broadcasting " - "log events is a requirement for displaying the log entries in " - "LLDB command-line. It is also required if LLDB clients want to " - "process log events. The default is true."}, - // Message formatting options - {LLDB_OPT_SET_ALL, false, "timestamp-relative", 'r', - OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, - "Include timestamp in the message header when printing a log " - "message. The timestamp is relative to the first displayed " - "message."}, - {LLDB_OPT_SET_ALL, false, "subsystem", 's', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Include the subsystem in the the message header when displaying " - "a log message."}, - {LLDB_OPT_SET_ALL, false, "category", 'c', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Include the category in the the message header when displaying " - "a log message."}, - {LLDB_OPT_SET_ALL, false, "activity-chain", 'C', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Include the activity parent-child chain in the the message header " - "when displaying a log message. The activity hierarchy is " - "displayed as {grandparent-activity}:" - "{parent-activity}:{activity}[:...]."}, - {LLDB_OPT_SET_ALL, false, "all-fields", 'A', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Shortcut to specify that all header fields should be displayed."}, - - // Tail sentinel entry - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; - class EnableCommand : public CommandObjectParsed { public: EnableCommand(CommandInterpreter &interpreter, bool enable, const char *name, |
