DavidSpickett added a comment.

I was able to use the commands I showed before successfully but only after 
making these changes:

  --- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  +++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  @@ -231,14 +231,15 @@ class GdbRemoteTestCaseBase(Base):
           return target.GetByteOrder()
  
       def launch_debug_monitor(self, attach_pid=None, logfile=None):
  -        family, type, proto, _, addr = socket.getaddrinfo("localhost", 0, 
proto=socket.IPPROTO_TCP)[0]
  +        info = socket.getaddrinfo("0.0.0.0", 0, proto=socket.IPPROTO_TCP)
  +        family, type, proto, _, addr = info[0]
           sock = socket.socket(family, type, proto)
           sock.settimeout(self.DEFAULT_TIMEOUT)
  
           sock.bind(addr)
           sock.listen(1)
           addr = sock.getsockname()
  -        self.connect_address = "[{}]:{}".format(*addr)
  +        self.connect_address = "[{}]:{}".format(socket.getfqdn(), addr[1])

This is a hack obviously but it fixes the issues my particular setup has:

- By asking for "localhost" we get the IPV6 interface first and the QEMU VM 
doesn't have IPV6 to the host. (I'm sure it could with some extra setup)
- "0.0.0.0" fixes that issue since it's an IPV4 special address. (and means the 
port can be connected to externally?)
- Then we were telling lldb-server in the VM to connect to a local port, not to 
the port on the host. getfqdn fixes that.

So I end up with the host side listening to `0.0.0.0:<port>` and lldb-server in 
the VM connecting to `<host's hostname>:<port>` and that works.

If we want this scenario to work (and it's not a dodgy network setup on my 
part) perhaps we could take a hint from how we're connected to the initial 
platform?

  Connecting to remote platform 'remote-linux' at 'connect://<VM IPv4 
address>:54321'

So here we could assume that IPv4 is ok and since the hostname isn't any sort 
of localhost we need to tell the lldb-server to connect to the hostname of the 
machine running the tests.
(though that assumes you can in fact connect to that from the VM, with what I 
have, you can)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117559/new/

https://reviews.llvm.org/D117559

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to