forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Let table gen create command option initializers.
Summary: We currently have man large arrays containing initializers for our command options. These tables are tricky maintain as we don't have any good place to check them for consistency and it's also hard to read (`nullptr, {}, 0` is not very descriptive). This patch fixes this by letting table gen generate those tables. This way we can have a more readable syntax for this (especially for all the default arguments) and we can let TableCheck check them for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.). Also refactoring the related data structures can now be done without changing the hundred of option initializers. For example, this line: ``` {LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."}, ``` becomes this: ``` def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">; ``` For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other option initializers tables in separate patches. Reviewers: JDevlieghere, davide, sgraenitz Reviewed By: JDevlieghere Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64365 llvm-svn: 365908
- Loading branch information
Showing
13 changed files
with
436 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
include "OptionsBase.td" | ||
|
||
let Command = "target modules dump symtab" in { | ||
def tm_sort : Option<"sort", "s">, Group<1>, | ||
Desc<"Supply a sort order when dumping the symbol table.">, | ||
EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">; | ||
} | ||
|
||
let Command = "help" in { | ||
def help_hide_aliases : Option<"hide-aliases", "a">, | ||
Desc<"Hide aliases in the command list.">; | ||
def help_hide_user : Option<"hide-user-commands", "u">, | ||
Desc<"Hide user-defined commands from the list.">; | ||
def help_show_hidden : Option<"show-hidden-commands", "h">, | ||
Desc<"Include commands prefixed with an underscore.">; | ||
} | ||
|
||
let Command = "settings set" in { | ||
def setset_global : Option<"global", "g">, Arg<"Filename">, | ||
Completion<"DiskFile">, | ||
Desc<"Apply the new value to the global default value.">; | ||
def setset_force : Option<"force", "f">, | ||
Desc<"Force an empty value to be accepted as the default.">; | ||
} | ||
|
||
let Command = "settings write" in { | ||
def setwrite_file : Option<"file", "f">, Required, Arg<"Filename">, | ||
Completion<"DiskFile">, | ||
Desc<"The file into which to write the settings.">; | ||
def setwrite_append : Option<"append", "a">, | ||
Desc<"Append to saved settings file if it exists.">; | ||
} | ||
|
||
let Command = "settings read" in { | ||
def setread_file : Option<"file", "f">, Required, Arg<"Filename">, | ||
Completion<"DiskFile">, | ||
Desc<"The file from which to read the settings.">; | ||
} | ||
|
||
let Command = "breakpoint list" in { | ||
def blist_internal : Option<"internal", "i">, | ||
Desc<"Show debugger internal breakpoints">; | ||
def blist_brief : Option<"brief", "b">, Group<1>, | ||
Desc<"Give a brief description of the breakpoint (no location info).">; | ||
def blist_full : Option<"full", "f">, Group<2>, | ||
Desc<"Give a full description of the breakpoint and its locations.">; | ||
def blist_verbose : Option<"verbose", "v">, Group<3>, | ||
Desc<"Explain everything we know about the breakpoint (for debugging " | ||
"debugger bugs).">; | ||
def blist_dummy_bp : Option<"dummy-breakpoints", "D">, | ||
Desc<"List Dummy breakpoints - i.e. breakpoints set before a file is " | ||
"provided, which prime new targets.">; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Base class for all options. | ||
class Option<string fullname, string shortname> { | ||
string FullName = fullname; | ||
string ShortName = shortname; | ||
// The full associated command/subcommand such as "settings set". | ||
string Command; | ||
} | ||
|
||
// Moves the option into a list of option groups. | ||
class Groups<list<int> groups> { | ||
list<int> Groups = groups; | ||
} | ||
|
||
// Moves the option in all option groups in a range. | ||
// Start and end values are inclusive. | ||
class GroupRange<int start, int end> { | ||
int GroupStart = start; | ||
int GroupEnd = end; | ||
} | ||
// Moves the option in a single option group. | ||
class Group<int group> { | ||
int GroupStart = group; | ||
int GroupEnd = group; | ||
} | ||
|
||
// Sets the description for the option that should be | ||
// displayed to the user. | ||
class Desc<string description> { | ||
string Description = description; | ||
} | ||
|
||
// Marks the option as required when calling the | ||
// associated command. | ||
class Required { | ||
bit Required = 1; | ||
} | ||
|
||
// Gives the option an optional argument. | ||
class OptionalArg<string type> { | ||
string ArgType = type; | ||
bit OptionalArg = 1; | ||
} | ||
|
||
// Gives the option an required argument. | ||
class Arg<string type> { | ||
string ArgType = type; | ||
} | ||
|
||
// Gives the option an required argument. | ||
class EnumArg<string type, string enum> { | ||
string ArgType = type; | ||
string ArgEnum = enum; | ||
} | ||
|
||
// Sets the available completions for the given option. | ||
class Completions<list<string> completions> { | ||
list<string> Completions = completions; | ||
} | ||
// Sets a single completion for the given option. | ||
class Completion<string completion> { | ||
list<string> Completions = [completion]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(LLVM_LINK_COMPONENTS Support) | ||
|
||
add_tablegen(lldb-tblgen LLDB | ||
LLDBOptionDefEmitter.cpp | ||
LLDBTableGen.cpp | ||
) | ||
set_target_properties(lldb-tblgen PROPERTIES FOLDER "LLDB tablegenning") | ||
|
Oops, something went wrong.