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 
9 #include "lldb/Core/IOHandler.h"
10 
11 #if defined(__APPLE__)
12 #include <deque>
13 #endif
14 #include <string>
15 
16 #include "lldb/Core/Debugger.h"
17 #include "lldb/Core/StreamFile.h"
18 #include "lldb/Host/Config.h"
19 #include "lldb/Host/File.h"
21 #include "lldb/Utility/Predicate.h"
23 #include "lldb/Utility/Status.h"
26 #include "lldb/lldb-forward.h"
27 
28 #if LLDB_ENABLE_LIBEDIT
29 #include "lldb/Host/Editline.h"
30 #endif
33 #include "llvm/ADT/StringRef.h"
34 
35 #ifdef _WIN32
37 #endif
38 
39 #include <memory>
40 #include <mutex>
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 
51 using namespace lldb;
52 using namespace lldb_private;
53 using llvm::None;
54 using llvm::Optional;
55 using llvm::StringRef;
56 
57 IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
58  : IOHandler(debugger, type,
59  FileSP(), // Adopt STDIN from top input reader
60  StreamFileSP(), // Adopt STDOUT from top input reader
61  StreamFileSP(), // Adopt STDERR from top input reader
62  0, // Flags
63  nullptr // Shadow file recorder
64  ) {}
65 
67  const lldb::FileSP &input_sp,
68  const lldb::StreamFileSP &output_sp,
69  const lldb::StreamFileSP &error_sp, uint32_t flags,
70  repro::DataRecorder *data_recorder)
71  : m_debugger(debugger), m_input_sp(input_sp), m_output_sp(output_sp),
72  m_error_sp(error_sp), m_data_recorder(data_recorder), m_popped(false),
73  m_flags(flags), m_type(type), m_user_data(nullptr), m_done(false),
74  m_active(false) {
75  // If any files are not specified, then adopt them from the top input reader.
76  if (!m_input_sp || !m_output_sp || !m_error_sp)
78  m_error_sp);
79 }
80 
81 IOHandler::~IOHandler() = default;
82 
84  return (m_input_sp ? m_input_sp->GetDescriptor() : -1);
85 }
86 
88  return (m_output_sp ? m_output_sp->GetFile().GetDescriptor() : -1);
89 }
90 
92  return (m_error_sp ? m_error_sp->GetFile().GetDescriptor() : -1);
93 }
94 
96  return (m_input_sp ? m_input_sp->GetStream() : nullptr);
97 }
98 
100  return (m_output_sp ? m_output_sp->GetFile().GetStream() : nullptr);
101 }
102 
104  return (m_error_sp ? m_error_sp->GetFile().GetStream() : nullptr);
105 }
106 
108 
110 
111 StreamFileSP IOHandler::GetErrorStreamFileSP() { return m_error_sp; }
112 
114  return GetInputFileSP() ? GetInputFileSP()->GetIsInteractive() : false;
115 }
116 
118  return GetInputFileSP() ? GetInputFileSP()->GetIsRealTerminal() : false;
119 }
120 
122 
124 
125 void IOHandler::PrintAsync(const char *s, size_t len, bool is_stdout) {
126  std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
127  lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
128  stream->Write(s, len);
129  stream->Flush();
130 }
131 
132 bool IOHandlerStack::PrintAsync(const char *s, size_t len, bool is_stdout) {
133  std::lock_guard<std::recursive_mutex> guard(m_mutex);
134  if (!m_top)
135  return false;
136  m_top->PrintAsync(s, len, is_stdout);
137  return true;
138 }
139 
140 IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
141  bool default_response)
143  debugger, IOHandler::Type::Confirm,
144  nullptr, // nullptr editline_name means no history loaded/saved
145  llvm::StringRef(), // No prompt
146  llvm::StringRef(), // No continuation prompt
147  false, // Multi-line
148  false, // Don't colorize the prompt (i.e. the confirm message.)
149  0, *this, nullptr),
150  m_default_response(default_response), m_user_response(default_response) {
151  StreamString prompt_stream;
152  prompt_stream.PutCString(prompt);
153  if (m_default_response)
154  prompt_stream.Printf(": [Y/n] ");
155  else
156  prompt_stream.Printf(": [y/N] ");
157 
158  SetPrompt(prompt_stream.GetString());
159 }
160 
162 
164  CompletionRequest &request) {
165  if (request.GetRawCursorPos() != 0)
166  return;
167  request.AddCompletion(m_default_response ? "y" : "n");
168 }
169 
171  std::string &line) {
172  if (line.empty()) {
173  // User just hit enter, set the response to the default
175  io_handler.SetIsDone(true);
176  return;
177  }
178 
179  if (line.size() == 1) {
180  switch (line[0]) {
181  case 'y':
182  case 'Y':
183  m_user_response = true;
184  io_handler.SetIsDone(true);
185  return;
186  case 'n':
187  case 'N':
188  m_user_response = false;
189  io_handler.SetIsDone(true);
190  return;
191  default:
192  break;
193  }
194  }
195 
196  if (line == "yes" || line == "YES" || line == "Yes") {
197  m_user_response = true;
198  io_handler.SetIsDone(true);
199  } else if (line == "no" || line == "NO" || line == "No") {
200  m_user_response = false;
201  io_handler.SetIsDone(true);
202  }
203 }
204 
205 llvm::Optional<std::string>
207  llvm::StringRef line) {
208  return io_handler.GetDebugger()
211 }
212 
214  CompletionRequest &request) {
215  switch (m_completion) {
216  case Completion::None:
217  break;
219  io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(request);
220  break;
223  io_handler.GetDebugger().GetCommandInterpreter(),
225  break;
226  }
227 }
228 
230  Debugger &debugger, IOHandler::Type type,
231  const char *editline_name, // Used for saving history files
232  llvm::StringRef prompt, llvm::StringRef continuation_prompt,
233  bool multi_line, bool color_prompts, uint32_t line_number_start,
234  IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
235  : IOHandlerEditline(debugger, type,
236  FileSP(), // Inherit input from top input reader
237  StreamFileSP(), // Inherit output from top input reader
238  StreamFileSP(), // Inherit error from top input reader
239  0, // Flags
240  editline_name, // Used for saving history files
241  prompt, continuation_prompt, multi_line, color_prompts,
242  line_number_start, delegate, data_recorder) {}
243 
245  Debugger &debugger, IOHandler::Type type, const lldb::FileSP &input_sp,
246  const lldb::StreamFileSP &output_sp, const lldb::StreamFileSP &error_sp,
247  uint32_t flags,
248  const char *editline_name, // Used for saving history files
249  llvm::StringRef prompt, llvm::StringRef continuation_prompt,
250  bool multi_line, bool color_prompts, uint32_t line_number_start,
251  IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
252  : IOHandler(debugger, type, input_sp, output_sp, error_sp, flags,
253  data_recorder),
254 #if LLDB_ENABLE_LIBEDIT
255  m_editline_up(),
256 #endif
257  m_delegate(delegate), m_prompt(), m_continuation_prompt(),
258  m_current_lines_ptr(nullptr), m_base_line_number(line_number_start),
259  m_curr_line_idx(UINT32_MAX), m_multi_line(multi_line),
260  m_color_prompts(color_prompts), m_interrupt_exits(true) {
261  SetPrompt(prompt);
262 
263 #if LLDB_ENABLE_LIBEDIT
264  bool use_editline = false;
265 
266  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
267  m_input_sp && m_input_sp->GetIsRealTerminal();
268 
269  if (use_editline) {
270  m_editline_up = std::make_unique<Editline>(
271  editline_name, GetInputFILE(), GetOutputFILE(), GetErrorFILE(),
273  m_editline_up->SetIsInputCompleteCallback(
274  [this](Editline *editline, StringList &lines) {
275  return this->IsInputCompleteCallback(editline, lines);
276  });
277 
278  m_editline_up->SetAutoCompleteCallback([this](CompletionRequest &request) {
279  this->AutoCompleteCallback(request);
280  });
281 
282  if (debugger.GetUseAutosuggestion()) {
283  m_editline_up->SetSuggestionCallback([this](llvm::StringRef line) {
284  return this->SuggestionCallback(line);
285  });
286  m_editline_up->SetSuggestionAnsiPrefix(ansi::FormatAnsiTerminalCodes(
287  debugger.GetAutosuggestionAnsiPrefix()));
288  m_editline_up->SetSuggestionAnsiSuffix(ansi::FormatAnsiTerminalCodes(
289  debugger.GetAutosuggestionAnsiSuffix()));
290  }
291  // See if the delegate supports fixing indentation
292  const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters();
293  if (indent_chars) {
294  // The delegate does support indentation, hook it up so when any
295  // indentation character is typed, the delegate gets a chance to fix it
296  FixIndentationCallbackType f = [this](Editline *editline,
297  const StringList &lines,
298  int cursor_position) {
299  return this->FixIndentationCallback(editline, lines, cursor_position);
300  };
301  m_editline_up->SetFixIndentationCallback(std::move(f), indent_chars);
302  }
303  }
304 #endif
306  SetPrompt(prompt);
307  SetContinuationPrompt(continuation_prompt);
308 }
309 
311 #if LLDB_ENABLE_LIBEDIT
312  m_editline_up.reset();
313 #endif
314 }
315 
319 }
320 
324 }
325 
327 #if LLDB_ENABLE_LIBEDIT
328  if (m_editline_up)
329  m_editline_up->TerminalSizeChanged();
330 #endif
331 }
332 
333 // Split out a line from the buffer, if there is a full one to get.
334 static Optional<std::string> SplitLine(std::string &line_buffer) {
335  size_t pos = line_buffer.find('\n');
336  if (pos == std::string::npos)
337  return None;
338  std::string line =
339  std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r"));
340  line_buffer = line_buffer.substr(pos + 1);
341  return line;
342 }
343 
344 // If the final line of the file ends without a end-of-line, return
345 // it as a line anyway.
346 static Optional<std::string> SplitLineEOF(std::string &line_buffer) {
347  if (llvm::all_of(line_buffer, llvm::isSpace))
348  return None;
349  std::string line = std::move(line_buffer);
350  line_buffer.clear();
351  return line;
352 }
353 
354 bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
355 #if LLDB_ENABLE_LIBEDIT
356  if (m_editline_up) {
357  bool b = m_editline_up->GetLine(line, interrupted);
358  if (b && m_data_recorder)
359  m_data_recorder->Record(line, true);
360  return b;
361  }
362 #endif
363 
364  line.clear();
365 
366  if (GetIsInteractive()) {
367  const char *prompt = nullptr;
368 
369  if (m_multi_line && m_curr_line_idx > 0)
370  prompt = GetContinuationPrompt();
371 
372  if (prompt == nullptr)
373  prompt = GetPrompt();
374 
375  if (prompt && prompt[0]) {
376  if (m_output_sp) {
377  m_output_sp->Printf("%s", prompt);
378  m_output_sp->Flush();
379  }
380  }
381  }
382 
383  Optional<std::string> got_line = SplitLine(m_line_buffer);
384 
385  if (!got_line && !m_input_sp) {
386  // No more input file, we are done...
387  SetIsDone(true);
388  return false;
389  }
390 
391  FILE *in = GetInputFILE();
392  char buffer[256];
393 
394  if (!got_line && !in && m_input_sp) {
395  // there is no FILE*, fall back on just reading bytes from the stream.
396  while (!got_line) {
397  size_t bytes_read = sizeof(buffer);
398  Status error = m_input_sp->Read((void *)buffer, bytes_read);
399  if (error.Success() && !bytes_read) {
400  got_line = SplitLineEOF(m_line_buffer);
401  break;
402  }
403  if (error.Fail())
404  break;
405  m_line_buffer += StringRef(buffer, bytes_read);
406  got_line = SplitLine(m_line_buffer);
407  }
408  }
409 
410  if (!got_line && in) {
411  while (!got_line) {
412  char *r = fgets(buffer, sizeof(buffer), in);
413 #ifdef _WIN32
414  // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
415  // according to the docs on MSDN. However, this has evidently been a
416  // known bug since Windows 8. Therefore, we can't detect if a signal
417  // interrupted in the fgets. So pressing ctrl-c causes the repl to end
418  // and the process to exit. A temporary workaround is just to attempt to
419  // fgets twice until this bug is fixed.
420  if (r == nullptr)
421  r = fgets(buffer, sizeof(buffer), in);
422  // this is the equivalent of EINTR for Windows
423  if (r == nullptr && GetLastError() == ERROR_OPERATION_ABORTED)
424  continue;
425 #endif
426  if (r == nullptr) {
427  if (ferror(in) && errno == EINTR)
428  continue;
429  if (feof(in))
430  got_line = SplitLineEOF(m_line_buffer);
431  break;
432  }
433  m_line_buffer += buffer;
434  got_line = SplitLine(m_line_buffer);
435  }
436  }
437 
438  if (got_line) {
439  line = *got_line;
440  if (m_data_recorder)
441  m_data_recorder->Record(line, true);
442  }
443 
444  return (bool)got_line;
445 }
446 
447 #if LLDB_ENABLE_LIBEDIT
448 bool IOHandlerEditline::IsInputCompleteCallback(Editline *editline,
449  StringList &lines) {
450  return m_delegate.IOHandlerIsInputComplete(*this, lines);
451 }
452 
453 int IOHandlerEditline::FixIndentationCallback(Editline *editline,
454  const StringList &lines,
455  int cursor_position) {
456  return m_delegate.IOHandlerFixIndentation(*this, lines, cursor_position);
457 }
458 
459 llvm::Optional<std::string>
460 IOHandlerEditline::SuggestionCallback(llvm::StringRef line) {
461  return m_delegate.IOHandlerSuggestion(*this, line);
462 }
463 
464 void IOHandlerEditline::AutoCompleteCallback(CompletionRequest &request) {
465  m_delegate.IOHandlerComplete(*this, request);
466 }
467 #endif
468 
470 #if LLDB_ENABLE_LIBEDIT
471  if (m_editline_up) {
472  return m_editline_up->GetPrompt();
473  } else {
474 #endif
475  if (m_prompt.empty())
476  return nullptr;
477 #if LLDB_ENABLE_LIBEDIT
478  }
479 #endif
480  return m_prompt.c_str();
481 }
482 
483 bool IOHandlerEditline::SetPrompt(llvm::StringRef prompt) {
484  m_prompt = std::string(prompt);
485 
486 #if LLDB_ENABLE_LIBEDIT
487  if (m_editline_up)
488  m_editline_up->SetPrompt(m_prompt.empty() ? nullptr : m_prompt.c_str());
489 #endif
490  return true;
491 }
492 
494  return (m_continuation_prompt.empty() ? nullptr
495  : m_continuation_prompt.c_str());
496 }
497 
498 void IOHandlerEditline::SetContinuationPrompt(llvm::StringRef prompt) {
500 
501 #if LLDB_ENABLE_LIBEDIT
502  if (m_editline_up)
503  m_editline_up->SetContinuationPrompt(m_continuation_prompt.empty()
504  ? nullptr
505  : m_continuation_prompt.c_str());
506 #endif
507 }
508 
510  m_base_line_number = line;
511 }
512 
514 #if LLDB_ENABLE_LIBEDIT
515  if (m_editline_up)
516  return m_editline_up->GetCurrentLine();
517 #endif
518  return m_curr_line_idx;
519 }
520 
521 bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
522  m_current_lines_ptr = &lines;
523 
524  bool success = false;
525 #if LLDB_ENABLE_LIBEDIT
526  if (m_editline_up) {
527  return m_editline_up->GetLines(m_base_line_number, lines, interrupted);
528  } else {
529 #endif
530  bool done = false;
531  Status error;
532 
533  while (!done) {
534  // Show line numbers if we are asked to
535  std::string line;
536  if (m_base_line_number > 0 && GetIsInteractive()) {
537  if (m_output_sp) {
538  m_output_sp->Printf("%u%s",
540  GetPrompt() == nullptr ? " " : "");
541  }
542  }
543 
544  m_curr_line_idx = lines.GetSize();
545 
546  bool interrupted = false;
547  if (GetLine(line, interrupted) && !interrupted) {
548  lines.AppendString(line);
549  done = m_delegate.IOHandlerIsInputComplete(*this, lines);
550  } else {
551  done = true;
552  }
553  }
554  success = lines.GetSize() > 0;
555 #if LLDB_ENABLE_LIBEDIT
556  }
557 #endif
558  return success;
559 }
560 
561 // Each IOHandler gets to run until it is done. It should read data from the
562 // "in" and place output into "out" and "err and return when done.
564  std::string line;
565  while (IsActive()) {
566  bool interrupted = false;
567  if (m_multi_line) {
568  StringList lines;
569  if (GetLines(lines, interrupted)) {
570  if (interrupted) {
573 
574  } else {
575  line = lines.CopyList();
576  m_delegate.IOHandlerInputComplete(*this, line);
577  }
578  } else {
579  m_done = true;
580  }
581  } else {
582  if (GetLine(line, interrupted)) {
583  if (interrupted)
585  else
586  m_delegate.IOHandlerInputComplete(*this, line);
587  } else {
588  m_done = true;
589  }
590  }
591  }
592 }
593 
595 #if LLDB_ENABLE_LIBEDIT
596  if (m_editline_up)
597  m_editline_up->Cancel();
598 #endif
599 }
600 
602  // Let the delgate handle it first
603  if (m_delegate.IOHandlerInterrupt(*this))
604  return true;
605 
606 #if LLDB_ENABLE_LIBEDIT
607  if (m_editline_up)
608  return m_editline_up->Interrupt();
609 #endif
610  return false;
611 }
612 
614 #if LLDB_ENABLE_LIBEDIT
615  if (m_editline_up)
616  m_editline_up->Interrupt();
617 #endif
618 }
619 
620 void IOHandlerEditline::PrintAsync(const char *s, size_t len, bool is_stdout) {
621 #if LLDB_ENABLE_LIBEDIT
622  if (m_editline_up) {
623  std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
624  lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
625  m_editline_up->PrintAsync(stream.get(), s, len);
626  } else
627 #endif
628  {
629 #ifdef _WIN32
630  const char *prompt = GetPrompt();
631  if (prompt) {
632  // Back up over previous prompt using Windows API
633  CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
634  HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
635  GetConsoleScreenBufferInfo(console_handle, &screen_buffer_info);
636  COORD coord = screen_buffer_info.dwCursorPosition;
637  coord.X -= strlen(prompt);
638  if (coord.X < 0)
639  coord.X = 0;
640  SetConsoleCursorPosition(console_handle, coord);
641  }
642 #endif
643  IOHandler::PrintAsync(s, len, is_stdout);
644 #ifdef _WIN32
645  if (prompt)
646  IOHandler::PrintAsync(prompt, strlen(prompt), is_stdout);
647 #endif
648  }
649 }
lldb_private::IOHandler::SetPopped
void SetPopped(bool b)
Definition: IOHandler.cpp:121
lldb_private::IOHandlerConfirm::IOHandlerComplete
void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) override
Definition: IOHandler.cpp:163
lldb_private::IOHandler::PrintAsync
virtual void PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: IOHandler.cpp:125
lldb_private::IOHandlerEditline::Cancel
void Cancel() override
Definition: IOHandler.cpp:594
llvm
Definition: Debugger.h:50
lldb_private::CompletionRequest::GetRawCursorPos
unsigned GetRawCursorPos() const
Definition: CompletionRequest.h:132
lldb_private::IOHandler::IsActive
bool IsActive()
Definition: IOHandler.h:88
lldb_private::Debugger::AdoptTopIOHandlerFilesIfInvalid
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
Definition: Debugger.cpp:1108
lldb_private::IOHandlerDelegate::IOHandlerInterrupt
virtual bool IOHandlerInterrupt(IOHandler &io_handler)
Definition: IOHandler.h:290
lldb_private::IOHandler::GetOutputFILE
FILE * GetOutputFILE()
Definition: IOHandler.cpp:99
IOHandler.h
lldb_private::Debugger::GetCommandInterpreter
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:172
lldb_private::IOHandlerDelegate::IOHandlerFixIndentation
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:238
lldb_private::IOHandlerEditline::m_delegate
IOHandlerDelegate & m_delegate
Definition: IOHandler.h:436
lldb_private::IOHandlerEditline::IOHandlerEditline
IOHandlerEditline(Debugger &debugger, IOHandler::Type type, const char *editline_name, llvm::StringRef prompt, llvm::StringRef continuation_prompt, bool multi_line, bool color_prompts, uint32_t line_number_start, IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
Definition: IOHandler.cpp:229
lldb_private::IOHandler::GetInputFILE
FILE * GetInputFILE()
Definition: IOHandler.cpp:95
lldb_private::IOHandlerConfirm::IOHandlerConfirm
IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, bool default_response)
Definition: IOHandler.cpp:140
lldb_private::IOHandlerDelegate::IOHandlerIsInputComplete
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:271
lldb_private::IOHandlerEditline::Activate
void Activate() override
Definition: IOHandler.cpp:316
lldb_private::IOHandlerStack::m_mutex
std::recursive_mutex m_mutex
Definition: IOHandler.h:548
lldb_private::StringList::AppendString
void AppendString(const std::string &s)
Definition: StringList.cpp:43
lldb_private::IOHandlerEditline::PrintAsync
void PrintAsync(const char *s, size_t len, bool is_stdout) override
Definition: IOHandler.cpp:620
lldb_private::IOHandlerDelegate::IOHandlerGetFixIndentationCharacters
virtual const char * IOHandlerGetFixIndentationCharacters()
Definition: IOHandler.h:214
lldb_private::repro::DataRecorder
Recorder that records its data as text to a file.
Definition: ReproducerProvider.h:55
lldb_private::IOHandlerEditline::GetLines
bool GetLines(StringList &lines, bool &interrupted)
Definition: IOHandler.cpp:521
lldb_private::IOHandlerDelegate::IOHandlerDeactivated
virtual void IOHandlerDeactivated(IOHandler &io_handler)
Definition: IOHandler.h:206
lldb_private::IOHandler::m_output_sp
lldb::StreamFileSP m_output_sp
Definition: IOHandler.h:173
Predicate.h
lldb_private::IOHandlerEditline::m_color_prompts
bool m_color_prompts
Definition: IOHandler.h:443
Debugger.h
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::IOHandlerEditline::m_multi_line
bool m_multi_line
Definition: IOHandler.h:442
lldb_private::Debugger::GetUseAutosuggestion
bool GetUseAutosuggestion() const
Definition: Debugger.cpp:404
lldb_private::IOHandlerDelegate::Completion::Expression
@ Expression
lldb_private::StringList::GetSize
size_t GetSize() const
Definition: StringList.cpp:74
lldb_private::IOHandler::GetIsRealTerminal
bool GetIsRealTerminal()
Check if the input is coming from a real terminal.
Definition: IOHandler.cpp:117
lldb_private::IOHandler::m_data_recorder
repro::DataRecorder * m_data_recorder
Definition: IOHandler.h:176
ReproducerProvider.h
lldb_private::Debugger::GetAutosuggestionAnsiSuffix
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition: Debugger.cpp:415
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::IOHandlerConfirm::IOHandlerInputComplete
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
Definition: IOHandler.cpp:170
lldb_private::CommandInterpreter::HandleCompletion
void HandleCompletion(CompletionRequest &request)
lldb_private::IOHandlerEditline::SetPrompt
bool SetPrompt(llvm::StringRef prompt) override
Definition: IOHandler.cpp:483
lldb_private::IOHandlerEditline::Run
void Run() override
Definition: IOHandler.cpp:563
lldb_private::IOHandlerEditline::m_base_line_number
uint32_t m_base_line_number
Definition: IOHandler.h:440
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
Definition: CommandCompletions.cpp:51
lldb_private::IOHandler::GetIsInteractive
bool GetIsInteractive()
Check if the input is being supplied interactively by a user.
Definition: IOHandler.cpp:113
lldb_private::IOHandler::IOHandler
IOHandler(Debugger &debugger, IOHandler::Type type)
Definition: IOHandler.cpp:57
StreamString.h
lldb_private::StringList
Definition: StringList.h:26
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::IOHandler
Definition: IOHandler.h:46
lldb_private::IOHandler::GetInputFD
int GetInputFD()
Definition: IOHandler.cpp:83
Editline.h
lldb_private::IOHandler::m_popped
Predicate< bool > m_popped
Definition: IOHandler.h:177
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::IOHandlerDelegate::IOHandlerActivated
virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive)
Definition: IOHandler.h:204
lldb_private::IOHandlerDelegate::IOHandlerComplete
virtual void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request)
Definition: IOHandler.cpp:213
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
StringList.h
SplitLine
static Optional< std::string > SplitLine(std::string &line_buffer)
Definition: IOHandler.cpp:334
lldb_private::IOHandlerEditline::GetContinuationPrompt
const char * GetContinuationPrompt()
Definition: IOHandler.cpp:493
lldb_private::IOHandlerEditline::SetBaseLineNumber
void SetBaseLineNumber(uint32_t line)
Definition: IOHandler.cpp:509
lldb_private::eBroadcastOnChange
@ eBroadcastOnChange
Only broadcast if the value changes when the value is modified.
Definition: Predicate.h:29
AnsiTerminal.h
lldb_private::IOHandlerStack::m_top
IOHandler * m_top
Definition: IOHandler.h:549
lldb_private::IOHandler::Deactivate
virtual void Deactivate()
Definition: IOHandler.h:98
lldb_private::IOHandlerDelegate::Completion::None
@ None
lldb_private::IOHandlerEditline::GetCurrentLineIndex
uint32_t GetCurrentLineIndex() const
Definition: IOHandler.cpp:513
lldb_private::IOHandler::GetOutputFD
int GetOutputFD()
Definition: IOHandler.cpp:87
lldb_private::StringList::CopyList
std::string CopyList(const char *item_preamble=nullptr, const char *items_sep="\n") const
Definition: StringList.cpp:198
lldb_private::IOHandlerEditline::SetContinuationPrompt
void SetContinuationPrompt(llvm::StringRef prompt)
Definition: IOHandler.cpp:498
StreamFile.h
lldb_private::IOHandler::Activate
virtual void Activate()
Definition: IOHandler.h:96
lldb_private::IOHandlerEditline::m_current_lines_ptr
StringList * m_current_lines_ptr
Definition: IOHandler.h:439
lldb_private::IOHandlerEditline::Interrupt
bool Interrupt() override
Definition: IOHandler.cpp:601
lldb_private::IOHandlerEditline::m_prompt
std::string m_prompt
Definition: IOHandler.h:437
lldb_private::Status
Definition: Status.h:44
lldb_private::IOHandlerDelegate::Completion::LLDBCommand
@ LLDBCommand
lldb_private::IOHandlerEditline::GetLine
bool GetLine(std::string &line, bool &interrupted)
Definition: IOHandler.cpp:354
lldb_private::IOHandlerEditline::m_continuation_prompt
std::string m_continuation_prompt
Definition: IOHandler.h:438
lldb_private::IOHandlerEditline::Deactivate
void Deactivate() override
Definition: IOHandler.cpp:321
uint32_t
lldb_private::repro::DataRecorder::Record
void Record(const T &t, bool newline=false)
Definition: ReproducerProvider.h:63
lldb_private::IOHandlerDelegate::IOHandlerInputInterrupted
virtual void IOHandlerInputInterrupted(IOHandler &io_handler, std::string &data)
Definition: IOHandler.h:254
lldb_private::IOHandler::GetErrorFD
int GetErrorFD()
Definition: IOHandler.cpp:91
lldb_private::IOHandler::GetDebugger
Debugger & GetDebugger()
Definition: IOHandler.h:137
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::Predicate::WaitForValueEqualTo
bool WaitForValueEqualTo(T value, const Timeout< std::micro > &timeout=llvm::None)
Wait for m_value to be equal to value.
Definition: Predicate.h:154
lldb_private::IOHandler::GetInputFileSP
lldb::FileSP GetInputFileSP()
Definition: IOHandler.cpp:107
if
if(APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) remove_module_flags() endif() macro(add_host_subdirectory group) list(APPEND HOST_SOURCES $
Definition: Host/CMakeLists.txt:1
windows.h
lldb_private::IOHandler::m_error_sp
lldb::StreamFileSP m_error_sp
Definition: IOHandler.h:174
lldb_private::IOHandler::~IOHandler
virtual ~IOHandler()
lldb_private::IOHandler::Type
Type
Definition: IOHandler.h:48
lldb_private::IOHandlerConfirm::~IOHandlerConfirm
~IOHandlerConfirm() override
lldb_private::IOHandler::SetIsDone
void SetIsDone(bool b)
Definition: IOHandler.h:90
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::IOHandlerEditline::m_curr_line_idx
uint32_t m_curr_line_idx
Definition: IOHandler.h:441
lldb-forward.h
lldb_private::IOHandler::m_done
bool m_done
Definition: IOHandler.h:181
Status.h
lldb_private::IOHandlerDelegate
A delegate class for use with IOHandler subclasses.
Definition: IOHandler.h:195
lldb_private::CommandCompletions::eVariablePathCompletion
@ eVariablePathCompletion
Definition: CommandCompletions.h:37
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::IOHandlerStack::PrintAsync
bool PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: IOHandler.cpp:132
lldb_private::IOHandlerEditline::TerminalSizeChanged
void TerminalSizeChanged() override
Definition: IOHandler.cpp:326
lldb_private::CompletionRequest::AddCompletion
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
Definition: CompletionRequest.h:167
lldb_private::IOHandlerDelegate::IOHandlerSuggestion
virtual llvm::Optional< std::string > IOHandlerSuggestion(IOHandler &io_handler, llvm::StringRef line)
Definition: IOHandler.cpp:206
CommandInterpreter.h
lldb_private::IOHandlerEditline::~IOHandlerEditline
~IOHandlerEditline() override
Definition: IOHandler.cpp:310
lldb_private::IOHandlerEditline::GetPrompt
const char * GetPrompt() override
Definition: IOHandler.cpp:469
lldb_private::IOHandlerEditline::GotEOF
void GotEOF() override
Definition: IOHandler.cpp:613
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::IOHandler::m_output_mutex
std::recursive_mutex m_output_mutex
Definition: IOHandler.h:175
lldb_private::Debugger::GetAutosuggestionAnsiPrefix
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition: Debugger.cpp:410
lldb_private::IOHandlerDelegate::m_completion
Completion m_completion
Definition: IOHandler.h:293
lldb_private::IOHandlerConfirm::m_user_response
bool m_user_response
Definition: IOHandler.h:467
lldb_private::IOHandlerConfirm::m_default_response
const bool m_default_response
Definition: IOHandler.h:466
lldb_private::IOHandlerDelegate::IOHandlerInputComplete
virtual void IOHandlerInputComplete(IOHandler &io_handler, std::string &data)=0
Called when a line or lines have been retrieved.
lldb_private::IOHandler::GetOutputMutex
std::recursive_mutex & GetOutputMutex()
Definition: IOHandler.h:168
lldb_private::IOHandlerEditline::m_line_buffer
std::string m_line_buffer
Definition: IOHandler.h:445
lldb_private::IOHandler::WaitForPop
void WaitForPop()
Definition: IOHandler.cpp:123
lldb_private::CommandInterpreter::GetAutoSuggestionForCommand
llvm::Optional< std::string > GetAutoSuggestionForCommand(llvm::StringRef line)
Returns the auto-suggestion string that should be added to the given command line.
lldb
Definition: SBAddress.h:15
File.h
lldb_private::IOHandler::GetOutputStreamFileSP
lldb::StreamFileSP GetOutputStreamFileSP()
Definition: IOHandler.cpp:109
lldb_private::Predicate::SetValue
void SetValue(T value, PredicateBroadcastType broadcast_type)
Value set accessor.
Definition: Predicate.h:89
SplitLineEOF
static Optional< std::string > SplitLineEOF(std::string &line_buffer)
Definition: IOHandler.cpp:346
CommandCompletions.h
lldb_private::IOHandler::GetErrorFILE
FILE * GetErrorFILE()
Definition: IOHandler.cpp:103
lldb_private::IOHandlerEditline::m_interrupt_exits
bool m_interrupt_exits
Definition: IOHandler.h:444
lldb_private::IOHandler::GetErrorStreamFileSP
lldb::StreamFileSP GetErrorStreamFileSP()
Definition: IOHandler.cpp:111
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::IOHandler::m_input_sp
lldb::FileSP m_input_sp
Definition: IOHandler.h:172
lldb_private::ansi::FormatAnsiTerminalCodes
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
Definition: AnsiTerminal.h:83
lldb_private::IOHandlerEditline
Definition: IOHandler.h:332
endif
LLDBWrapPython cpp endif() if(LLDB_ENABLE_LUA) get_target_property(lua_bindings_dir swig_wrapper_lua BINARY_DIR) set(lldb_lua_wrapper $
Definition: API/CMakeLists.txt:11