|
LLDB mainline
|
#include <PseudoConsole.h>
Public Member Functions | |
| PseudoConsole ()=default | |
| ~PseudoConsole () | |
| PseudoConsole (const PseudoConsole &)=delete | |
| PseudoConsole (PseudoConsole &&)=delete | |
| PseudoConsole & | operator= (const PseudoConsole &)=delete |
| PseudoConsole & | operator= (PseudoConsole &&)=delete |
| llvm::Error | OpenPseudoConsole () |
| Creates and opens a new ConPTY instance with a default console size of 80x25. | |
| void | Close () |
| Closes the ConPTY and invalidates its handle, without closing the STDIN and STDOUT pipes. | |
| void | ClosePipes () |
| Closes the STDIN and STDOUT pipe handles and invalidates them. | |
| 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. | |
| llvm::Error | DrainInitSequences () |
| Drains initialization sequences from the ConPTY output pipe. | |
| 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 = ((HANDLE)(long long)-1) |
| HANDLE | m_conpty_output = ((HANDLE)(long long)-1) |
| HANDLE | m_conpty_input = ((HANDLE)(long long)-1) |
| std::mutex | m_mutex {} |
| std::condition_variable | m_cv {} |
| std::atomic< bool > | m_stopping = false |
Definition at line 24 of file PseudoConsole.h.
|
default |
Referenced by operator=(), operator=(), PseudoConsole(), and PseudoConsole().
| PseudoConsole::~PseudoConsole | ( | ) |
Definition at line 68 of file PseudoConsole.cpp.
References Close(), and ClosePipes().
|
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 145 of file PseudoConsole.cpp.
References kernel32, m_conpty_handle, m_cv, m_mutex, and SetStopping().
Referenced by ~PseudoConsole().
| void PseudoConsole::ClosePipes | ( | ) |
Closes the STDIN and STDOUT pipe handles and invalidates them.
Definition at line 155 of file PseudoConsole.cpp.
References m_conpty_input, and m_conpty_output.
Referenced by ~PseudoConsole().
| llvm::Error PseudoConsole::DrainInitSequences | ( | ) |
Drains initialization sequences from the ConPTY output pipe.
When a process first attaches to a ConPTY, Windows emits VT100/ANSI escape sequences (ESC[2J for clear screen, ESC[H for cursor home and more) as part of the PseudoConsole initialization. To prevent these sequences from appearing in the debugger output (and flushing lldb's shell for instance) we launch a short-lived dummy process that triggers the initialization, then drain all output before launching the actual debuggee.
Definition at line 165 of file PseudoConsole.cpp.
References lldb_private::ProcThreadAttributeList::Create(), error(), m_conpty_handle, m_conpty_output, and lldb_private::ProcThreadAttributeList::SetupPseudoConsole().
Referenced by OpenPseudoConsole().
|
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 99 of file PseudoConsole.h.
References m_cv.
|
inline |
Returns a reference to the mutex used to synchronize access to the ConPTY state.
Definition at line 95 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 63 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 81 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 72 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 139 of file PseudoConsole.cpp.
References m_conpty_handle, m_conpty_input, and m_conpty_output.
|
inline |
Returns whether the ConPTY is in the process of shutting down.
Definition at line 107 of file PseudoConsole.h.
References m_stopping.
| llvm::Error PseudoConsole::OpenPseudoConsole | ( | ) |
Creates and opens a new ConPTY instance with a default console size of 80x25.
Also sets up the associated STDIN/STDOUT pipes and drains any initialization sequences emitted by Windows.
Definition at line 73 of file PseudoConsole.cpp.
References DrainInitSequences(), error(), lldb_private::GetLog(), lldb_private::Host, kernel32, LLDB_LOG_ERROR, m_conpty_handle, m_conpty_input, and m_conpty_output.
|
delete |
References PseudoConsole().
|
delete |
References PseudoConsole().
|
inline |
Sets the stopping flag to value, signalling to threads waiting on the ConPTY that they should stop.
Definition at line 111 of file PseudoConsole.h.
References m_stopping.
Referenced by Close().
Definition at line 114 of file PseudoConsole.h.
Referenced by Close(), DrainInitSequences(), GetPseudoTerminalHandle(), IsConnected(), and OpenPseudoConsole().
Definition at line 116 of file PseudoConsole.h.
Referenced by ClosePipes(), GetSTDINHandle(), IsConnected(), and OpenPseudoConsole().
Definition at line 115 of file PseudoConsole.h.
Referenced by ClosePipes(), DrainInitSequences(), GetSTDOUTHandle(), IsConnected(), and OpenPseudoConsole().
|
protected |
Definition at line 118 of file PseudoConsole.h.
|
protected |
Definition at line 117 of file PseudoConsole.h.
Referenced by Close(), and GetMutex().
|
protected |
Definition at line 119 of file PseudoConsole.h.
Referenced by IsStopping(), and SetStopping().