[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
Walter Erquinigo via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 20 05:54:56 PST 2025
================
@@ -4952,6 +4895,29 @@ static int DuplicateFileDescriptor(int fd) {
#endif
}
+static llvm::Expected<std::pair<Socket::SocketProtocol, std::string>>
+validateConnection(llvm::StringRef conn) {
+ auto uri = lldb_private::URI::Parse(conn);
+
+ if (uri && (uri->scheme == "tcp" || uri->scheme == "connect" ||
+ !uri->hostname.empty() || uri->port)) {
+ return std::make_pair(
+ Socket::ProtocolTcp,
+ formatv("[{0}]:{1}", uri->hostname.empty() ? "0.0.0.0" : uri->hostname,
+ uri->port.value_or(0)));
+ }
+
+ if (uri && (uri->scheme == "unix" || uri->scheme == "unix-connect" ||
+ uri->path != "/")) {
+ return std::make_pair(Socket::ProtocolUnixDomain, uri->path.str());
+ }
+
+ return llvm::createStringError(
+ "Unsupported connection specifier, expected 'unix-connect:///path' or "
+ "'connect://[host]:port', got '%s'.",
+ conn.str().c_str());
+}
+
int main(int argc, char *argv[]) {
----------------
walter-erquinigo wrote:
the newly added logic seems correct, but would it be possible to extract out some of code into other functions? I'm afraid main is starting to get too big to be easily readable
https://github.com/llvm/llvm-project/pull/116392
More information about the lldb-commits
mailing list