Author: Michał Górny Date: 2021-09-29T13:45:41+02:00 New Revision: 52b04efa0197d5b1f65f4824a6528ea634bdf3db
URL: https://github.com/llvm/llvm-project/commit/52b04efa0197d5b1f65f4824a6528ea634bdf3db DIFF: https://github.com/llvm/llvm-project/commit/52b04efa0197d5b1f65f4824a6528ea634bdf3db.diff LOG: [lldb] [Host] Remove TerminalStateSwitcher Remove TerminalStateSwitcher class. It is not used anywhere and its API is really weird. This is the first step towards cleaning up Terminal.h. Differential Revision: https://reviews.llvm.org/D110693 Added: Modified: lldb/include/lldb/Host/Terminal.h lldb/source/Host/common/Terminal.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h index ca91d6b59720a..b22b96776c335 100644 --- a/lldb/include/lldb/Host/Terminal.h +++ b/lldb/include/lldb/Host/Terminal.h @@ -124,59 +124,6 @@ class TerminalState { lldb::pid_t m_process_group = -1; ///< Cached process group information. }; -/// \class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h" -/// A TTY state switching class. -/// -/// This class can be used to remember 2 TTY states for a given file -/// descriptor and switch between the two states. -class TerminalStateSwitcher { -public: - /// Constructor - TerminalStateSwitcher(); - - /// Destructor - ~TerminalStateSwitcher(); - - /// Get the number of possible states to save. - /// - /// \return - /// The number of states that this TTY switcher object contains. - uint32_t GetNumberOfStates() const; - - /// Restore the TTY state for state at index \a idx. - /// - /// \return - /// Returns \b true if the TTY state was successfully restored, - /// \b false otherwise. - bool Restore(uint32_t idx) const; - - /// Save the TTY state information for the state at index \a idx. The TTY - /// state is saved for the file descriptor \a fd and the process group - /// information will also be saved if requested by \a save_process_group. - /// - /// \param[in] idx - /// The index into the state array where the state should be - /// saved. - /// - /// \param[in] fd - /// The file descriptor for which to save the settings. - /// - /// \param[in] save_process_group - /// If \b true, save the process group information for the TTY. - /// - /// \return - /// Returns \b true if the save was successful, \b false - /// otherwise. - bool Save(uint32_t idx, int fd, bool save_process_group); - -protected: - // Member variables - mutable uint32_t m_currentState = - UINT32_MAX; ///< The currently active TTY state index. - TerminalState - m_ttystates[2]; ///< The array of TTY states that holds saved TTY info. -}; - } // namespace lldb_private #endif // #if defined(__cplusplus) diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index 2301abe9afb1d..147bbdcde137d 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -188,50 +188,3 @@ bool TerminalState::TTYStateIsValid() const { bool TerminalState::ProcessGroupIsValid() const { return static_cast<int32_t>(m_process_group) != -1; } - -// Constructor -TerminalStateSwitcher::TerminalStateSwitcher() = default; - -// Destructor -TerminalStateSwitcher::~TerminalStateSwitcher() = default; - -// Returns the number of states that this switcher contains -uint32_t TerminalStateSwitcher::GetNumberOfStates() const { - return llvm::array_lengthof(m_ttystates); -} - -// Restore the state at index "idx". -// -// Returns true if the restore was successful, false otherwise. -bool TerminalStateSwitcher::Restore(uint32_t idx) const { - const uint32_t num_states = GetNumberOfStates(); - if (idx >= num_states) - return false; - - // See if we already are in this state? - if (m_currentState < num_states && (idx == m_currentState) && - m_ttystates[idx].IsValid()) - return true; - - // Set the state to match the index passed in and only update the current - // state if there are no errors. - if (m_ttystates[idx].Restore()) { - m_currentState = idx; - return true; - } - - // We failed to set the state. The tty state was invalid or not initialized. - return false; -} - -// Save the state at index "idx" for file descriptor "fd" and save the process -// group if requested. -// -// Returns true if the restore was successful, false otherwise. -bool TerminalStateSwitcher::Save(uint32_t idx, int fd, - bool save_process_group) { - const uint32_t num_states = GetNumberOfStates(); - if (idx < num_states) - return m_ttystates[idx].Save(fd, save_process_group); - return false; -} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits