[lldb] Make `process connect` behave the same in sync and async mode.
authorJonas Devlieghere <jonas@devlieghere.com>
Sat, 14 Nov 2020 01:30:34 +0000 (17:30 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Sat, 14 Nov 2020 01:39:30 +0000 (17:39 -0800)
I think the check for whether the process is connected is totally bogus
in the first place, but on the off-chance that's it's not, we should
behave the same in synchronous and asynchronous mode.

lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/test/Shell/Commands/command-process-connect.test [new file with mode: 0644]

index 0e0b61f..e8bfbd8 100644 (file)
@@ -837,18 +837,6 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
   return std::string(result.GetString());
 }
 
-lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
-    llvm::StringRef connect_url, llvm::StringRef plugin_name,
-    lldb_private::Debugger &debugger, lldb_private::Target *target,
-    lldb_private::Status &error) {
-  if (!IsRemote() || !IsConnected()) {
-    error.SetErrorString("Not connected to remote gdb server");
-    return nullptr;
-  }
-  return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
-                                  error);
-}
-
 size_t PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger &debugger,
                                                           Status &error) {
   std::vector<std::string> connection_urls;
index 297b482..e43cd0e 100644 (file)
@@ -154,12 +154,6 @@ public:
 
   const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
 
-  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
-                                 llvm::StringRef plugin_name,
-                                 lldb_private::Debugger &debugger,
-                                 lldb_private::Target *target,
-                                 lldb_private::Status &error) override;
-
   size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
                                    lldb_private::Status &error) override;
 
diff --git a/lldb/test/Shell/Commands/command-process-connect.test b/lldb/test/Shell/Commands/command-process-connect.test
new file mode 100644 (file)
index 0000000..c476136
--- /dev/null
@@ -0,0 +1,9 @@
+# Synchronous
+# RUN: %lldb -o 'platform select remote-gdb-server' -o 'process connect connect://localhost:4321' 2>&1 | FileCheck %s
+
+# Asynchronous
+# RUN: echo -e 'platform select remote-gdb-server\nprocess connect connect://localhost:4321' | %lldb 2>&1 | FileCheck %s
+
+# CHECK: Platform: remote-gdb-server
+# CHECK: Connected: no
+# CHECK: error: Failed to connect port