[Lldb-commits] [lldb] 8a5e296 - [lldb] tab completion for `disassemble -F`
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 11 01:02:07 PDT 2020
Author: Gongyu Deng
Date: 2020-08-11T10:01:45+02:00
New Revision: 8a5e296975b3da5d5d849ae8185ef3d98ca77795
URL: https://github.com/llvm/llvm-project/commit/8a5e296975b3da5d5d849ae8185ef3d98ca77795
DIFF: https://github.com/llvm/llvm-project/commit/8a5e296975b3da5d5d849ae8185ef3d98ca77795.diff
LOG: [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.
Added:
Modified:
lldb/include/lldb/Interpreter/CommandCompletions.h
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/test/API/functionalities/completion/TestCompletion.py
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index 39d1c98eaa39..55ab5d8a6375 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -37,10 +37,11 @@ class CommandCompletions {
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 @@ class CommandCompletions {
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 48df77357201..69d7f78b8c6c 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 6f58b8ba0ea7..946ea814bc0d 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 a57dbdbd22ea..030bd25d3454 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -115,6 +115,12 @@ def test_ambiguous_long_opt(self):
'--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 ', [])
More information about the lldb-commits
mailing list