diff options
author | Gongyu Deng <gy_deng@icloud.com> | 2020-08-11 09:59:30 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-08-11 10:01:45 +0200 |
commit | 8a5e296975b3da5d5d849ae8185ef3d98ca77795 (patch) | |
tree | 30fe5a97ba7fa9912c764cbe43a867482eecda62 | |
parent | 2e653327e364aae564209af99d3b6a4625e25b68 (diff) | |
download | llvm-8a5e296975b3da5d5d849ae8185ef3d98ca77795.zip llvm-8a5e296975b3da5d5d849ae8185ef3d98ca77795.tar.gz llvm-8a5e296975b3da5d5d849ae8185ef3d98ca77795.tar.bz2 |
[lldb] tab completion for `disassemble -F`
1.Added a new common completion DisassemblyFlavors;
2. Bound DisassemblyFlavors to argument of type eArgTypeDisassemblyFlavor in
CommandObject.cpp;
3. Added a related test case.
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandCompletions.h | 7 | ||||
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 2 | ||||
-rw-r--r-- | lldb/test/API/functionalities/completion/TestCompletion.py | 6 |
4 files changed, 26 insertions, 3 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 39d1c98..55ab5d8 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -37,10 +37,11 @@ public: eRegisterCompletion = (1u << 9), eBreakpointCompletion = (1u << 10), eProcessPluginCompletion = (1u << 11), + eDisassemblyFlavorCompletion = (1u << 12), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. - eCustomCompletion = (1u << 12) + eCustomCompletion = (1u << 13) }; static bool InvokeCommonCompletionCallbacks( @@ -94,6 +95,10 @@ public: static void ProcessPluginNames(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher); + + static void DisassemblyFlavors(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher); }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 48df773..69d7f78 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -59,6 +59,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eRegisterCompletion, CommandCompletions::Registers}, {eBreakpointCompletion, CommandCompletions::Breakpoints}, {eProcessPluginCompletion, CommandCompletions::ProcessPluginNames}, + {eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -593,4 +594,15 @@ void CommandCompletions::ProcessPluginNames(CommandInterpreter &interpreter, SearchFilter *searcher) { PluginManager::AutoCompleteProcessName(request.GetCursorArgumentPrefix(), request); -}
\ No newline at end of file +} + +void CommandCompletions::DisassemblyFlavors(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + // Currently the only valid options for disassemble -F are default, and for + // Intel architectures, att and intel. + static const char *flavors[] = {"default", "att", "intel"}; + for (const char *flavor : flavors) { + request.TryCompleteCurrentArg(flavor); + } +} diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 6f58b8b..946ea81 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -1047,7 +1047,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = { { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." }, { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." }, { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { nullptr, false }, "A directory name." }, - { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eNoCompletion, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" }, + { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eDisassemblyFlavorCompletion, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" }, { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." }, { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index a57dbdb..030bd25 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -115,6 +115,12 @@ class CommandLineCompletionTestCase(TestBase): '--thread-index', '--thread-name']) + def test_disassemble_dash_f(self): + self.completions_match('disassemble -F ', + ['default', + 'intel', + 'att']) + def test_plugin_load(self): self.complete_from_to('plugin load ', []) |