This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add a gdb_remote_client test for connecting to pty
ClosedPublic

Authored by mgorny on Sep 30 2021, 1:36 PM.

Details

Summary

Add a minimal mock server utilizing a pty, and add a client test
connecting to that server.

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 30 2021, 1:36 PM
mgorny created this revision.

@labath, this is the part where I ask for help ;-).

An exception happened when receiving the response from the gdb server. Closing the client...
Traceback (most recent call last):
  File "/home/mgorny/git/llvm-project/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py", line 405, in _run
    data = seven.bitcast_to_string(self._client.recv(4096))
  File "/home/mgorny/git/llvm-project/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py", line 538, in recv
    return self.read(size)
OSError: [Errno 5] Input/output error
PASS: LLDB (/home/mgorny/git/llvm-project/build/bin/clang-x86_64) :: test_process_connect_sync_dwarf (TestPty.TestPty)

I think it's getting in the 'controlling terminal' magic and getting EIO when lldb finishes or sth like that. Any suggestion how to avoid this exception?

labath added a comment.Oct 1 2021, 1:19 AM

@labath, this is the part where I ask for help ;-).

An exception happened when receiving the response from the gdb server. Closing the client...
Traceback (most recent call last):
  File "/home/mgorny/git/llvm-project/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py", line 405, in _run
    data = seven.bitcast_to_string(self._client.recv(4096))
  File "/home/mgorny/git/llvm-project/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py", line 538, in recv
    return self.read(size)
OSError: [Errno 5] Input/output error
PASS: LLDB (/home/mgorny/git/llvm-project/build/bin/clang-x86_64) :: test_process_connect_sync_dwarf (TestPty.TestPty)

I think it's getting in the 'controlling terminal' magic and getting EIO when lldb finishes or sth like that. Any suggestion how to avoid this exception?

Catch it and turn it into EOF? (btw, I've found this link to be pretty good at explaining the behavior across different OSs.)

lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
618–623

I think it would be cleaner if we had like a single new interface, which describes what to we expect of the connection, and then a socket- and pty-based implementation of that interface.

648–652

I'm wondering if we should have an overload of SBTarget::ConnectRemote that accepts a file descriptor (or SBFile, SBCommunication, ...).

This would make the socket case easier as well, and it seems like it could be generally useful.

mgorny added inline comments.Oct 1 2021, 1:41 AM
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
648–652

I'm not saying 'no' but I think we'd still want to explicitly test process connect command somewhere.

mgorny updated this revision to Diff 376456.Oct 1 2021, 2:30 AM
mgorny marked an inline comment as done.

Replaced the class hacks with an abstraction over socket & connection sockets.

labath added inline comments.Oct 1 2021, 2:38 AM
lldb/test/API/functionalities/gdb_remote_client/TestPty.py
22

I think this can be applied at class level

lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
409

do you actually need to keep the slave open here?

mgorny marked 2 inline comments as done.Oct 1 2021, 5:00 AM
mgorny added inline comments.
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
409

Yes, it seems this way. If I close it early, the test hangs.

mgorny updated this revision to Diff 376480.Oct 1 2021, 5:03 AM
mgorny marked an inline comment as done.
mgorny retitled this revision from [lldb] Add a gdb_remote_client test for connecting to pty [WIP] to [lldb] Add a gdb_remote_client test for connecting to pty.

Make it easier to override socket class at GDBRemoteTestBase level. Add async test, mark the whole class skipIfWindows.

mgorny updated this revision to Diff 376487.Oct 1 2021, 5:25 AM

Add get_connect_url() to simplify combining address with proper protocol/prefix.

labath accepted this revision.Oct 1 2021, 5:29 AM
This revision is now accepted and ready to land.Oct 1 2021, 5:29 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 1 2021, 5:32 AM