[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 5 08:54:55 PST 2024


================
@@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() {
   return CheckIPSupport("IPv6", "[::1]:0");
 }
 
+bool lldb_private::HostSupportsLocalhostToIPv4() {
+  if (!HostSupportsIPv4())
+    return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET,
+                                                 SOCK_STREAM, IPPROTO_TCP);
+  return !addresses.empty();
+}
+
+bool lldb_private::HostSupportsLocalhostToIPv6() {
+  if (!HostSupportsIPv6())
+    return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6,
+                                                 SOCK_STREAM, IPPROTO_TCP);
----------------
ashgti wrote:

Thanks for the suggestion!

I tried this on my mac by commenting out the `::1 localhost` line in my hosts file, but I wonder if I had some caching or something happening.

Applied this suggestion.

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


More information about the lldb-commits mailing list