[Lldb-commits] [lldb] 419f1be - [lldb] tab completion for `target modules load -u`
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 11 03:35:53 PDT 2020
Author: Gongyu Deng
Date: 2020-08-11T12:35:36+02:00
New Revision: 419f1be7b54ef2c285050c24e4b4c333cb108cfc
URL: https://github.com/llvm/llvm-project/commit/419f1be7b54ef2c285050c24e4b4c333cb108cfc
DIFF: https://github.com/llvm/llvm-project/commit/419f1be7b54ef2c285050c24e4b4c333cb108cfc.diff
LOG: [lldb] tab completion for `target modules load -u`
1. Added a common completion ModuleUUIDs to provide a list of the UUIDs of modules for completion;
2. Added a new enumeration item eArgTypeModuleUUID to CommandArgumentType which is set as the option argument type of OptionGroupUUID;
3. Applied the module UUID completion to the argument of the type eArgTypeModuleUUID in lldb/source/Interpreter/CommandObject.cpp;
4. Added an related test case in lldb/test/API/functionalities/completion/TestCompletion.py.
Added:
Modified:
lldb/include/lldb/Interpreter/CommandCompletions.h
lldb/include/lldb/lldb-enumerations.h
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Interpreter/OptionGroupUUID.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 306c6c121f5f..4392e335061e 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -40,10 +40,11 @@ class CommandCompletions {
eDisassemblyFlavorCompletion = (1u << 12),
eTypeLanguageCompletion = (1u << 13),
eFrameIndexCompletion = (1u << 14),
+ eModuleUUIDCompletion = (1u << 15),
// 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 << 15)
+ eCustomCompletion = (1u << 16)
};
static bool InvokeCommonCompletionCallbacks(
@@ -71,6 +72,9 @@ class CommandCompletions {
static void Modules(CommandInterpreter &interpreter,
CompletionRequest &request, SearchFilter *searcher);
+ static void ModuleUUIDs(CommandInterpreter &interpreter,
+ CompletionRequest &request, SearchFilter *searcher);
+
static void Symbols(CommandInterpreter &interpreter,
CompletionRequest &request, SearchFilter *searcher);
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 107c3ffe8f95..8692dd8705ae 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -596,6 +596,7 @@ enum CommandArgumentType {
eArgRawInput,
eArgTypeCommand,
eArgTypeColumnNum,
+ eArgTypeModuleUUID,
eArgTypeLastArg // Always keep this entry as the last entry in this
// enumeration!!
};
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 25f684a28268..590a0d2dfad8 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -54,6 +54,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
{eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
{eSymbolCompletion, CommandCompletions::Symbols},
{eModuleCompletion, CommandCompletions::Modules},
+ {eModuleUUIDCompletion, CommandCompletions::ModuleUUIDs},
{eSettingsNameCompletion, CommandCompletions::SettingsNames},
{ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
{eArchitectureCompletion, CommandCompletions::ArchitectureNames},
@@ -491,6 +492,24 @@ void CommandCompletions::Modules(CommandInterpreter &interpreter,
}
}
+void CommandCompletions::ModuleUUIDs(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ const ExecutionContext &exe_ctx = interpreter.GetExecutionContext();
+ if (!exe_ctx.HasTargetScope())
+ return;
+
+ exe_ctx.GetTargetPtr()->GetImages().ForEach(
+ [&request](const lldb::ModuleSP &module) {
+ StreamString strm;
+ module->GetDescription(strm.AsRawOstream(),
+ lldb::eDescriptionLevelInitial);
+ request.TryCompleteCurrentArg(module->GetUUID().GetAsString(),
+ strm.GetString());
+ return true;
+ });
+}
+
void CommandCompletions::Symbols(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index fc3127611ae5..6f356e448523 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -1119,7 +1119,8 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." },
{ eArgRawInput, "raw-input", CommandCompletions::eNoCompletion, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes. To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." },
{ eArgTypeCommand, "command", CommandCompletions::eNoCompletion, { nullptr, false }, "An LLDB Command line command." },
- { eArgTypeColumnNum, "column", CommandCompletions::eNoCompletion, { nullptr, false }, "Column number in a source file." }
+ { eArgTypeColumnNum, "column", CommandCompletions::eNoCompletion, { nullptr, false }, "Column number in a source file." },
+ { eArgTypeModuleUUID, "module-uuid", CommandCompletions::eModuleUUIDCompletion, { nullptr, false }, "A module UUID value." }
// clang-format on
};
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index 46f2ff75225a..dc6f4139896f 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -19,7 +19,7 @@ OptionGroupUUID::~OptionGroupUUID() {}
static constexpr OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
- nullptr, {}, 0, eArgTypeNone, "A module UUID value."},
+ nullptr, {}, 0, eArgTypeModuleUUID, "A module UUID value."},
};
llvm::ArrayRef<OptionDefinition> OptionGroupUUID::GetDefinitions() {
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 691a6e89eec5..d41139947b81 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -551,6 +551,11 @@ def test_register_read_and_write_on_x86(self):
def test_common_completion_type_language(self):
self.complete_from_to('type category -l ', ['c'])
+ def test_target_modules_load_dash_u(self):
+ self.build()
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.complete_from_to('target modules load -u ', [target.GetModuleAtIndex(0).GetUUIDString()])
+
def test_complete_breakpoint_with_ids(self):
"""These breakpoint subcommands should be completed with a list of breakpoint ids"""
More information about the lldb-commits
mailing list