[lldb][NFC] Inclusive language: replace master/slave names for ptys

[NFC] This patch replaces master and slave with primary and secondary
respectively when referring to pseudoterminals/file descriptors.

Reviewed By: clayborg, teemperor

Differential Revision: https://reviews.llvm.org/D113687
This commit is contained in:
Quinn Pham 2021-11-10 08:50:14 -06:00
parent 79fbba9b79
commit 52a3ed5b93
10 changed files with 31 additions and 31 deletions

View File

@ -399,8 +399,8 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info,
case FileAction::eFileActionOpen: {
FileSpec file_spec = file_action->GetFileSpec();
if (file_spec) {
const int master_fd = launch_info.GetPTY().GetPrimaryFileDescriptor();
if (master_fd != PseudoTerminal::invalid_fd) {
const int primary_fd = launch_info.GetPTY().GetPrimaryFileDescriptor();
if (primary_fd != PseudoTerminal::invalid_fd) {
// Check in case our file action open wants to open the secondary
FileSpec secondary_spec(launch_info.GetPTY().GetSecondaryName());
if (file_spec == secondary_spec) {

View File

@ -621,7 +621,7 @@ NativeProcessWindows::Factory::Attach(
lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
MainLoop &mainloop) const {
Error E = Error::success();
// Set pty master fd invalid since it is not available.
// Set pty primary fd invalid since it is not available.
auto process_up = std::unique_ptr<NativeProcessWindows>(
new NativeProcessWindows(pid, -1, native_delegate, E));
if (E)

View File

@ -286,7 +286,7 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() {
if (should_forward_stdio) {
// nullptr means it's not redirected to file or pty (in case of LLGS local)
// at least one of stdio will be transferred pty<->gdb-remote we need to
// give the pty master handle to this object to read and/or write
// give the pty primary handle to this object to read and/or write
LLDB_LOG(log,
"pid = {0}: setting up stdout/stderr redirection via $O "
"gdb-remote commands",

View File

@ -1110,7 +1110,7 @@ lldb::ProcessSP Platform::DebugProcess(ProcessLaunchInfo &launch_info,
// If we didn't have any file actions, the pseudo terminal might have
// been used where the secondary side was given as the file to open for
// stdin/out/err after we have already opened the master so we can
// stdin/out/err after we have already opened the primary so we can
// read/write stdin/out/err.
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {

View File

@ -4465,7 +4465,7 @@ public:
protected:
Process *m_process;
NativeFile m_read_file; // Read from this file (usually actual STDIN for LLDB
NativeFile m_write_file; // Write to this file (usually the master pty for
NativeFile m_write_file; // Write to this file (usually the primary pty for
// getting io to debuggee)
Pipe m_pipe;
std::atomic<bool> m_is_running{false};

View File

@ -11,7 +11,7 @@ class TestPty(GDBRemoteTestBase):
def get_term_attrs(self):
import termios
return termios.tcgetattr(self.server._socket._slave)
return termios.tcgetattr(self.server._socket._secondary)
def setUp(self):
super().setUp()

View File

@ -420,27 +420,27 @@ class PtyServerSocket(ServerSocket):
def __init__(self):
import pty
import tty
master, slave = pty.openpty()
tty.setraw(master)
self._master = io.FileIO(master, 'r+b')
self._slave = io.FileIO(slave, 'r+b')
primary, secondary = pty.openpty()
tty.setraw(primary)
self._primary = io.FileIO(primary, 'r+b')
self._secondary = io.FileIO(secondary, 'r+b')
def get_connect_address(self):
libc = ctypes.CDLL(None)
libc.ptsname.argtypes = (ctypes.c_int,)
libc.ptsname.restype = ctypes.c_char_p
return libc.ptsname(self._master.fileno()).decode()
return libc.ptsname(self._primary.fileno()).decode()
def get_connect_url(self):
return "serial://" + self.get_connect_address()
def close_server(self):
self._slave.close()
self._master.close()
self._secondary.close()
self._primary.close()
def recv(self):
try:
return self._master.read(4096)
return self._primary.read(4096)
except OSError as e:
# closing the pty results in EIO on Linux, convert it to EOF
if e.errno == errno.EIO:
@ -448,7 +448,7 @@ class PtyServerSocket(ServerSocket):
raise
def sendall(self, data):
return self._master.write(data)
return self._primary.write(data)
class MockGDBServer:

View File

@ -15,10 +15,10 @@ class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
super().setUp()
import pty
import tty
master, slave = pty.openpty()
tty.setraw(master)
self._master = io.FileIO(master, 'r+b')
self._slave = io.FileIO(slave, 'r+b')
primary, secondary = pty.openpty()
tty.setraw(primary)
self._primary = io.FileIO(primary, 'r+b')
self._secondary = io.FileIO(secondary, 'r+b')
def get_debug_monitor_command_line_args(self, attach_pid=None):
commandline_args = self.debug_monitor_extra_args
@ -28,7 +28,7 @@ class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
libc = ctypes.CDLL(None)
libc.ptsname.argtypes = (ctypes.c_int,)
libc.ptsname.restype = ctypes.c_char_p
pty_path = libc.ptsname(self._master.fileno()).decode()
pty_path = libc.ptsname(self._primary.fileno()).decode()
commandline_args += ["serial://%s" % (pty_path,)]
return commandline_args
@ -48,7 +48,7 @@ class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
def recv(self, count):
return self.fd.read(count)
self.sock = FakeSocket(self._master)
self.sock = FakeSocket(self._primary)
self._server = Server(self.sock, server)
return server

View File

@ -229,7 +229,7 @@ class PtyProcess(object):
pid, fd = _fork_pty.fork_pty()
# Some platforms must call setwinsize() and setecho() from the
# child process, and others from the master process. We do both,
# child process, and others from the primary process. We do both,
# allowing IOError for either.
if pid == CHILD:

View File

@ -87,24 +87,24 @@ private:
std::unique_ptr<lldb_private::Editline> _editline_sp;
PseudoTerminal _pty;
int _pty_master_fd;
int _pty_primary_fd;
int _pty_secondary_fd;
std::unique_ptr<FilePointer> _el_secondary_file;
};
EditlineAdapter::EditlineAdapter()
: _editline_sp(), _pty(), _pty_master_fd(-1), _pty_secondary_fd(-1),
: _editline_sp(), _pty(), _pty_primary_fd(-1), _pty_secondary_fd(-1),
_el_secondary_file() {
lldb_private::Status error;
// Open the first master pty available.
// Open the first primary pty available.
EXPECT_THAT_ERROR(_pty.OpenFirstAvailablePrimary(O_RDWR), llvm::Succeeded());
// Grab the master fd. This is a file descriptor we will:
// Grab the primary fd. This is a file descriptor we will:
// (1) write to when we want to send input to editline.
// (2) read from when we want to see what editline sends back.
_pty_master_fd = _pty.GetPrimaryFileDescriptor();
_pty_primary_fd = _pty.GetPrimaryFileDescriptor();
// Open the corresponding secondary pty.
EXPECT_THAT_ERROR(_pty.OpenSecondary(O_RDWR), llvm::Succeeded());
@ -140,13 +140,13 @@ bool EditlineAdapter::SendLine(const std::string &line) {
// Write the line out to the pipe connected to editline's input.
ssize_t input_bytes_written =
::write(_pty_master_fd, line.c_str(),
::write(_pty_primary_fd, line.c_str(),
line.length() * sizeof(std::string::value_type));
const char *eoln = "\n";
const size_t eoln_length = strlen(eoln);
input_bytes_written =
::write(_pty_master_fd, eoln, eoln_length * sizeof(char));
::write(_pty_primary_fd, eoln, eoln_length * sizeof(char));
EXPECT_NE(-1, input_bytes_written) << strerror(errno);
EXPECT_EQ(eoln_length * sizeof(char), size_t(input_bytes_written));
@ -205,7 +205,7 @@ bool EditlineAdapter::IsInputComplete(lldb_private::Editline *editline,
}
void EditlineAdapter::ConsumeAllOutput() {
FilePointer output_file(fdopen(_pty_master_fd, "r"));
FilePointer output_file(fdopen(_pty_primary_fd, "r"));
int ch;
while ((ch = fgetc(output_file)) != EOF) {