[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

Santhosh Kumar Ellendula via lldb-commits lldb-commits at lists.llvm.org
Thu May 30 06:26:09 PDT 2024


================
@@ -749,9 +752,30 @@ void request_attach(const llvm::json::Object &request) {
     // Disable async events so the attach will be successful when we return from
     // the launch call and the launch will happen synchronously
     g_dap.debugger.SetAsync(false);
-    if (core_file.empty())
-      g_dap.target.Attach(attach_info, error);
-    else
+    if (core_file.empty()) {
+      if ((pid != LLDB_INVALID_PROCESS_ID) && (port != invalid_port)) {
+        // If both pid and port numbers are specified.
+        error.SetErrorString("The user can't specify both pid and port");
+      } else if (port != invalid_port) {
+        // If port is specified and pid is not.
+        lldb::SBListener listener = g_dap.debugger.GetListener();
+
+        // If the user hasn't provided the hostname property, default localhost
+        // being used.
+        std::string connect_url("connect://localhost:");
+
+        // If the user has provided hostname other than localhost.
+        if (!hostname.empty() && !hostname.starts_with("localhost")) {
+          connect_url = llvm::formatv("connect://{0}:", hostname.data());
+        }
+        connect_url += std::to_string(port);
+        g_dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
----------------
santhoshe447 wrote:

Since we don't support any process plugins other than "gdb-remote", would it be a problem to hardcode "gdb-remote"? Adding a "process-plugin" attribute would be an additional burden to maintain and might confuse users.
If we use default "process-pligin"="gdb-remote" would be ok but let's take opinion from forks.



https://github.com/llvm/llvm-project/pull/91570


More information about the lldb-commits mailing list