[Lldb-commits] [lldb] 52a3ed5 - [lldb][NFC] Inclusive language: replace master/slave names for ptys

Quinn Pham via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 12 08:54:22 PST 2021


Author: Quinn Pham
Date: 2021-11-12T10:54:18-06:00
New Revision: 52a3ed5b93ca9aba042d87e2bb697bf0dda2e43c

URL: https://github.com/llvm/llvm-project/commit/52a3ed5b93ca9aba042d87e2bb697bf0dda2e43c
DIFF: https://github.com/llvm/llvm-project/commit/52a3ed5b93ca9aba042d87e2bb697bf0dda2e43c.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
    lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    lldb/source/Target/Platform.cpp
    lldb/source/Target/Process.cpp
    lldb/test/API/functionalities/gdb_remote_client/TestPty.py
    lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
    lldb/test/API/tools/lldb-server/TestPtyServer.py
    lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py
    lldb/unittests/Editline/EditlineTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
index beb2cbd1507b4..f8c3ed65372f8 100644
--- a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
+++ b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
@@ -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) {

diff  --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 5ae878024be17..3d2225ff0cb24 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -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)

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index da645319fda63..5360db3d84623 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -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",

diff  --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index be91a90158e8c..0ae56e6ff1615 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -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) {

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 388d47be5a027..519db0482e4ba 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4465,7 +4465,7 @@ class IOHandlerProcessSTDIO : public IOHandler {
 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};

diff  --git a/lldb/test/API/functionalities/gdb_remote_client/TestPty.py b/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
index c7ddebd892b95..50eae1e219559 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
@@ -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()

diff  --git a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
index a1ab7ab052e28..cc95564675b83 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -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 @@ def recv(self):
             raise
 
     def sendall(self, data):
-        return self._master.write(data)
+        return self._primary.write(data)
 
 
 class MockGDBServer:

diff  --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index 5a12f565d9e49..44aa2f1e15aeb 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -15,10 +15,10 @@ def setUp(self):
         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 @@ def get_debug_monitor_command_line_args(self, attach_pid=None):
         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 @@ def sendall(self, frame):
             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
 

diff  --git a/lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py b/lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py
index 29b4e43b569f3..a58741e8335e9 100644
--- a/lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py
+++ b/lldb/third_party/Python/module/ptyprocess-0.6.0/ptyprocess/ptyprocess.py
@@ -229,7 +229,7 @@ def spawn(
             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:

diff  --git a/lldb/unittests/Editline/EditlineTest.cpp b/lldb/unittests/Editline/EditlineTest.cpp
index 5318481145043..97455a2275f19 100644
--- a/lldb/unittests/Editline/EditlineTest.cpp
+++ b/lldb/unittests/Editline/EditlineTest.cpp
@@ -87,24 +87,24 @@ class EditlineAdapter {
   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) {


        


More information about the lldb-commits mailing list