[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name

2020-05-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D79929#2058939 , @MrHate wrote:

> That does make sense. I will split it into `eArgTypeProcessPlugin` and 
> `eArgTypeDisassemblePlugin` along with the corresponding completion function 
> names at the time I implement the `disassemble` related completion function.


Excellent, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79929/new/

https://reviews.llvm.org/D79929



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name

2020-05-27 Thread Gongyu Deng via Phabricator via lldb-commits
MrHate marked an inline comment as done.
MrHate added a comment.

That does make sense. I will split it into `eArgTypeProcessPlugin` and 
`eArgTypeDisassemblePlugin` along with the corresponding completion function 
names at the time I implement the `disassemble` related completion function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79929/new/

https://reviews.llvm.org/D79929



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name

2020-05-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This change makes the eArgTypePlugin be the completion for process plugins.  
Shouldn't we change the enum name and completion name to indicate that?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79929/new/

https://reviews.llvm.org/D79929



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name

2020-05-27 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG763bc2305797: [lldb] Tab completion for process plugin name 
(authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D79929?vs=265742=266498#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79929/new/

https://reviews.llvm.org/D79929

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -85,6 +85,13 @@
   ['mips',
'arm64'])
 
+def test_process_plugin_completion(self):
+subcommands = ['attach -P', 'connect -p', 'launch -p']
+
+for subcommand in subcommands:
+self.complete_from_to('process ' + subcommand + ' mac',
+  'process ' + subcommand + ' mach-o-core')
+
 def test_process_signal(self):
 # The tab completion for "process signal"  won't work without a running process.
 self.complete_from_to('process signal ',
Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1080,7 +1080,7 @@
 { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
 { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
 { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." },
-{ eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+{ eArgTypePlugin, "plugin", CommandCompletions::eProcessPluginCompletion, { nullptr, false }, "Help text goes here." },
 { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." },
 { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." },
 { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." },
Index: lldb/source/Core/PluginManager.cpp
===
--- lldb/source/Core/PluginManager.cpp
+++ lldb/source/Core/PluginManager.cpp
@@ -830,6 +830,14 @@
   return GetProcessInstances().GetCallbackForName(name);
 }
 
+void PluginManager::AutoCompleteProcessName(llvm::StringRef name,
+CompletionRequest ) {
+  for (const auto  : GetProcessInstances().GetInstances()) {
+if (instance.name.GetStringRef().startswith(name))
+  request.AddCompletion(instance.name.GetCString(), instance.description);
+  }
+}
+
 #pragma mark ScriptInterpreter
 
 struct ScriptInterpreterInstance
Index: lldb/source/Commands/CommandObjectProcess.cpp
===
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -325,34 +325,38 @@
   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