mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
[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
This commit is contained in:
committed by
Raphael Isemann
parent
c7593b0f0d
commit
763bc23057
@@ -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...
|
||||
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.
|
||||
|
||||
// Are we in the name?
|
||||
if (GetDefinitions()[opt_defs_index].short_option != 'n')
|
||||
return;
|
||||
const char *partial_name = nullptr;
|
||||
partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
|
||||
|
||||
// Look to see if there is a -P argument provided, and if so use that
|
||||
// plugin, otherwise use the default plugin.
|
||||
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;
|
||||
|
||||
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());
|
||||
case 'P':
|
||||
CommandCompletions::InvokeCommonCompletionCallbacks(
|
||||
interpreter, CommandCompletions::eProcessPluginCompletion, request,
|
||||
nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user