LLDB mainline
IOHandler.cpp
Go to the documentation of this file.
1//===-- IOHandler.cpp -----------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#if defined(__APPLE__)
12#include <deque>
13#endif
14#include <string>
15
16#include "lldb/Core/Debugger.h"
17#include "lldb/Host/Config.h"
18#include "lldb/Host/File.h"
22#include "lldb/Utility/Status.h"
25#include "lldb/lldb-forward.h"
26
27#if LLDB_ENABLE_LIBEDIT
28#include "lldb/Host/Editline.h"
29#endif
32#include "llvm/ADT/StringRef.h"
33
34#ifdef _WIN32
36#endif
37
38#include <memory>
39#include <mutex>
40#include <optional>
41
42#include <cassert>
43#include <cctype>
44#include <cerrno>
45#include <clocale>
46#include <cstdint>
47#include <cstdio>
48#include <cstring>
49#include <type_traits>
50
51using namespace lldb;
52using namespace lldb_private;
53using llvm::StringRef;
54
56 : IOHandler(debugger, type,
57 FileSP(), // Adopt STDIN from top input reader
58 LockableStreamFileSP(), // Adopt STDOUT from top input reader
59 LockableStreamFileSP(), // Adopt STDERR from top input reader
60 0 // Flags
61
62 ) {}
63
65 const lldb::FileSP &input_sp,
66 const lldb::LockableStreamFileSP &output_sp,
67 const lldb::LockableStreamFileSP &error_sp, uint32_t flags)
68 : m_debugger(debugger), m_input_sp(input_sp), m_output_sp(output_sp),
69 m_error_sp(error_sp), m_popped(false), m_flags(flags), m_type(type),
70 m_user_data(nullptr), m_done(false), m_active(false) {
71 // If any files are not specified, then adopt them from the top input reader.
75}
76
77IOHandler::~IOHandler() = default;
78
80 return (m_input_sp ? m_input_sp->GetDescriptor() : -1);
81}
82
84 return (m_output_sp ? m_output_sp->GetUnlockedFile().GetDescriptor() : -1);
85}
86
88 return (m_error_sp ? m_error_sp->GetUnlockedFile().GetDescriptor() : -1);
89}
90
92
94
96
98 return GetInputFileSP() ? GetInputFileSP()->GetIsInteractive() : false;
99}
100
102 return GetInputFileSP() ? GetInputFileSP()->GetIsRealTerminal() : false;
103}
104
106
107void IOHandler::WaitForPop() { m_popped.WaitForValueEqualTo(true); }
108
109void IOHandler::PrintAsync(const char *s, size_t len, bool is_stdout) {
110 lldb::LockableStreamFileSP stream_sp = is_stdout ? m_output_sp : m_error_sp;
111 LockedStreamFile locked_Stream = stream_sp->Lock();
112 locked_Stream.Write(s, len);
113}
114
115bool IOHandlerStack::PrintAsync(const char *s, size_t len, bool is_stdout) {
116 std::lock_guard<std::recursive_mutex> guard(m_mutex);
117 if (!m_top)
118 return false;
119 m_top->PrintAsync(s, len, is_stdout);
120 return true;
121}
122
123IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
124 bool default_response)
126 debugger, IOHandler::Type::Confirm,
127 nullptr, // nullptr editline_name means no history loaded/saved
128 llvm::StringRef(), // No prompt
129 llvm::StringRef(), // No continuation prompt
130 false, // Multi-line
131 false, // Don't colorize the prompt (i.e. the confirm message.)
132 0, *this),
133 m_default_response(default_response), m_user_response(default_response) {
134 StreamString prompt_stream;
135 prompt_stream.PutCString(prompt);
137 prompt_stream.Printf(": [Y/n] ");
138 else
139 prompt_stream.Printf(": [y/N] ");
140
141 SetPrompt(prompt_stream.GetString());
142}
143
145
147 CompletionRequest &request) {
148 if (request.GetRawCursorPos() != 0)
149 return;
150 request.AddCompletion(m_default_response ? "y" : "n");
151}
152
154 std::string &line) {
155 const llvm::StringRef input = llvm::StringRef(line).rtrim();
156 if (input.empty()) {
157 // User just hit enter, set the response to the default
159 io_handler.SetIsDone(true);
160 return;
161 }
162
163 if (input.size() == 1) {
164 switch (input[0]) {
165 case 'y':
166 case 'Y':
167 m_user_response = true;
168 io_handler.SetIsDone(true);
169 return;
170 case 'n':
171 case 'N':
172 m_user_response = false;
173 io_handler.SetIsDone(true);
174 return;
175 default:
176 break;
177 }
178 }
179
180 if (input.equals_insensitive("yes")) {
181 m_user_response = true;
182 io_handler.SetIsDone(true);
183 } else if (input.equals_insensitive("no")) {
184 m_user_response = false;
185 io_handler.SetIsDone(true);
186 }
187}
188
189std::optional<std::string>
191 llvm::StringRef line) {
192 return io_handler.GetDebugger()
195}
196
198 CompletionRequest &request) {
199 switch (m_completion) {
200 case Completion::None:
201 break;
203 io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(request);
204 break;
207 io_handler.GetDebugger().GetCommandInterpreter(),
208 lldb::eVariablePathCompletion, request, nullptr);
209 break;
210 }
211}
212
214 Debugger &debugger, IOHandler::Type type,
215 const char *editline_name, // Used for saving history files
216 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
217 bool multi_line, bool color, uint32_t line_number_start,
218 IOHandlerDelegate &delegate)
220 debugger, type,
221 FileSP(), // Inherit input from top input reader
222 LockableStreamFileSP(), // Inherit output from top input reader
223 LockableStreamFileSP(), // Inherit error from top input reader
224 0, // Flags
225 editline_name, // Used for saving history files
226 prompt, continuation_prompt, multi_line, color, line_number_start,
227 delegate) {}
228
230 Debugger &debugger, IOHandler::Type type, const lldb::FileSP &input_sp,
231 const lldb::LockableStreamFileSP &output_sp,
232 const lldb::LockableStreamFileSP &error_sp, uint32_t flags,
233 const char *editline_name, // Used for saving history files
234 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
235 bool multi_line, bool color, uint32_t line_number_start,
236 IOHandlerDelegate &delegate)
237 : IOHandler(debugger, type, input_sp, output_sp, error_sp, flags),
238#if LLDB_ENABLE_LIBEDIT
239 m_editline_up(),
240#endif
242 m_current_lines_ptr(nullptr), m_base_line_number(line_number_start),
243 m_curr_line_idx(UINT32_MAX), m_multi_line(multi_line), m_color(color),
244 m_interrupt_exits(true) {
245 SetPrompt(prompt);
246
247#if LLDB_ENABLE_LIBEDIT
248 // To use Editline, we need an input, output, and error stream. Not all valid
249 // files will have a FILE* stream. Don't use Editline if the input is not a
250 // real terminal.
251 const bool use_editline =
252 m_input_sp && m_input_sp->GetIsRealTerminal() && // Input
253 m_output_sp && m_output_sp->GetUnlockedFile().GetStream() && // Output
254 m_error_sp && m_error_sp->GetUnlockedFile().GetStream(); // Error
255 if (use_editline) {
256 m_editline_up = std::make_unique<Editline>(
257 editline_name, m_input_sp ? m_input_sp->GetStream() : nullptr,
259 m_editline_up->SetIsInputCompleteCallback(
260 [this](Editline *editline, StringList &lines) {
261 return this->IsInputCompleteCallback(editline, lines);
262 });
263
264 m_editline_up->SetAutoCompleteCallback([this](CompletionRequest &request) {
265 this->AutoCompleteCallback(request);
266 });
267 m_editline_up->SetRedrawCallback([this]() { this->RedrawCallback(); });
268
269 if (debugger.GetUseAutosuggestion()) {
270 m_editline_up->SetSuggestionCallback([this](llvm::StringRef line) {
271 return this->SuggestionCallback(line);
272 });
273 m_editline_up->SetSuggestionAnsiPrefix(ansi::FormatAnsiTerminalCodes(
274 debugger.GetAutosuggestionAnsiPrefix()));
275 m_editline_up->SetSuggestionAnsiSuffix(ansi::FormatAnsiTerminalCodes(
276 debugger.GetAutosuggestionAnsiSuffix()));
277 }
278 // See if the delegate supports fixing indentation
279 const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters();
280 if (indent_chars) {
281 // The delegate does support indentation, hook it up so when any
282 // indentation character is typed, the delegate gets a chance to fix it
283 FixIndentationCallbackType f = [this](Editline *editline,
284 const StringList &lines,
285 int cursor_position) {
286 return this->FixIndentationCallback(editline, lines, cursor_position);
287 };
288 m_editline_up->SetFixIndentationCallback(std::move(f), indent_chars);
289 }
290 }
291#endif
293 SetPrompt(prompt);
294 SetContinuationPrompt(continuation_prompt);
295}
296
298#if LLDB_ENABLE_LIBEDIT
299 m_editline_up.reset();
300#endif
301}
302
305 m_delegate.IOHandlerActivated(*this, GetIsInteractive());
306}
307
310 m_delegate.IOHandlerDeactivated(*this);
311}
312
314#if LLDB_ENABLE_LIBEDIT
315 if (m_editline_up)
316 m_editline_up->TerminalSizeChanged();
317#endif
318}
319
320// Split out a line from the buffer, if there is a full one to get.
321static std::optional<std::string> SplitLine(std::string &line_buffer) {
322 size_t pos = line_buffer.find('\n');
323 if (pos == std::string::npos)
324 return std::nullopt;
325 std::string line =
326 std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r"));
327 line_buffer = line_buffer.substr(pos + 1);
328 return line;
329}
330
331// If the final line of the file ends without a end-of-line, return
332// it as a line anyway.
333static std::optional<std::string> SplitLineEOF(std::string &line_buffer) {
334 if (llvm::all_of(line_buffer, llvm::isSpace))
335 return std::nullopt;
336 std::string line = std::move(line_buffer);
337 line_buffer.clear();
338 return line;
339}
340
341bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
342#if LLDB_ENABLE_LIBEDIT
343 if (m_editline_up) {
344 return m_editline_up->GetLine(line, interrupted);
345 }
346#endif
347
348 line.clear();
349
350 if (GetIsInteractive()) {
351 const char *prompt = nullptr;
352
353 if (m_multi_line && m_curr_line_idx > 0)
354 prompt = GetContinuationPrompt();
355
356 if (prompt == nullptr)
357 prompt = GetPrompt();
358
359 if (prompt && prompt[0]) {
360 if (m_output_sp) {
361 LockedStreamFile locked_stream = m_output_sp->Lock();
362 locked_stream.Printf("%s", prompt);
363 }
364 }
365 }
366
367 std::optional<std::string> got_line = SplitLine(m_line_buffer);
368
369 if (!got_line && !m_input_sp) {
370 // No more input file, we are done...
371 SetIsDone(true);
372 return false;
373 }
374
375 FILE *in = m_input_sp ? m_input_sp->GetStream() : nullptr;
376 char buffer[256];
377
378 if (!got_line && !in && m_input_sp) {
379 // there is no FILE*, fall back on just reading bytes from the stream.
380 while (!got_line) {
381 size_t bytes_read = sizeof(buffer);
382 Status error = m_input_sp->Read((void *)buffer, bytes_read);
383 if (error.Success() && !bytes_read) {
384 got_line = SplitLineEOF(m_line_buffer);
385 break;
386 }
387 if (error.Fail())
388 break;
389 m_line_buffer += StringRef(buffer, bytes_read);
390 got_line = SplitLine(m_line_buffer);
391 }
392 }
393
394 if (!got_line && in) {
395 while (!got_line) {
396 char *r = fgets(buffer, sizeof(buffer), in);
397#ifdef _WIN32
398 // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
399 // according to the docs on MSDN. However, this has evidently been a
400 // known bug since Windows 8. Therefore, we can't detect if a signal
401 // interrupted in the fgets. So pressing ctrl-c causes the repl to end
402 // and the process to exit. A temporary workaround is just to attempt to
403 // fgets twice until this bug is fixed.
404 if (r == nullptr)
405 r = fgets(buffer, sizeof(buffer), in);
406 // this is the equivalent of EINTR for Windows
407 if (r == nullptr && GetLastError() == ERROR_OPERATION_ABORTED)
408 continue;
409#endif
410 if (r == nullptr) {
411 if (ferror(in) && errno == EINTR)
412 continue;
413 if (feof(in))
414 got_line = SplitLineEOF(m_line_buffer);
415 break;
416 }
417 m_line_buffer += buffer;
418 got_line = SplitLine(m_line_buffer);
419 }
420 }
421
422 if (got_line) {
423 line = *got_line;
424 }
425
426 return (bool)got_line;
427}
428
429#if LLDB_ENABLE_LIBEDIT
430bool IOHandlerEditline::IsInputCompleteCallback(Editline *editline,
431 StringList &lines) {
432 return m_delegate.IOHandlerIsInputComplete(*this, lines);
433}
434
435int IOHandlerEditline::FixIndentationCallback(Editline *editline,
436 const StringList &lines,
437 int cursor_position) {
438 return m_delegate.IOHandlerFixIndentation(*this, lines, cursor_position);
439}
440
441std::optional<std::string>
442IOHandlerEditline::SuggestionCallback(llvm::StringRef line) {
443 return m_delegate.IOHandlerSuggestion(*this, line);
444}
445
446void IOHandlerEditline::AutoCompleteCallback(CompletionRequest &request) {
447 m_delegate.IOHandlerComplete(*this, request);
448}
449
450void IOHandlerEditline::RedrawCallback() {
451 m_debugger.RedrawStatusline(std::nullopt);
452}
453
454#endif
455
457#if LLDB_ENABLE_LIBEDIT
458 if (m_editline_up) {
459 return m_editline_up->GetPrompt();
460 } else {
461#endif
462 if (m_prompt.empty())
463 return nullptr;
464#if LLDB_ENABLE_LIBEDIT
465 }
466#endif
467 return m_prompt.c_str();
468}
469
470bool IOHandlerEditline::SetPrompt(llvm::StringRef prompt) {
471 m_prompt = std::string(prompt);
472
473#if LLDB_ENABLE_LIBEDIT
474 if (m_editline_up) {
475 m_editline_up->SetPrompt(m_prompt.empty() ? nullptr : m_prompt.c_str());
476 m_editline_up->SetPromptAnsiPrefix(
477 ansi::FormatAnsiTerminalCodes(m_debugger.GetPromptAnsiPrefix()));
478 m_editline_up->SetPromptAnsiSuffix(
479 ansi::FormatAnsiTerminalCodes(m_debugger.GetPromptAnsiSuffix()));
480 }
481#endif
482 return true;
483}
484
485bool IOHandlerEditline::SetUseColor(bool use_color) {
486 m_color = use_color;
487
488#if LLDB_ENABLE_LIBEDIT
489 if (m_editline_up) {
490 m_editline_up->UseColor(use_color);
491 m_editline_up->SetSuggestionAnsiPrefix(ansi::FormatAnsiTerminalCodes(
492 m_debugger.GetAutosuggestionAnsiPrefix()));
493 m_editline_up->SetSuggestionAnsiSuffix(ansi::FormatAnsiTerminalCodes(
494 m_debugger.GetAutosuggestionAnsiSuffix()));
495 }
496#endif
497 return true;
498}
499
501 return (m_continuation_prompt.empty() ? nullptr
502 : m_continuation_prompt.c_str());
503}
504
505void IOHandlerEditline::SetContinuationPrompt(llvm::StringRef prompt) {
506 m_continuation_prompt = std::string(prompt);
507
508#if LLDB_ENABLE_LIBEDIT
509 if (m_editline_up)
510 m_editline_up->SetContinuationPrompt(m_continuation_prompt.empty()
511 ? nullptr
512 : m_continuation_prompt.c_str());
513#endif
514}
515
517 m_base_line_number = line;
518}
519
521#if LLDB_ENABLE_LIBEDIT
522 if (m_editline_up)
523 return m_editline_up->GetCurrentLine();
524#endif
525 return m_curr_line_idx;
526}
527
529#if LLDB_ENABLE_LIBEDIT
530 if (m_editline_up)
531 return m_editline_up->GetInputAsStringList();
532#endif
533 // When libedit is not used, the current lines can be gotten from
534 // `m_current_lines_ptr`, which is updated whenever a new line is processed.
535 // This doesn't happen when libedit is used, in which case
536 // `m_current_lines_ptr` is only updated when the full input is terminated.
537
539 return *m_current_lines_ptr;
540 return StringList();
541}
542
543bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
544 m_current_lines_ptr = &lines;
545
546 bool success = false;
547#if LLDB_ENABLE_LIBEDIT
548 if (m_editline_up) {
549 return m_editline_up->GetLines(m_base_line_number, lines, interrupted);
550 } else {
551#endif
552 bool done = false;
554
555 while (!done) {
556 // Show line numbers if we are asked to
557 std::string line;
559 if (m_output_sp) {
560 LockedStreamFile locked_stream = m_output_sp->Lock();
561 locked_stream.Printf("%u%s",
562 m_base_line_number + (uint32_t)lines.GetSize(),
563 GetPrompt() == nullptr ? " " : "");
564 }
565 }
566
567 m_curr_line_idx = lines.GetSize();
568
569 bool interrupted = false;
570 if (GetLine(line, interrupted) && !interrupted) {
571 lines.AppendString(line);
572 done = m_delegate.IOHandlerIsInputComplete(*this, lines);
573 } else {
574 done = true;
575 }
576 }
577 success = lines.GetSize() > 0;
578#if LLDB_ENABLE_LIBEDIT
579 }
580#endif
581 return success;
582}
583
584// Each IOHandler gets to run until it is done. It should read data from the
585// "in" and place output into "out" and "err and return when done.
587 std::string line;
588 while (IsActive()) {
589 bool interrupted = false;
590 if (m_multi_line) {
591 StringList lines;
592 if (GetLines(lines, interrupted)) {
593 if (interrupted) {
595 m_delegate.IOHandlerInputInterrupted(*this, line);
596
597 } else {
598 line = lines.CopyList();
599 m_delegate.IOHandlerInputComplete(*this, line);
600 }
601 } else {
602 m_done = true;
603 }
604 } else {
605 if (GetLine(line, interrupted)) {
606 if (interrupted)
607 m_delegate.IOHandlerInputInterrupted(*this, line);
608 else
609 m_delegate.IOHandlerInputComplete(*this, line);
610 } else {
611 m_done = true;
612 }
613 }
614 }
615}
616
618#if LLDB_ENABLE_LIBEDIT
619 if (m_editline_up)
620 m_editline_up->Cancel();
621#endif
622}
623
625 // Let the delgate handle it first
626 if (m_delegate.IOHandlerInterrupt(*this))
627 return true;
628
629#if LLDB_ENABLE_LIBEDIT
630 if (m_editline_up)
631 return m_editline_up->Interrupt();
632#endif
633 return false;
634}
635
637#if LLDB_ENABLE_LIBEDIT
638 if (m_editline_up)
639 m_editline_up->Interrupt();
640#endif
641}
642
643void IOHandlerEditline::PrintAsync(const char *s, size_t len, bool is_stdout) {
644#if LLDB_ENABLE_LIBEDIT
645 if (m_editline_up) {
646 lldb::LockableStreamFileSP stream_sp = is_stdout ? m_output_sp : m_error_sp;
647 m_editline_up->PrintAsync(stream_sp, s, len);
648 } else
649#endif
650 {
651#ifdef _WIN32
652 const char *prompt = GetPrompt();
653 if (prompt) {
654 // Back up over previous prompt using Windows API
655 CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
656 HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
657 GetConsoleScreenBufferInfo(console_handle, &screen_buffer_info);
658 COORD coord = screen_buffer_info.dwCursorPosition;
659 coord.X -= strlen(prompt);
660 if (coord.X < 0)
661 coord.X = 0;
662 SetConsoleCursorPosition(console_handle, coord);
663 }
664#endif
665 IOHandler::PrintAsync(s, len, is_stdout);
666#ifdef _WIN32
667 if (prompt)
668 IOHandler::PrintAsync(prompt, strlen(prompt), is_stdout);
669#endif
670 }
671}
672
674#if LLDB_ENABLE_LIBEDIT
675 if (m_editline_up)
676 m_editline_up->Refresh();
677#endif
678}
static llvm::raw_ostream & error(Stream &strm)
static std::optional< std::string > SplitLine(std::string &line_buffer)
static std::optional< std::string > SplitLineEOF(std::string &line_buffer)
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
std::optional< std::string > GetAutoSuggestionForCommand(llvm::StringRef line)
Returns the auto-suggestion string that should be added to the given command line.
void HandleCompletion(CompletionRequest &request)
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
A class to manage flag bits.
Definition Debugger.h:80
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition Debugger.cpp:543
CommandInterpreter & GetCommandInterpreter()
Definition Debugger.h:166
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition Debugger.cpp:549
bool GetUseAutosuggestion() const
Definition Debugger.cpp:537
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::LockableStreamFileSP &out, lldb::LockableStreamFileSP &err)
Instances of Editline provide an abstraction over libedit's EditLine facility.
Definition Editline.h:155
IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, bool default_response)
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) override
A delegate class for use with IOHandler subclasses.
Definition IOHandler.h:184
virtual void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request)
virtual const char * IOHandlerGetFixIndentationCharacters()
Definition IOHandler.h:203
virtual bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines)
Called to determine whether typing enter after the last line in lines should end input.
Definition IOHandler.h:260
virtual std::optional< std::string > IOHandlerSuggestion(IOHandler &io_handler, llvm::StringRef line)
virtual int IOHandlerFixIndentation(IOHandler &io_handler, const StringList &lines, int cursor_position)
Called when a new line is created or one of an identified set of indentation characters is typed.
Definition IOHandler.h:227
void PrintAsync(const char *s, size_t len, bool is_stdout) override
bool SetPrompt(llvm::StringRef prompt) override
bool GetLine(std::string &line, bool &interrupted)
void TerminalSizeChanged() override
bool GetLines(StringList &lines, bool &interrupted)
void SetBaseLineNumber(uint32_t line)
IOHandlerEditline(Debugger &debugger, IOHandler::Type type, const char *editline_name, llvm::StringRef prompt, llvm::StringRef continuation_prompt, bool multi_line, bool color, uint32_t line_number_start, IOHandlerDelegate &delegate)
void SetContinuationPrompt(llvm::StringRef prompt)
IOHandlerDelegate & m_delegate
Definition IOHandler.h:429
bool SetUseColor(bool use_color) override
const char * GetPrompt() override
uint32_t GetCurrentLineIndex() const
StringList GetCurrentLines() const
bool PrintAsync(const char *s, size_t len, bool is_stdout)
std::recursive_mutex m_mutex
Definition IOHandler.h:542
virtual void PrintAsync(const char *s, size_t len, bool is_stdout)
Predicate< bool > m_popped
Definition IOHandler.h:166
virtual void Activate()
Definition IOHandler.h:87
bool GetIsRealTerminal()
Check if the input is coming from a real terminal.
lldb::FileSP GetInputFileSP()
Definition IOHandler.cpp:91
Debugger & GetDebugger()
Definition IOHandler.h:130
virtual void Deactivate()
Definition IOHandler.h:89
lldb::LockableStreamFileSP m_output_sp
Definition IOHandler.h:164
lldb::LockableStreamFileSP m_error_sp
Definition IOHandler.h:165
IOHandler(Debugger &debugger, IOHandler::Type type)
Definition IOHandler.cpp:55
bool GetIsInteractive()
Check if the input is being supplied interactively by a user.
Definition IOHandler.cpp:97
lldb::FileSP m_input_sp
Definition IOHandler.h:163
lldb::LockableStreamFileSP GetErrorStreamFileSP()
Definition IOHandler.cpp:95
lldb::LockableStreamFileSP GetOutputStreamFileSP()
Definition IOHandler.cpp:93
void SetIsDone(bool b)
Definition IOHandler.h:81
An error handling class.
Definition Status.h:118
llvm::StringRef GetString() const
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition Stream.h:112
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
std::string CopyList(const char *item_preamble=nullptr, const char *items_sep="\n") const
void AppendString(const std::string &s)
#define UINT32_MAX
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
llvm::unique_function< int(Editline *, StringList &, int)> FixIndentationCallbackType
Definition Editline.h:97
A class that represents a running process on the host machine.
@ eBroadcastOnChange
Only broadcast if the value changes when the value is modified.
Definition Predicate.h:30
@ eVariablePathCompletion
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
std::shared_ptr< lldb_private::File > FileSP