|
LLDB mainline
|
#include <PseudoConsole.h>
Public Types | |
| enum class | Mode { ConPTY , Pipe , None } |
Public Member Functions | |
| PseudoConsole ()=default | |
| ~PseudoConsole () | |
| PseudoConsole (const PseudoConsole &)=delete | |
| PseudoConsole (PseudoConsole &&)=delete | |
| PseudoConsole & | operator= (const PseudoConsole &)=delete |
| PseudoConsole & | operator= (PseudoConsole &&)=delete |
| llvm::Error | CreateOverlappedPipePair (HANDLE &out_read, HANDLE &out_write, bool inheritable) |
| Creates a named pipe pair for overlapped I/O. | |
| llvm::Error | OpenPseudoConsole (uint16_t req_cols=0, uint16_t req_rows=0) |
| Creates and opens a new ConPTY instance with a default console size of 80x25. | |
| llvm::Error | OpenAnonymousPipes () |
| Creates a pair of anonymous pipes to use for stdio instead of a ConPTY. | |
| void | Close () |
| Closes the ConPTY and invalidates its handle, without closing the STDIN and STDOUT pipes. | |
| void | ClosePseudoConsolePipes () |
| Closes the STDIN and STDOUT pipe handles and invalidates them. | |
| void | CloseAnonymousPipes () |
| Closes the child-side pipe handles (stdin read end and stdout/stderr write end) that were passed to CreateProcessW. | |
| void | Reset () |
| Closes any open ConPTY/pipe handles and resets internal state to a freshly-constructed PseudoConsole. | |
| bool | IsConnected () const |
| Returns whether the ConPTY and its pipes are currently open and valid. | |
| HPCON | GetPseudoTerminalHandle () |
| The ConPTY HPCON handle accessor. | |
| HANDLE | GetSTDOUTHandle () const |
| The STDOUT read HANDLE accessor. | |
| HANDLE | GetSTDINHandle () const |
| The STDIN write HANDLE accessor. | |
| HANDLE | GetChildStdinHandle () const |
| The child-side stdin read HANDLE (pipe mode only). | |
| HANDLE | GetChildStdoutHandle () const |
| The child-side stdout/stderr write HANDLE (pipe mode only). | |
| Mode | GetMode () const |
| std::mutex & | GetMutex () |
| Returns a reference to the mutex used to synchronize access to the ConPTY state. | |
| std::condition_variable & | GetCV () |
| Returns a reference to the condition variable used to signal state changes to threads waiting on the ConPTY (e.g. | |
| bool | IsStopping () const |
| Returns whether the ConPTY is in the process of shutting down. | |
| void | SetStopping (bool value) |
Sets the stopping flag to value, signalling to threads waiting on the ConPTY that they should stop. | |
Protected Attributes | |
| HANDLE | m_conpty_handle = reinterpret_cast<HANDLE>(static_cast<intptr_t>(-1)) |
| HANDLE | m_conpty_output = reinterpret_cast<HANDLE>(static_cast<intptr_t>(-1)) |
| HANDLE | m_conpty_input = reinterpret_cast<HANDLE>(static_cast<intptr_t>(-1)) |
| HANDLE | m_pipe_child_stdin |
| HANDLE | m_pipe_child_stdout |
| Mode | m_mode = Mode::None |
| std::mutex | m_mutex {} |
| std::condition_variable | m_cv {} |
| std::atomic< bool > | m_stopping = false |
Definition at line 24 of file PseudoConsole.h.
|
strong |
| Enumerator | |
|---|---|
| ConPTY | |
| Pipe | |
| None | |
Definition at line 27 of file PseudoConsole.h.
|
default |
Referenced by operator=(), operator=(), PseudoConsole(), and PseudoConsole().
| PseudoConsole::~PseudoConsole | ( | ) |
Definition at line 94 of file PseudoConsole.cpp.
References Reset().
|
delete |
References PseudoConsole().
|
delete |
References PseudoConsole().
| void PseudoConsole::Close | ( | ) |
Closes the ConPTY and invalidates its handle, without closing the STDIN and STDOUT pipes.
Closing the ConPTY signals EOF to any process currently attached to it.
Definition at line 186 of file PseudoConsole.cpp.
References kernel32, m_conpty_handle, m_cv, m_mutex, and SetStopping().
Referenced by Reset().
| void PseudoConsole::CloseAnonymousPipes | ( | ) |
Closes the child-side pipe handles (stdin read end and stdout/stderr write end) that were passed to CreateProcessW.
Must be called after a successful CreateProcessW to avoid keeping the pipes alive indefinitely.
Definition at line 206 of file PseudoConsole.cpp.
References m_pipe_child_stdin, and m_pipe_child_stdout.
Referenced by Reset().
| void PseudoConsole::ClosePseudoConsolePipes | ( | ) |
Closes the STDIN and STDOUT pipe handles and invalidates them.
Definition at line 196 of file PseudoConsole.cpp.
References m_conpty_input, and m_conpty_output.
Referenced by Reset().
| llvm::Error PseudoConsole::CreateOverlappedPipePair | ( | HANDLE & | out_read, |
| HANDLE & | out_write, | ||
| bool | inheritable ) |
Creates a named pipe pair for overlapped I/O.
On failure any handles that were successfully opened are closed and an error is returned.
Definition at line 68 of file PseudoConsole.cpp.
Referenced by OpenAnonymousPipes(), and OpenPseudoConsole().
|
inline |
The child-side stdin read HANDLE (pipe mode only).
Definition at line 109 of file PseudoConsole.h.
References m_pipe_child_stdin.
Referenced by lldb_private::ProcessLauncherWindows::LaunchProcess().
|
inline |
The child-side stdout/stderr write HANDLE (pipe mode only).
Definition at line 112 of file PseudoConsole.h.
References m_pipe_child_stdout.
Referenced by lldb_private::ProcessLauncherWindows::LaunchProcess().
|
inline |
Returns a reference to the condition variable used to signal state changes to threads waiting on the ConPTY (e.g.
waiting for output or shutdown).
Definition at line 122 of file PseudoConsole.h.
References m_cv.
|
inline |
Definition at line 114 of file PseudoConsole.h.
References m_mode.
|
inline |
Returns a reference to the mutex used to synchronize access to the ConPTY state.
Definition at line 118 of file PseudoConsole.h.
References m_mutex.
|
inline |
The ConPTY HPCON handle accessor.
This object retains ownership of the HPCON when this accessor is used.
Definition at line 88 of file PseudoConsole.h.
References m_conpty_handle.
|
inline |
The STDIN write HANDLE accessor.
This object retains ownership of the HANDLE when this accessor is used.
Definition at line 106 of file PseudoConsole.h.
References m_conpty_input.
|
inline |
The STDOUT read HANDLE accessor.
This object retains ownership of the HANDLE when this accessor is used.
Definition at line 97 of file PseudoConsole.h.
References m_conpty_output.
| bool PseudoConsole::IsConnected | ( | ) | const |
Returns whether the ConPTY and its pipes are currently open and valid.
Definition at line 177 of file PseudoConsole.cpp.
References m_conpty_handle, m_conpty_input, m_conpty_output, m_mode, and Pipe.
|
inline |
Returns whether the ConPTY is in the process of shutting down.
Definition at line 130 of file PseudoConsole.h.
References m_stopping.
| llvm::Error PseudoConsole::OpenAnonymousPipes | ( | ) |
Creates a pair of anonymous pipes to use for stdio instead of a ConPTY.
Definition at line 223 of file PseudoConsole.cpp.
References CreateOverlappedPipePair(), m_conpty_input, m_conpty_output, m_mode, m_pipe_child_stdin, m_pipe_child_stdout, Pipe, and Reset().
| llvm::Error PseudoConsole::OpenPseudoConsole | ( | uint16_t | req_cols = 0, |
| uint16_t | req_rows = 0 ) |
Creates and opens a new ConPTY instance with a default console size of 80x25.
Also sets up the associated STDIN/STDOUT pipes and responds to the cursor-position query that ConPTY emits at startup.
| req_cols,req_rows | Optional terminal dimensions. |
Definition at line 96 of file PseudoConsole.cpp.
References ConPTY, CreateOverlappedPipePair(), kernel32, m_conpty_handle, m_conpty_input, m_conpty_output, m_mode, PSEUDOCONSOLE_INHERIT_CURSOR, and Reset().
|
delete |
References PseudoConsole().
|
delete |
References PseudoConsole().
| void PseudoConsole::Reset | ( | ) |
Closes any open ConPTY/pipe handles and resets internal state to a freshly-constructed PseudoConsole.
Definition at line 216 of file PseudoConsole.cpp.
References Close(), CloseAnonymousPipes(), ClosePseudoConsolePipes(), m_mode, and None.
Referenced by OpenAnonymousPipes(), OpenPseudoConsole(), and ~PseudoConsole().
|
inline |
Sets the stopping flag to value, signalling to threads waiting on the ConPTY that they should stop.
Definition at line 134 of file PseudoConsole.h.
References m_stopping.
Referenced by Close().
|
protected |
Definition at line 137 of file PseudoConsole.h.
Referenced by Close(), GetPseudoTerminalHandle(), IsConnected(), and OpenPseudoConsole().
|
protected |
Definition at line 139 of file PseudoConsole.h.
Referenced by ClosePseudoConsolePipes(), GetSTDINHandle(), IsConnected(), OpenAnonymousPipes(), and OpenPseudoConsole().
|
protected |
Definition at line 138 of file PseudoConsole.h.
Referenced by ClosePseudoConsolePipes(), GetSTDOUTHandle(), IsConnected(), OpenAnonymousPipes(), and OpenPseudoConsole().
|
protected |
Definition at line 147 of file PseudoConsole.h.
|
protected |
Definition at line 145 of file PseudoConsole.h.
Referenced by GetMode(), IsConnected(), OpenAnonymousPipes(), OpenPseudoConsole(), and Reset().
|
protected |
Definition at line 146 of file PseudoConsole.h.
Referenced by Close(), and GetMutex().
|
protected |
Definition at line 141 of file PseudoConsole.h.
Referenced by CloseAnonymousPipes(), GetChildStdinHandle(), and OpenAnonymousPipes().
|
protected |
Definition at line 143 of file PseudoConsole.h.
Referenced by CloseAnonymousPipes(), GetChildStdoutHandle(), and OpenAnonymousPipes().
|
protected |
Definition at line 148 of file PseudoConsole.h.
Referenced by IsStopping(), and SetStopping().