Skip to content

Commit 563ef30

Browse files
authored
Add the RegisterCompleter to eArgTypeRegisterName in g_argument_table (#82428)
This is a follow-on to: #82085 The completer for register names was missing from the argument table. I somehow missed that the only register completer test was x86_64, so that test broke. I added the completer in to the right slot in the argument table, and added a small completions test that just uses the alias register names. If we end up having a platform that doesn't define register names, we'll have to skip this test there, but it should add a sniff test for register completion that will run most everywhere.
1 parent 31f4559 commit 563ef30

20 files changed

+108
-237
lines changed

lldb/include/lldb/Interpreter/CommandObject.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ class CommandObject : public std::enable_shared_from_this<CommandObject> {
242242
/// The completion request that needs to be answered.
243243
virtual void HandleCompletion(CompletionRequest &request);
244244

245+
/// The default version handles argument definitions that have only one
246+
/// argument type, and use one of the argument types that have an entry in
247+
/// the CommonCompletions. Override this if you have a more complex
248+
/// argument setup.
249+
/// FIXME: we should be able to extend this to more complex argument
250+
/// definitions provided we have completers for all the argument types.
251+
///
245252
/// The input array contains a parsed version of the line.
246253
///
247254
/// We've constructed the map of options and their arguments as well if that
@@ -251,7 +258,7 @@ class CommandObject : public std::enable_shared_from_this<CommandObject> {
251258
/// The completion request that needs to be answered.
252259
virtual void
253260
HandleArgumentCompletion(CompletionRequest &request,
254-
OptionElementVector &opt_element_vector) {}
261+
OptionElementVector &opt_element_vector);
255262

256263
bool HelpTextContainsWord(llvm::StringRef search_word,
257264
bool search_short_help = true,

lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h

+13-10
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
243243
{ lldb::eArgTypeLogCategory, "log-category", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
244244
{ lldb::eArgTypeLogChannel, "log-channel", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
245245
{ lldb::eArgTypeMethod, "method", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A C++ method name." },
246-
{ lldb::eArgTypeName, "name", lldb::eTypeCategoryNameCompletion, {}, { nullptr, false }, "Help text goes here." },
246+
{ lldb::eArgTypeName, "name", lldb::eTypeCategoryNameCompletion, {}, { nullptr, false }, "The name of a type category." },
247247
{ lldb::eArgTypeNewPathPrefix, "new-path-prefix", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
248248
{ lldb::eArgTypeNumLines, "num-lines", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The number of lines to use." },
249249
{ lldb::eArgTypeNumberPerLine, "number-per-line", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The number of items per line to display." },
@@ -260,31 +260,31 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
260260
{ lldb::eArgTypePythonFunction, "python-function", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a Python function." },
261261
{ lldb::eArgTypePythonScript, "python-script", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Source code written in Python." },
262262
{ lldb::eArgTypeQueueName, "queue-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of the thread queue." },
263-
{ lldb::eArgTypeRegisterName, "register-name", lldb::CompletionType::eNoCompletion, {}, { RegisterNameHelpTextCallback, true }, nullptr },
263+
{ lldb::eArgTypeRegisterName, "register-name", lldb::CompletionType::eRegisterCompletion, {}, { RegisterNameHelpTextCallback, true }, nullptr },
264264
{ lldb::eArgTypeRegularExpression, "regular-expression", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A POSIX-compliant extended regular expression." },
265-
{ lldb::eArgTypeRunArgs, "run-args", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
265+
{ lldb::eArgTypeRunArgs, "run-args", lldb::CompletionType::eDiskFileCompletion, {}, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
266266
{ lldb::eArgTypeRunMode, "run-mode", lldb::CompletionType::eNoCompletion, g_running_mode, { nullptr, false }, "Help text goes here." },
267267
{ lldb::eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", lldb::CompletionType::eNoCompletion, g_script_synchro_type, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
268268
{ lldb::eArgTypeScriptLang, "script-language", lldb::CompletionType::eNoCompletion, g_script_option_enumeration, { nullptr, false }, "The scripting language to be used for script-based commands. Supported languages are python and lua." },
269269
{ lldb::eArgTypeSearchWord, "search-word", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Any word of interest for search purposes." },
270270
{ lldb::eArgTypeSelector, "selector", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An Objective-C selector name." },
271271
{ lldb::eArgTypeSettingIndex, "setting-index", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
272272
{ lldb::eArgTypeSettingKey, "setting-key", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
273-
{ lldb::eArgTypeSettingPrefix, "setting-prefix", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
274-
{ lldb::eArgTypeSettingVariableName, "setting-variable-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." },
275-
{ lldb::eArgTypeShlibName, "shlib-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of a shared library." },
273+
{ lldb::eArgTypeSettingPrefix, "setting-prefix", lldb::CompletionType::eSettingsNameCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
274+
{ lldb::eArgTypeSettingVariableName, "setting-variable-name", lldb::CompletionType::eSettingsNameCompletion, {}, { nullptr, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." },
275+
{ lldb::eArgTypeShlibName, "shlib-name", lldb::CompletionType::eDiskFileCompletion, {}, { nullptr, false }, "The name of a shared library." },
276276
{ lldb::eArgTypeSourceFile, "source-file", lldb::eSourceFileCompletion, {}, { nullptr, false }, "The name of a source file.." },
277277
{ lldb::eArgTypeSortOrder, "sort-order", lldb::CompletionType::eNoCompletion, g_sort_option_enumeration, { nullptr, false }, "Specify a sort order when dumping lists." },
278278
{ lldb::eArgTypeStartAddress, "start-address", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
279279
{ lldb::eArgTypeSummaryString, "summary-string", lldb::CompletionType::eNoCompletion, {}, { SummaryStringHelpTextCallback, true }, nullptr },
280280
{ lldb::eArgTypeSymbol, "symbol", lldb::eSymbolCompletion, {}, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" },
281-
{ lldb::eArgTypeThreadID, "thread-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Thread ID number." },
282-
{ lldb::eArgTypeThreadIndex, "thread-index", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Index into the process' list of threads." },
281+
{ lldb::eArgTypeThreadID, "thread-id", lldb::CompletionType::eThreadIndexCompletion, {}, { nullptr, false }, "Thread ID number." },
282+
{ lldb::eArgTypeThreadIndex, "thread-index", lldb::CompletionType::eThreadIndexCompletion, {}, { nullptr, false }, "Index into the process' list of threads." },
283283
{ lldb::eArgTypeThreadName, "thread-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The thread's name." },
284284
{ lldb::eArgTypeTypeName, "type-name", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A type name." },
285285
{ lldb::eArgTypeUnsignedInteger, "unsigned-integer", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "An unsigned integer." },
286286
{ lldb::eArgTypeUnixSignal, "unix-signal", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
287-
{ lldb::eArgTypeVarName, "variable-name", lldb::CompletionType::eNoCompletion, {} ,{ nullptr, false }, "The name of a variable in your program." },
287+
{ lldb::eArgTypeVarName, "variable-name", lldb::CompletionType::eVariablePathCompletion, {} ,{ nullptr, false }, "The name of a variable in your program." },
288288
{ lldb::eArgTypeValue, "value", lldb::CompletionType::eNoCompletion, g_dependents_enumeration, { nullptr, false }, "A value could be anything, depending on where and how it is used." },
289289
{ lldb::eArgTypeWidth, "width", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Help text goes here." },
290290
{ lldb::eArgTypeNone, "none", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "No help available for this." },
@@ -302,8 +302,11 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
302302
{ lldb::eArgTypeRecognizerID, "frame-recognizer-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The ID for a stack frame recognizer." },
303303
{ lldb::eArgTypeConnectURL, "process-connect-url", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "A URL-style specification for a remote connection." },
304304
{ lldb::eArgTypeTargetID, "target-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The index ID for an lldb Target." },
305-
{ lldb::eArgTypeStopHookID, "stop-hook-id", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The ID you receive when you create a stop-hook." },
305+
{ lldb::eArgTypeStopHookID, "stop-hook-id", lldb::CompletionType::eStopHookIDCompletion, {}, { nullptr, false }, "The ID you receive when you create a stop-hook." },
306306
{ lldb::eArgTypeCompletionType, "completion-type", lldb::CompletionType::eNoCompletion, g_completion_type, { nullptr, false }, "The completion type to use when adding custom commands. If none is specified, the command won't use auto-completion." },
307+
{ lldb::eArgTypeRemotePath, "remote-path", lldb::CompletionType::eRemoteDiskFileCompletion, {}, { nullptr, false }, "A path on the system managed by the current platform." },
308+
{ lldb::eArgTypeRemoteFilename, "remote-filename", lldb::CompletionType::eRemoteDiskFileCompletion, {}, { nullptr, false }, "A file on the system managed by the current platform." },
309+
{ lldb::eArgTypeModule, "module", lldb::CompletionType::eModuleCompletion, {}, { nullptr, false }, "The name of a module loaded into the current target." },
307310
// clang-format on
308311
};
309312

lldb/include/lldb/lldb-enumerations.h

+3
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,9 @@ enum CommandArgumentType {
651651
eArgTypeTargetID,
652652
eArgTypeStopHookID,
653653
eArgTypeCompletionType,
654+
eArgTypeRemotePath,
655+
eArgTypeRemoteFilename,
656+
eArgTypeModule,
654657
eArgTypeLastArg // Always keep this entry as the last entry in this
655658
// enumeration!!
656659
};

lldb/source/Commands/CommandObjectCommands.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ class CommandObjectCommandsSource : public CommandObjectParsed {
6363
return std::string("");
6464
}
6565

66-
void
67-
HandleArgumentCompletion(CompletionRequest &request,
68-
OptionElementVector &opt_element_vector) override {
69-
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
70-
GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
71-
}
72-
7366
Options *GetOptions() override { return &m_options; }
7467

7568
protected:
@@ -1968,13 +1961,6 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
19681961

19691962
~CommandObjectCommandsScriptImport() override = default;
19701963

1971-
void
1972-
HandleArgumentCompletion(CompletionRequest &request,
1973-
OptionElementVector &opt_element_vector) override {
1974-
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
1975-
GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr);
1976-
}
1977-
19781964
Options *GetOptions() override { return &m_options; }
19791965

19801966
protected:

lldb/source/Commands/CommandObjectDWIMPrint.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ CommandObjectDWIMPrint::CommandObjectDWIMPrint(CommandInterpreter &interpreter)
5252

5353
Options *CommandObjectDWIMPrint::GetOptions() { return &m_option_group; }
5454

55-
void CommandObjectDWIMPrint::HandleArgumentCompletion(
56-
CompletionRequest &request, OptionElementVector &opt_element_vector) {
57-
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
58-
GetCommandInterpreter(), lldb::eVariablePathCompletion, request, nullptr);
59-
}
60-
6155
void CommandObjectDWIMPrint::DoExecute(StringRef command,
6256
CommandReturnObject &result) {
6357
m_option_group.NotifyOptionParsingStarting(&m_exe_ctx);

lldb/source/Commands/CommandObjectDWIMPrint.h

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class CommandObjectDWIMPrint : public CommandObjectRaw {
3939

4040
bool WantsCompletion() override { return true; }
4141

42-
void
43-
HandleArgumentCompletion(CompletionRequest &request,
44-
OptionElementVector &opt_element_vector) override;
45-
4642
private:
4743
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
4844

lldb/source/Commands/CommandObjectFrame.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,6 @@ class CommandObjectFrameSelect : public CommandObjectParsed {
286286

287287
~CommandObjectFrameSelect() override = default;
288288

289-
void
290-
HandleArgumentCompletion(CompletionRequest &request,
291-
OptionElementVector &opt_element_vector) override {
292-
if (request.GetCursorIndex() != 0)
293-
return;
294-
295-
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
296-
GetCommandInterpreter(), lldb::eFrameIndexCompletion, request, nullptr);
297-
}
298-
299289
Options *GetOptions() override { return &m_options; }
300290

301291
protected:
@@ -446,15 +436,6 @@ may even involve JITing and running code in the target program.)");
446436

447437
Options *GetOptions() override { return &m_option_group; }
448438

449-
void
450-
HandleArgumentCompletion(CompletionRequest &request,
451-
OptionElementVector &opt_element_vector) override {
452-
// Arguments are the standard source file completer.
453-
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
454-
GetCommandInterpreter(), lldb::eVariablePathCompletion, request,
455-
nullptr);
456-
}
457-
458439
protected:
459440
llvm::StringRef GetScopeString(VariableSP var_sp) {
460441
if (!var_sp)

0 commit comments

Comments
 (0)