mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Support listening on serial port when serial:// protocol is being used
in place of host/port.  This is not fully functional yet, as lldb-server
crashes when attempting to send long packets (e.g. target.xml contents).


https://reviews.llvm.org/D111964

Files:
  lldb/tools/lldb-server/lldb-gdbserver.cpp


Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===================================================================
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -228,23 +228,26 @@
       final_host_and_port.append("localhost");
     final_host_and_port.append(host_and_port.str());
 
-    if (reverse_connect) {
+    bool is_serial = host_and_port.startswith("serial://");
+    if (reverse_connect || is_serial) {
       // llgs will connect to the gdb-remote client.
 
-      // Ensure we have a port number for the connection.
-      // Note: use rfind, because the host/port may look like "[::1]:12345".
-      uint32_t connection_portno = 0;
-      const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-      if (colon_pos != std::string::npos)
-        llvm::to_integer(final_host_and_port.substr(colon_pos + 1), 
connection_portno);
-      if (connection_portno == 0) {
-        fprintf(stderr, "error: port number must be specified on when using "
-                        "reverse connect\n");
-        exit(1);
-      }
+      if (!is_serial) {
+        // Ensure we have a port number for the connection.
+        // Note: use rfind, because the host/port may look like "[::1]:12345".
+        uint32_t connection_portno = 0;
+        const std::string::size_type colon_pos = 
final_host_and_port.rfind(':');
+        if (colon_pos != std::string::npos)
+          llvm::to_integer(final_host_and_port.substr(colon_pos + 1), 
connection_portno);
+        if (connection_portno == 0) {
+          fprintf(stderr, "error: port number must be specified on when using "
+                          "reverse connect\n");
+          exit(1);
+        }
 
-      // Build the connection string.
-      final_host_and_port.insert(0, "connect://");
+        // Build the connection string.
+        final_host_and_port.insert(0, "connect://");
+      }
 
       // Create the connection.
       connection_up.reset(new ConnectionFileDescriptor);


Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===================================================================
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -228,23 +228,26 @@
       final_host_and_port.append("localhost");
     final_host_and_port.append(host_and_port.str());
 
-    if (reverse_connect) {
+    bool is_serial = host_and_port.startswith("serial://");
+    if (reverse_connect || is_serial) {
       // llgs will connect to the gdb-remote client.
 
-      // Ensure we have a port number for the connection.
-      // Note: use rfind, because the host/port may look like "[::1]:12345".
-      uint32_t connection_portno = 0;
-      const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-      if (colon_pos != std::string::npos)
-        llvm::to_integer(final_host_and_port.substr(colon_pos + 1), connection_portno);
-      if (connection_portno == 0) {
-        fprintf(stderr, "error: port number must be specified on when using "
-                        "reverse connect\n");
-        exit(1);
-      }
+      if (!is_serial) {
+        // Ensure we have a port number for the connection.
+        // Note: use rfind, because the host/port may look like "[::1]:12345".
+        uint32_t connection_portno = 0;
+        const std::string::size_type colon_pos = final_host_and_port.rfind(':');
+        if (colon_pos != std::string::npos)
+          llvm::to_integer(final_host_and_port.substr(colon_pos + 1), connection_portno);
+        if (connection_portno == 0) {
+          fprintf(stderr, "error: port number must be specified on when using "
+                          "reverse connect\n");
+          exit(1);
+        }
 
-      // Build the connection string.
-      final_host_and_port.insert(0, "connect://");
+        // Build the connection string.
+        final_host_and_port.insert(0, "connect://");
+      }
 
       // Create the connection.
       connection_up.reset(new ConnectionFileDescriptor);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] D11... Michał Górny via Phabricator via lldb-commits

Reply via email to