diff options
author | Gongyu Deng <gy_deng@icloud.com> | 2020-05-27 14:06:28 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-05-27 14:11:16 +0200 |
commit | 763bc2305797c980a4f4fa2f6314ed78a010678d (patch) | |
tree | b0d875b9dd0f3d4cb6aa31d64584575dbaa5112d /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | c7593b0f0d28f6b7f9fa4557ce73197a49b37799 (diff) | |
download | llvm-763bc2305797c980a4f4fa2f6314ed78a010678d.zip llvm-763bc2305797c980a4f4fa2f6314ed78a010678d.tar.gz llvm-763bc2305797c980a4f4fa2f6314ed78a010678d.tar.bz2 |
[lldb] Tab completion for process plugin name
Summary:
1. Added tab completion to `process launch -p`, `process attach -P`, `process
connect -p`;
2. Bound the plugin name common completion as the default completion for
`eArgTypePlugin` arguments.
Reviewers: teemperor, JDevlieghere
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D79929
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 043765a..4f591b5 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -325,34 +325,38 @@ public: int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; - // We are only completing the name option for now... - - // Are we in the name? - if (GetDefinitions()[opt_defs_index].short_option != 'n') - return; - - // Look to see if there is a -P argument provided, and if so use that - // plugin, otherwise use the default plugin. - - const char *partial_name = nullptr; - partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos); - - PlatformSP platform_sp(interpreter.GetPlatform(true)); - if (!platform_sp) - return; - ProcessInstanceInfoList process_infos; - ProcessInstanceInfoMatch match_info; - if (partial_name) { - match_info.GetProcessInfo().GetExecutableFile().SetFile( - partial_name, FileSpec::Style::native); - match_info.SetNameMatchType(NameMatch::StartsWith); - } - platform_sp->FindProcesses(match_info, process_infos); - const size_t num_matches = process_infos.size(); - if (num_matches == 0) - return; - for (size_t i = 0; i < num_matches; ++i) { - request.AddCompletion(process_infos[i].GetNameAsStringRef()); + switch (GetDefinitions()[opt_defs_index].short_option) { + case 'n': { + // Look to see if there is a -P argument provided, and if so use that + // plugin, otherwise use the default plugin. + + const char *partial_name = nullptr; + partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos); + + PlatformSP platform_sp(interpreter.GetPlatform(true)); + if (!platform_sp) + return; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; + if (partial_name) { + match_info.GetProcessInfo().GetExecutableFile().SetFile( + partial_name, FileSpec::Style::native); + match_info.SetNameMatchType(NameMatch::StartsWith); + } + platform_sp->FindProcesses(match_info, process_infos); + const size_t num_matches = process_infos.size(); + if (num_matches == 0) + return; + for (size_t i = 0; i < num_matches; ++i) { + request.AddCompletion(process_infos[i].GetNameAsStringRef()); + } + } break; + + case 'P': + CommandCompletions::InvokeCommonCompletionCallbacks( + interpreter, CommandCompletions::eProcessPluginCompletion, request, + nullptr); + break; } } |