33 auto *buf =
static_cast<char *
>(data);
36 const char *end = buf + len;
44 size_t remaining = end - in;
48 if (remaining >= 4 && memcmp(in,
"\x1b[6n", 4) == 0) {
55 if (remaining >= 3 && memcmp(in,
"\x1b[m", 3) == 0) {
61 if (remaining >= 6 && memcmp(in,
"\x1b[?25h", 6) == 0) {
68 if (remaining >= 8 && memcmp(in,
"\x1b[?9001", 7) == 0 &&
69 (in[7] ==
'h' || in[7] ==
'l')) {
75 if (remaining >= 8 && memcmp(in,
"\x1b[?1004", 7) == 0 &&
76 (in[7] ==
'h' || in[7] ==
'l')) {
82 if (remaining >= 4 && in[1] ==
']' && in[2] ==
'0' && in[3] ==
';') {
84 static_cast<const char *
>(memchr(in + 4,
'\x07', end - in - 4));
96 len =
static_cast<size_t>(out - buf);
106 if (
m_pty->IsConnected())
121 std::unique_lock<std::mutex> guard(
m_pty->GetMutex());
122 if (
m_pty->IsStopping())
123 m_pty->GetCV().wait(guard, [
this] {
return !
m_pty->IsStopping(); });
124 if (!
m_pty->IsConnected()) {
130 char *out =
static_cast<char *
>(dst);
134 if (bytes_read > 0) {
145 llvm_unreachable(
"not implemented");
static void StripConPTYSequences(void *data, size_t &len, bool strip_init)
Remove ConPTY management sequences from a buffer in-place.
lldb::ConnectionStatus Disconnect(Status *error_ptr) override
Disconnect the communications connection if one is currently connected.
size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr) override
The actual write function that attempts to write to the communications protocol.
bool m_conpty_sequences_stripped
ConnectionConPTY(std::shared_ptr< PseudoConsole > pty)
size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) override
Read from the ConPTY's pipe.
std::shared_ptr< PseudoConsole > m_pty
lldb::ConnectionStatus Connect(llvm::StringRef s, Status *error_ptr) override
Connect using the connect string url.
size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) override
The read function that attempts to read from the connection.
A class that represents a running process on the host machine.
ConnectionStatus
Connection Status Types.
@ eConnectionStatusEndOfFile
End-of-file encountered.
@ eConnectionStatusSuccess
Success.
@ eConnectionStatusNoConnection
No connection.