Index: lldb/include/lldb/Interpreter/CommandCompletions.h =================================================================== --- lldb/include/lldb/Interpreter/CommandCompletions.h +++ lldb/include/lldb/Interpreter/CommandCompletions.h @@ -42,10 +42,11 @@ eFrameIndexCompletion = (1u << 14), eThreadIndexCompletion = (1u << 15), eWatchPointIDCompletion = (1u << 16), + eModuleUUIDCompletion = (1u << 17), // 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 << 17) + eCustomCompletion = (1u << 18) }; static bool InvokeCommonCompletionCallbacks( @@ -73,6 +74,9 @@ 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); Index: lldb/include/lldb/lldb-enumerations.h =================================================================== --- lldb/include/lldb/lldb-enumerations.h +++ lldb/include/lldb/lldb-enumerations.h @@ -592,6 +592,7 @@ eArgRawInput, eArgTypeCommand, eArgTypeColumnNum, + eArgTypeModuleUUID, eArgTypeLastArg // Always keep this entry as the last entry in this // enumeration!! }; Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -55,6 +55,7 @@ {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories}, {eSymbolCompletion, CommandCompletions::Symbols}, {eModuleCompletion, CommandCompletions::Modules}, + {eModuleUUIDCompletion, CommandCompletions::ModuleUUIDs}, {eSettingsNameCompletion, CommandCompletions::SettingsNames}, {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames}, {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, @@ -494,6 +495,24 @@ } } +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) { Index: lldb/source/Interpreter/CommandObject.cpp =================================================================== --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -1118,7 +1118,8 @@ { 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 }; Index: lldb/source/Interpreter/OptionGroupUUID.cpp =================================================================== --- lldb/source/Interpreter/OptionGroupUUID.cpp +++ lldb/source/Interpreter/OptionGroupUUID.cpp @@ -18,8 +18,16 @@ OptionGroupUUID::~OptionGroupUUID() {} static constexpr OptionDefinition g_option_table[] = { - {LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument, - nullptr, {}, 0, eArgTypeNone, "A module UUID value."}, + {LLDB_OPT_SET_1, + false, + "uuid", + 'u', + OptionParser::eRequiredArgument, + nullptr, + {}, + 0, + eArgTypeModuleUUID, + "A module UUID value."}, }; llvm::ArrayRef OptionGroupUUID::GetDefinitions() { Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -371,6 +371,11 @@ self.complete_from_to('target modules load a.ou', ['a.out']) + 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_target_create_dash_co(self): """Test that 'target create --co' completes to 'target variable --core '.""" self.complete_from_to('target create --co', 'target create --core ')