================ @@ -1167,21 +1168,61 @@ def __init__( if log_file: adaptor_env["LLDBDAP_LOG"] = log_file + args = [executable] + + if connection is not None: + args.append("--connection") + args.append(connection) + self.process = subprocess.Popen( - [executable], + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=adaptor_env, ) + + if connection is not None: + # If the process was also launched, parse the connection from the + # resolved connection. For example, if the connection + # `connection://localhost:0` was specified then the OS would pick a + # random port for listening and lldb-dap would print the listening + # port to stdout. + if self.process is not None: + # lldb-dap will print the listening address once the listener is + # made to stdout. The listener is formatted like + # `connection://host:port` or `unix-connection:///path`. + expected_prefix = "Listening for: " + out = self.process.stdout.readline().decode() + if not out.startswith(expected_prefix): + self.process.kill() + raise ValueError( + "lldb-dap failed to print listening address, expected '{}', got '{}'".format( + expected_prefix, out + ) + ) + + # If the listener expanded into multiple addresses, use the first. + connection = ( + out.removeprefix(expected_prefix).rstrip("\r\n").split(",", 1)[0] + ) + + if connection.startswith("unix-connect://"): # unix-connect:///path ---------------- labath wrote:
How about something like: ```suggestion scheme, address = connection.split("://") if connection == "unix-connect": # unix-connect:///path # etc. ``` https://github.com/llvm/llvm-project/pull/116392 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits