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 | |
| parent | 387eb83a509926ed6bd36591d1f235335ec215c0 (diff) | |
| download | bcm5719-llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.tar.gz bcm5719-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')
3 files changed, 135 insertions, 143 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 630490e3271..7312dfc5b7e 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -470,6 +470,11 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process, return NULL; } +static OptionDefinition g_objc_classtable_dump_options[] = { + {LLDB_OPT_SET_ALL, false, "verbose", 'v', OptionParser::eNoArgument, + nullptr, nullptr, 0, eArgTypeNone, + "Print ivar and method information in detail"}}; + class CommandObjectObjC_ClassTable_Dump : public CommandObjectParsed { public: class CommandOptions : public Options { @@ -501,10 +506,11 @@ public: m_verbose.Clear(); } - const OptionDefinition *GetDefinitions() override { return g_option_table; } + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { + return g_objc_classtable_dump_options; + } OptionValueBoolean m_verbose; - static OptionDefinition g_option_table[]; }; CommandObjectObjC_ClassTable_Dump(CommandInterpreter &interpreter) @@ -627,13 +633,6 @@ protected: CommandOptions m_options; }; -OptionDefinition - CommandObjectObjC_ClassTable_Dump::CommandOptions::g_option_table[] = { - {LLDB_OPT_SET_ALL, false, "verbose", 'v', OptionParser::eNoArgument, - nullptr, nullptr, 0, eArgTypeNone, - "Print ivar and method information in detail"}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; - class CommandObjectMultiwordObjC_TaggedPointer_Info : public CommandObjectParsed { public: diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index 9d751a75da0..1e4d846a898 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -3692,6 +3692,15 @@ public: } }; +static OptionDefinition g_renderscript_kernel_bp_set_options[] = { + {LLDB_OPT_SET_1, false, "coordinate", 'c', OptionParser::eRequiredArgument, + nullptr, nullptr, 0, eArgTypeValue, + "Set a breakpoint on a single invocation of the kernel with specified " + "coordinate.\n" + "Coordinate takes the form 'x[,y][,z] where x,y,z are positive " + "integers representing kernel dimensions. " + "Any unset dimensions will be defaulted to zero."}}; + class CommandObjectRenderScriptRuntimeKernelBreakpointSet : public CommandObjectParsed { public: @@ -3770,9 +3779,10 @@ public: m_coord[2] = -1; } - const OptionDefinition *GetDefinitions() override { return g_option_table; } + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { + return g_renderscript_kernel_bp_set_options; + } - static OptionDefinition g_option_table[]; std::array<int, 3> m_coord; }; @@ -3809,17 +3819,6 @@ private: CommandOptions m_options; }; -OptionDefinition CommandObjectRenderScriptRuntimeKernelBreakpointSet:: - CommandOptions::g_option_table[] = { - {LLDB_OPT_SET_1, false, "coordinate", 'c', - OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeValue, - "Set a breakpoint on a single invocation of the kernel with specified " - "coordinate.\n" - "Coordinate takes the form 'x[,y][,z] where x,y,z are positive " - "integers representing kernel dimensions. " - "Any unset dimensions will be defaulted to zero."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; - class CommandObjectRenderScriptRuntimeKernelBreakpointAll : public CommandObjectParsed { public: @@ -3972,6 +3971,11 @@ public: } }; +static OptionDefinition g_renderscript_runtime_alloc_dump_options[] = { + {LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, + nullptr, nullptr, 0, eArgTypeFilename, + "Print results to specified file instead of command line."}}; + class CommandObjectRenderScriptRuntimeContext : public CommandObjectMultiword { public: CommandObjectRenderScriptRuntimeContext(CommandInterpreter &interpreter) @@ -4034,9 +4038,10 @@ public: m_outfile.Clear(); } - const OptionDefinition *GetDefinitions() override { return g_option_table; } + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { + return g_renderscript_runtime_alloc_dump_options; + } - static OptionDefinition g_option_table[]; FileSpec m_outfile; }; @@ -4103,12 +4108,10 @@ private: CommandOptions m_options; }; -OptionDefinition CommandObjectRenderScriptRuntimeAllocationDump:: - CommandOptions::g_option_table[] = { - {LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, - nullptr, nullptr, 0, eArgTypeFilename, - "Print results to specified file instead of command line."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; +static OptionDefinition g_renderscript_runtime_alloc_list_options[] = { + {LLDB_OPT_SET_1, false, "id", 'i', OptionParser::eRequiredArgument, nullptr, + nullptr, 0, eArgTypeIndex, + "Only show details of a single allocation with specified id."}}; class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParsed { @@ -4157,9 +4160,10 @@ public: m_id = 0; } - const OptionDefinition *GetDefinitions() override { return g_option_table; } + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { + return g_renderscript_runtime_alloc_list_options; + } - static OptionDefinition g_option_table[]; uint32_t m_id; }; @@ -4177,13 +4181,6 @@ private: CommandOptions m_options; }; -OptionDefinition CommandObjectRenderScriptRuntimeAllocationList:: - CommandOptions::g_option_table[] = { - {LLDB_OPT_SET_1, false, "id", 'i', OptionParser::eRequiredArgument, - nullptr, nullptr, 0, eArgTypeIndex, - "Only show details of a single allocation with specified id."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; - class CommandObjectRenderScriptRuntimeAllocationLoad : public CommandObjectParsed { public: diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 0a6e324d770..ff87150c67f 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, |

