aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorGongyu Deng <gy_deng@icloud.com>2020-08-24 14:23:23 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-08-24 17:30:43 +0200
commit19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa (patch)
tree0683c608ce9c62759e81b639ea0fd8336aa452e4 /lldb/source/Commands/CommandObjectPlatform.cpp
parentd1a1cce5b130630df0c821e8cafe5f683ccccb90 (diff)
downloadllvm-19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa.zip
llvm-19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa.tar.gz
llvm-19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa.tar.bz2
[lldb] common completion for process pids and process names
1. Added two common completions: `ProcessIDs` and `ProcessNames`, which are refactored from their original dedicated option completions; 2. Removed the dedicated option completion functions of `process attach` and `platform process attach`, so that they can use arg-type-bound common completions instead; 3. Bound `eArgTypePid` to the pid completion, `eArgTypeProcessName` to the process name completion in `CommandObject.cpp`; 4. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D80700
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp48
1 files changed, 8 insertions, 40 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 4c235cb..da113e5c 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1331,6 +1331,14 @@ public:
~CommandObjectPlatformProcessInfo() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eProcessIDCompletion,
+ request, nullptr);
+ }
+
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
Target *target = GetDebugger().GetSelectedTarget().get();
@@ -1447,46 +1455,6 @@ public:
return llvm::makeArrayRef(g_platform_process_attach_options);
}
- void HandleOptionArgumentCompletion(
- CompletionRequest &request, OptionElementVector &opt_element_vector,
- int opt_element_index, CommandInterpreter &interpreter) override {
- 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 uint32_t num_matches = process_infos.size();
- if (num_matches == 0)
- return;
-
- for (uint32_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(process_infos[i].GetNameAsStringRef());
- }
- return;
- }
-
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];