Skip to content

Commit 52a3ed5

Browse files
Quinn PhamQuinn Pham
Quinn Pham
authored and
Quinn Pham
committed
[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
1 parent 79fbba9 commit 52a3ed5

File tree

10 files changed

+31
-31
lines changed

10 files changed

+31
-31
lines changed

lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info,
399399
case FileAction::eFileActionOpen: {
400400
FileSpec file_spec = file_action->GetFileSpec();
401401
if (file_spec) {
402-
const int master_fd = launch_info.GetPTY().GetPrimaryFileDescriptor();
403-
if (master_fd != PseudoTerminal::invalid_fd) {
402+
const int primary_fd = launch_info.GetPTY().GetPrimaryFileDescriptor();
403+
if (primary_fd != PseudoTerminal::invalid_fd) {
404404
// Check in case our file action open wants to open the secondary
405405
FileSpec secondary_spec(launch_info.GetPTY().GetSecondaryName());
406406
if (file_spec == secondary_spec) {

lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp

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

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

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

lldb/source/Target/Platform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ lldb::ProcessSP Platform::DebugProcess(ProcessLaunchInfo &launch_info,
11101110

11111111
// If we didn't have any file actions, the pseudo terminal might have
11121112
// been used where the secondary side was given as the file to open for
1113-
// stdin/out/err after we have already opened the master so we can
1113+
// stdin/out/err after we have already opened the primary so we can
11141114
// read/write stdin/out/err.
11151115
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
11161116
if (pty_fd != PseudoTerminal::invalid_fd) {

lldb/source/Target/Process.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4465,7 +4465,7 @@ class IOHandlerProcessSTDIO : public IOHandler {
44654465
protected:
44664466
Process *m_process;
44674467
NativeFile m_read_file; // Read from this file (usually actual STDIN for LLDB
4468-
NativeFile m_write_file; // Write to this file (usually the master pty for
4468+
NativeFile m_write_file; // Write to this file (usually the primary pty for
44694469
// getting io to debuggee)
44704470
Pipe m_pipe;
44714471
std::atomic<bool> m_is_running{false};

lldb/test/API/functionalities/gdb_remote_client/TestPty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TestPty(GDBRemoteTestBase):
1111

1212
def get_term_attrs(self):
1313
import termios
14-
return termios.tcgetattr(self.server._socket._slave)
14+
return termios.tcgetattr(self.server._socket._secondary)
1515

1616
def setUp(self):
1717
super().setUp()

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -420,35 +420,35 @@ class PtyServerSocket(ServerSocket):
420420
def __init__(self):
421421
import pty
422422
import tty
423-
master, slave = pty.openpty()
424-
tty.setraw(master)
425-
self._master = io.FileIO(master, 'r+b')
426-
self._slave = io.FileIO(slave, 'r+b')
423+
primary, secondary = pty.openpty()
424+
tty.setraw(primary)
425+
self._primary = io.FileIO(primary, 'r+b')
426+
self._secondary = io.FileIO(secondary, 'r+b')
427427

428428
def get_connect_address(self):
429429
libc = ctypes.CDLL(None)
430430
libc.ptsname.argtypes = (ctypes.c_int,)
431431
libc.ptsname.restype = ctypes.c_char_p
432-
return libc.ptsname(self._master.fileno()).decode()
432+
return libc.ptsname(self._primary.fileno()).decode()
433433

434434
def get_connect_url(self):
435435
return "serial://" + self.get_connect_address()
436436

437437
def close_server(self):
438-
self._slave.close()
439-
self._master.close()
438+
self._secondary.close()
439+
self._primary.close()
440440

441441
def recv(self):
442442
try:
443-
return self._master.read(4096)
443+
return self._primary.read(4096)
444444
except OSError as e:
445445
# closing the pty results in EIO on Linux, convert it to EOF
446446
if e.errno == errno.EIO:
447447
return b''
448448
raise
449449

450450
def sendall(self, data):
451-
return self._master.write(data)
451+
return self._primary.write(data)
452452

453453

454454
class MockGDBServer:

lldb/test/API/tools/lldb-server/TestPtyServer.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def setUp(self):
1515
super().setUp()
1616
import pty
1717
import tty
18-
master, slave = pty.openpty()
19-
tty.setraw(master)
20-
self._master = io.FileIO(master, 'r+b')
21-
self._slave = io.FileIO(slave, 'r+b')
18+
primary, secondary = pty.openpty()
19+
tty.setraw(primary)
20+
self._primary = io.FileIO(primary, 'r+b')
21+
self._secondary = io.FileIO(secondary, 'r+b')
2222

2323
def get_debug_monitor_command_line_args(self, attach_pid=None):
2424
commandline_args = self.debug_monitor_extra_args
@@ -28,7 +28,7 @@ def get_debug_monitor_command_line_args(self, attach_pid=None):
2828
libc = ctypes.CDLL(None)
2929
libc.ptsname.argtypes = (ctypes.c_int,)
3030
libc.ptsname.restype = ctypes.c_char_p
31-
pty_path = libc.ptsname(self._master.fileno()).decode()
31+
pty_path = libc.ptsname(self._primary.fileno()).decode()
3232
commandline_args += ["serial://%s" % (pty_path,)]
3333
return commandline_args
3434

@@ -48,7 +48,7 @@ def sendall(self, frame):
4848
def recv(self, count):
4949
return self.fd.read(count)
5050

51-
self.sock = FakeSocket(self._master)
51+
self.sock = FakeSocket(self._primary)
5252
self._server = Server(self.sock, server)
5353
return server
5454

lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def spawn(
229229
pid, fd = _fork_pty.fork_pty()
230230

231231
# Some platforms must call setwinsize() and setecho() from the
232-
# child process, and others from the master process. We do both,
232+
# child process, and others from the primary process. We do both,
233233
# allowing IOError for either.
234234

235235
if pid == CHILD:

lldb/unittests/Editline/EditlineTest.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,24 @@ class EditlineAdapter {
8787
std::unique_ptr<lldb_private::Editline> _editline_sp;
8888

8989
PseudoTerminal _pty;
90-
int _pty_master_fd;
90+
int _pty_primary_fd;
9191
int _pty_secondary_fd;
9292

9393
std::unique_ptr<FilePointer> _el_secondary_file;
9494
};
9595

9696
EditlineAdapter::EditlineAdapter()
97-
: _editline_sp(), _pty(), _pty_master_fd(-1), _pty_secondary_fd(-1),
97+
: _editline_sp(), _pty(), _pty_primary_fd(-1), _pty_secondary_fd(-1),
9898
_el_secondary_file() {
9999
lldb_private::Status error;
100100

101-
// Open the first master pty available.
101+
// Open the first primary pty available.
102102
EXPECT_THAT_ERROR(_pty.OpenFirstAvailablePrimary(O_RDWR), llvm::Succeeded());
103103

104-
// Grab the master fd. This is a file descriptor we will:
104+
// Grab the primary fd. This is a file descriptor we will:
105105
// (1) write to when we want to send input to editline.
106106
// (2) read from when we want to see what editline sends back.
107-
_pty_master_fd = _pty.GetPrimaryFileDescriptor();
107+
_pty_primary_fd = _pty.GetPrimaryFileDescriptor();
108108

109109
// Open the corresponding secondary pty.
110110
EXPECT_THAT_ERROR(_pty.OpenSecondary(O_RDWR), llvm::Succeeded());
@@ -140,13 +140,13 @@ bool EditlineAdapter::SendLine(const std::string &line) {
140140

141141
// Write the line out to the pipe connected to editline's input.
142142
ssize_t input_bytes_written =
143-
::write(_pty_master_fd, line.c_str(),
143+
::write(_pty_primary_fd, line.c_str(),
144144
line.length() * sizeof(std::string::value_type));
145145

146146
const char *eoln = "\n";
147147
const size_t eoln_length = strlen(eoln);
148148
input_bytes_written =
149-
::write(_pty_master_fd, eoln, eoln_length * sizeof(char));
149+
::write(_pty_primary_fd, eoln, eoln_length * sizeof(char));
150150

151151
EXPECT_NE(-1, input_bytes_written) << strerror(errno);
152152
EXPECT_EQ(eoln_length * sizeof(char), size_t(input_bytes_written));
@@ -205,7 +205,7 @@ bool EditlineAdapter::IsInputComplete(lldb_private::Editline *editline,
205205
}
206206

207207
void EditlineAdapter::ConsumeAllOutput() {
208-
FilePointer output_file(fdopen(_pty_master_fd, "r"));
208+
FilePointer output_file(fdopen(_pty_primary_fd, "r"));
209209

210210
int ch;
211211
while ((ch = fgetc(output_file)) != EOF) {

0 commit comments

Comments
 (0)