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