LLDB  mainline
SBCommandInterpreter.cpp
Go to the documentation of this file.
1 //===-- SBCommandInterpreter.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/lldb-types.h"
10 
14 #include "lldb/Target/Target.h"
16 #include "lldb/Utility/Listener.h"
17 
18 #include "lldb/API/SBBroadcaster.h"
22 #include "lldb/API/SBEvent.h"
24 #include "lldb/API/SBListener.h"
25 #include "lldb/API/SBProcess.h"
26 #include "lldb/API/SBStream.h"
27 #include "lldb/API/SBStringList.h"
28 #include "lldb/API/SBTarget.h"
29 
30 #include <memory>
31 
32 using namespace lldb;
33 using namespace lldb_private;
34 
36 public:
38  const char *name,
40  const char *help = nullptr,
41  const char *syntax = nullptr,
42  uint32_t flags = 0,
43  const char *auto_repeat_command = "")
44  : CommandObjectParsed(interpreter, name, help, syntax, flags),
45  m_backend(backend) {
46  m_auto_repeat_command =
47  auto_repeat_command == nullptr
48  ? llvm::None
49  : llvm::Optional<std::string>(auto_repeat_command);
50  }
51 
52  bool IsRemovable() const override { return true; }
53 
54  /// More documentation is available in lldb::CommandObject::GetRepeatCommand,
55  /// but in short, if nullptr is returned, the previous command will be
56  /// repeated, and if an empty string is returned, no commands will be
57  /// executed.
58  const char *GetRepeatCommand(Args &current_command_args,
59  uint32_t index) override {
60  if (!m_auto_repeat_command)
61  return nullptr;
62  else
63  return m_auto_repeat_command->c_str();
64  }
65 
66 protected:
67  bool DoExecute(Args &command, CommandReturnObject &result) override {
68  SBCommandReturnObject sb_return(result);
69  SBCommandInterpreter sb_interpreter(&m_interpreter);
70  SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
71  bool ret = m_backend->DoExecute(
72  debugger_sb, command.GetArgumentVector(), sb_return);
73  return ret;
74  }
75  std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
76  llvm::Optional<std::string> m_auto_repeat_command;
77 };
78 
80  : m_opaque_ptr(interpreter) {
81  LLDB_INSTRUMENT_VA(this, interpreter);
82 }
83 
85  : m_opaque_ptr(rhs.m_opaque_ptr) {
86  LLDB_INSTRUMENT_VA(this, rhs);
87 }
88 
90 
93  LLDB_INSTRUMENT_VA(this, rhs);
94 
96  return *this;
97 }
98 
100  LLDB_INSTRUMENT_VA(this);
101  return this->operator bool();
102 }
103 SBCommandInterpreter::operator bool() const {
104  LLDB_INSTRUMENT_VA(this);
105 
106  return m_opaque_ptr != nullptr;
107 }
108 
109 bool SBCommandInterpreter::CommandExists(const char *cmd) {
110  LLDB_INSTRUMENT_VA(this, cmd);
111 
112  return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd)
113  : false);
114 }
115 
116 bool SBCommandInterpreter::AliasExists(const char *cmd) {
117  LLDB_INSTRUMENT_VA(this, cmd);
118 
119  return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd)
120  : false);
121 }
122 
124  LLDB_INSTRUMENT_VA(this);
125 
126  return (IsValid() ? m_opaque_ptr->IsActive() : false);
127 }
128 
130  LLDB_INSTRUMENT_VA(this);
131 
132  return (IsValid() ? m_opaque_ptr->WasInterrupted() : false);
133 }
134 
136  LLDB_INSTRUMENT_VA(this, ch);
137 
138  return (IsValid()
141  .GetCString()
142  : nullptr);
143 }
144 
146 SBCommandInterpreter::HandleCommand(const char *command_line,
147  SBCommandReturnObject &result,
148  bool add_to_history) {
149  LLDB_INSTRUMENT_VA(this, command_line, result, add_to_history);
150 
151  SBExecutionContext sb_exe_ctx;
152  return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
153 }
154 
156  const char *command_line, SBExecutionContext &override_context,
157  SBCommandReturnObject &result, bool add_to_history) {
158  LLDB_INSTRUMENT_VA(this, command_line, override_context, result,
159  add_to_history);
160 
161  result.Clear();
162  if (command_line && IsValid()) {
163  result.ref().SetInteractive(false);
164  auto do_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
165  if (override_context.get())
166  m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
167  override_context.get()->Lock(true),
168  result.ref());
169  else
170  m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
171  result.ref());
172  } else {
173  result->AppendError(
174  "SBCommandInterpreter or the command line is not valid");
175  }
176 
177  return result.GetStatus();
178 }
179 
181  lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context,
184  LLDB_INSTRUMENT_VA(this, file, override_context, options, result);
185 
186  if (!IsValid()) {
187  result->AppendError("SBCommandInterpreter is not valid.");
188  return;
189  }
190 
191  if (!file.IsValid()) {
192  SBStream s;
193  file.GetDescription(s);
194  result->AppendErrorWithFormat("File is not valid: %s.", s.GetData());
195  }
196 
197  FileSpec tmp_spec = file.ref();
198  if (override_context.get())
200  override_context.get()->Lock(true),
201  options.ref(),
202  result.ref());
203 
204  else
205  m_opaque_ptr->HandleCommandsFromFile(tmp_spec, options.ref(), result.ref());
206 }
207 
209  const char *current_line, const char *cursor, const char *last_char,
210  int match_start_point, int max_return_elements, SBStringList &matches) {
211  LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
212  max_return_elements, matches);
213 
214  SBStringList dummy_descriptions;
216  current_line, cursor, last_char, match_start_point, max_return_elements,
217  matches, dummy_descriptions);
218 }
219 
221  const char *current_line, const char *cursor, const char *last_char,
222  int match_start_point, int max_return_elements, SBStringList &matches,
223  SBStringList &descriptions) {
224  LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
225  max_return_elements, matches, descriptions);
226 
227  // Sanity check the arguments that are passed in: cursor & last_char have to
228  // be within the current_line.
229  if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
230  return 0;
231 
232  if (cursor < current_line || last_char < current_line)
233  return 0;
234 
235  size_t current_line_size = strlen(current_line);
236  if (cursor - current_line > static_cast<ptrdiff_t>(current_line_size) ||
237  last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
238  return 0;
239 
240  if (!IsValid())
241  return 0;
242 
243  lldb_private::StringList lldb_matches, lldb_descriptions;
244  CompletionResult result;
245  CompletionRequest request(current_line, cursor - current_line, result);
246  m_opaque_ptr->HandleCompletion(request);
247  result.GetMatches(lldb_matches);
248  result.GetDescriptions(lldb_descriptions);
249 
250  // Make the result array indexed from 1 again by adding the 'common prefix'
251  // of all completions as element 0. This is done to emulate the old API.
252  if (request.GetParsedLine().GetArgumentCount() == 0) {
253  // If we got an empty string, insert nothing.
254  lldb_matches.InsertStringAtIndex(0, "");
255  lldb_descriptions.InsertStringAtIndex(0, "");
256  } else {
257  // Now figure out if there is a common substring, and if so put that in
258  // element 0, otherwise put an empty string in element 0.
259  std::string command_partial_str = request.GetCursorArgumentPrefix().str();
260 
261  std::string common_prefix = lldb_matches.LongestCommonPrefix();
262  const size_t partial_name_len = command_partial_str.size();
263  common_prefix.erase(0, partial_name_len);
264 
265  // If we matched a unique single command, add a space... Only do this if
266  // the completer told us this was a complete word, however...
267  if (lldb_matches.GetSize() == 1) {
268  char quote_char = request.GetParsedArg().GetQuoteChar();
269  common_prefix =
270  Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
271  if (request.GetParsedArg().IsQuoted())
272  common_prefix.push_back(quote_char);
273  common_prefix.push_back(' ');
274  }
275  lldb_matches.InsertStringAtIndex(0, common_prefix.c_str());
276  lldb_descriptions.InsertStringAtIndex(0, "");
277  }
278 
279  SBStringList temp_matches_list(&lldb_matches);
280  matches.AppendList(temp_matches_list);
281  SBStringList temp_descriptions_list(&lldb_descriptions);
282  descriptions.AppendList(temp_descriptions_list);
283  return result.GetNumberOfResults();
284 }
285 
287  const char *current_line, uint32_t cursor_pos, int match_start_point,
288  int max_return_elements, SBStringList &matches,
289  SBStringList &descriptions) {
290  LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
291  max_return_elements, matches, descriptions);
292 
293  const char *cursor = current_line + cursor_pos;
294  const char *last_char = current_line + strlen(current_line);
296  current_line, cursor, last_char, match_start_point, max_return_elements,
297  matches, descriptions);
298 }
299 
300 int SBCommandInterpreter::HandleCompletion(const char *current_line,
301  uint32_t cursor_pos,
302  int match_start_point,
303  int max_return_elements,
304  lldb::SBStringList &matches) {
305  LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
306  max_return_elements, matches);
307 
308  const char *cursor = current_line + cursor_pos;
309  const char *last_char = current_line + strlen(current_line);
310  return HandleCompletion(current_line, cursor, last_char, match_start_point,
311  max_return_elements, matches);
312 }
313 
315  LLDB_INSTRUMENT_VA(this);
316 
317  return (IsValid() ? m_opaque_ptr->HasCommands() : false);
318 }
319 
321  LLDB_INSTRUMENT_VA(this);
322 
323  return (IsValid() ? m_opaque_ptr->HasAliases() : false);
324 }
325 
327  LLDB_INSTRUMENT_VA(this);
328 
329  return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
330 }
331 
333  LLDB_INSTRUMENT_VA(this);
334 
335  SBProcess sb_process;
336  ProcessSP process_sp;
337  if (IsValid()) {
338  TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
339  if (target_sp) {
340  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
341  process_sp = target_sp->GetProcessSP();
342  sb_process.SetSP(process_sp);
343  }
344  }
345 
346  return sb_process;
347 }
348 
350  LLDB_INSTRUMENT_VA(this);
351 
352  SBDebugger sb_debugger;
353  if (IsValid())
354  sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
355 
356  return sb_debugger;
357 }
358 
360  LLDB_INSTRUMENT_VA(this);
361 
362  return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
363 }
364 
366  LLDB_INSTRUMENT_VA(this, b);
367 
368  if (IsValid())
370 }
371 
373  LLDB_INSTRUMENT_VA(this, allow);
374 
375  if (m_opaque_ptr)
377 }
378 
380  LLDB_INSTRUMENT_VA(this);
381 
382  bool exited = false;
383  if (m_opaque_ptr)
384  m_opaque_ptr->GetQuitExitCode(exited);
385  return exited;
386 }
387 
389  LLDB_INSTRUMENT_VA(this);
390 
391  bool exited = false;
392  return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
393 }
394 
395 void SBCommandInterpreter::ResolveCommand(const char *command_line,
396  SBCommandReturnObject &result) {
397  LLDB_INSTRUMENT_VA(this, command_line, result);
398 
399  result.Clear();
400  if (command_line && IsValid()) {
401  m_opaque_ptr->ResolveCommand(command_line, result.ref());
402  } else {
403  result->AppendError(
404  "SBCommandInterpreter or the command line is not valid");
405  }
406 }
407 
409 
411  assert(m_opaque_ptr);
412  return *m_opaque_ptr;
413 }
414 
416  lldb_private::CommandInterpreter *interpreter) {
417  m_opaque_ptr = interpreter;
418 }
419 
421  SBCommandReturnObject &result) {
422  LLDB_INSTRUMENT_VA(this, result);
423 
424  result.Clear();
425  if (IsValid()) {
426  TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
427  std::unique_lock<std::recursive_mutex> lock;
428  if (target_sp)
429  lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
431  } else {
432  result->AppendError("SBCommandInterpreter is not valid");
433  }
434 }
435 
437  SBCommandReturnObject &result, bool is_repl) {
438  LLDB_INSTRUMENT_VA(this, result, is_repl);
439 
440  result.Clear();
441  if (IsValid()) {
442  TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
443  std::unique_lock<std::recursive_mutex> lock;
444  if (target_sp)
445  lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
446  m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
447  } else {
448  result->AppendError("SBCommandInterpreter is not valid");
449  }
450 }
451 
453  SBCommandReturnObject &result) {
454  LLDB_INSTRUMENT_VA(this, result);
455 
456  result.Clear();
457  if (IsValid()) {
458  TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
459  std::unique_lock<std::recursive_mutex> lock;
460  if (target_sp)
461  lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
463  } else {
464  result->AppendError("SBCommandInterpreter is not valid");
465  }
466 }
467 
469  LLDB_INSTRUMENT_VA(this);
470 
471  SBBroadcaster broadcaster(m_opaque_ptr, false);
472 
473  return broadcaster;
474 }
475 
477  LLDB_INSTRUMENT();
478 
479  return CommandInterpreter::GetStaticBroadcasterClass().AsCString();
480 }
481 
483  const lldb::CommandArgumentType arg_type) {
484  LLDB_INSTRUMENT_VA(arg_type);
485 
486  return CommandObject::GetArgumentTypeAsCString(arg_type);
487 }
488 
490  const lldb::CommandArgumentType arg_type) {
491  LLDB_INSTRUMENT_VA(arg_type);
492 
493  return CommandObject::GetArgumentDescriptionAsCString(arg_type);
494 }
495 
497  const lldb::SBEvent &event) {
498  LLDB_INSTRUMENT_VA(event);
499 
500  return event.GetBroadcasterClass() ==
502 }
503 
505  const char *command_name, lldb::CommandOverrideCallback callback,
506  void *baton) {
507  LLDB_INSTRUMENT_VA(this, command_name, callback, baton);
508 
509  if (command_name && command_name[0] && IsValid()) {
510  llvm::StringRef command_name_str = command_name;
511  CommandObject *cmd_obj =
512  m_opaque_ptr->GetCommandObjectForCommand(command_name_str);
513  if (cmd_obj) {
514  assert(command_name_str.empty());
515  cmd_obj->SetOverrideCallback(callback, baton);
516  return true;
517  }
518  }
519  return false;
520 }
521 
523  const char *help) {
524  LLDB_INSTRUMENT_VA(this, name, help);
525 
526  lldb::CommandObjectSP new_command_sp(
527  new CommandObjectMultiword(*m_opaque_ptr, name, help));
528  new_command_sp->GetAsMultiwordCommand()->SetRemovable(true);
529  Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
530  if (add_error.Success())
531  return lldb::SBCommand(new_command_sp);
532  return lldb::SBCommand();
533 }
534 
536  const char *name, lldb::SBCommandPluginInterface *impl, const char *help) {
537  LLDB_INSTRUMENT_VA(this, name, impl, help);
538 
539  return AddCommand(name, impl, help, /*syntax=*/nullptr,
540  /*auto_repeat_command=*/"");
541 }
542 
546  const char *help, const char *syntax) {
547  LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
548  return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
549 }
550 
552  const char *name, lldb::SBCommandPluginInterface *impl, const char *help,
553  const char *syntax, const char *auto_repeat_command) {
554  LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
555 
556  lldb::CommandObjectSP new_command_sp;
557  new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
558  *m_opaque_ptr, name, impl, help, syntax, /*flags=*/0,
559  auto_repeat_command);
560 
561  Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
562  if (add_error.Success())
563  return lldb::SBCommand(new_command_sp);
564  return lldb::SBCommand();
565 }
566 
568 
569 SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {}
570 
572  LLDB_INSTRUMENT_VA(this);
573  return this->operator bool();
574 }
575 SBCommand::operator bool() const {
576  LLDB_INSTRUMENT_VA(this);
577 
578  return m_opaque_sp.get() != nullptr;
579 }
580 
581 const char *SBCommand::GetName() {
582  LLDB_INSTRUMENT_VA(this);
583 
584  return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
585 }
586 
587 const char *SBCommand::GetHelp() {
588  LLDB_INSTRUMENT_VA(this);
589 
590  return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
591  : nullptr);
592 }
593 
594 const char *SBCommand::GetHelpLong() {
595  LLDB_INSTRUMENT_VA(this);
596 
597  return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
598  : nullptr);
599 }
600 
601 void SBCommand::SetHelp(const char *help) {
602  LLDB_INSTRUMENT_VA(this, help);
603 
604  if (IsValid())
605  m_opaque_sp->SetHelp(help);
606 }
607 
608 void SBCommand::SetHelpLong(const char *help) {
609  LLDB_INSTRUMENT_VA(this, help);
610 
611  if (IsValid())
612  m_opaque_sp->SetHelpLong(help);
613 }
614 
616  const char *help) {
617  LLDB_INSTRUMENT_VA(this, name, help);
618 
619  if (!IsValid())
620  return lldb::SBCommand();
621  if (!m_opaque_sp->IsMultiwordObject())
622  return lldb::SBCommand();
624  m_opaque_sp->GetCommandInterpreter(), name, help);
625  new_command->SetRemovable(true);
626  lldb::CommandObjectSP new_command_sp(new_command);
627  if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
628  return lldb::SBCommand(new_command_sp);
629  return lldb::SBCommand();
630 }
631 
634  const char *help) {
635  LLDB_INSTRUMENT_VA(this, name, impl, help);
636  return AddCommand(name, impl, help, /*syntax=*/nullptr,
637  /*auto_repeat_command=*/"");
638 }
639 
642  const char *help, const char *syntax) {
643  LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
644  return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
645 }
646 
649  const char *help, const char *syntax,
650  const char *auto_repeat_command) {
651  LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
652 
653  if (!IsValid())
654  return lldb::SBCommand();
655  if (!m_opaque_sp->IsMultiwordObject())
656  return lldb::SBCommand();
657  lldb::CommandObjectSP new_command_sp;
658  new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
659  m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
660  /*flags=*/0, auto_repeat_command);
661  if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
662  return lldb::SBCommand(new_command_sp);
663  return lldb::SBCommand();
664 }
665 
667  LLDB_INSTRUMENT_VA(this);
668 
669  return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
670 }
671 
673  LLDB_INSTRUMENT_VA(this, flags);
674 
675  if (IsValid())
676  m_opaque_sp->GetFlags().Set(flags);
677 }
lldb_private::CommandInterpreter::GetPromptOnQuit
bool GetPromptOnQuit() const
Definition: CommandInterpreter.cpp:141
lldb::SBCommandReturnObject::ref
lldb_private::CommandReturnObject & ref() const
Definition: SBCommandReturnObject.cpp:213
lldb::SBStringList
Definition: SBStringList.h:16
Instrumentation.h
lldb_private::CommandObjectParsed
Definition: CommandObject.h:389
SBCommandInterpreterRunOptions.h
lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory
void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result)
Definition: SBCommandInterpreter.cpp:420
lldb::SBCommandPluginInterface
Definition: SBCommandInterpreter.h:279
lldb::SBCommandInterpreter::~SBCommandInterpreter
~SBCommandInterpreter()
lldb::SBCommandInterpreter::get
lldb_private::CommandInterpreter * get()
Definition: SBCommandInterpreter.cpp:408
lldb_private::CompletionRequest::GetParsedArg
const Args::ArgEntry & GetParsedArg()
Definition: CompletionRequest.h:138
lldb_private::CommandInterpreter::GetCommandObjectForCommand
CommandObject * GetCommandObjectForCommand(llvm::StringRef &command_line)
lldb_private::CompletionRequest::GetParsedLine
const Args & GetParsedLine() const
Definition: CompletionRequest.h:134
lldb_private::CommandInterpreter::HandleCommand
bool HandleCommand(const char *command_line, LazyBool add_to_history, const ExecutionContext &override_context, CommandReturnObject &result)
CommandPluginInterfaceImplementation::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: SBCommandInterpreter.cpp:67
lldb::SBCommandReturnObject
Definition: SBCommandReturnObject.h:24
lldb::SBCommandInterpreter::GetQuitStatus
int GetQuitStatus()
Returns the exit code that the user has specified when running the 'quit' command.
Definition: SBCommandInterpreter.cpp:388
lldb::SBCommandInterpreter
Definition: SBCommandInterpreter.h:19
SBStringList.h
lldb::SBCommand::AddMultiwordCommand
lldb::SBCommand AddMultiwordCommand(const char *name, const char *help=nullptr)
Definition: SBCommandInterpreter.cpp:615
lldb::SBProcess::SetSP
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:104
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
lldb::SBCommandInterpreter::AllowExitCodeOnQuit
void AllowExitCodeOnQuit(bool allow)
Sets whether the command interpreter should allow custom exit codes for the 'quit' command.
Definition: SBCommandInterpreter.cpp:372
lldb::SBCommandInterpreter::HasCommands
bool HasCommands()
Definition: SBCommandInterpreter.cpp:314
lldb_private::CommandInterpreter::HasCommands
bool HasCommands() const
lldb::SBCommandInterpreter::GetPromptOnQuit
bool GetPromptOnQuit()
Definition: SBCommandInterpreter.cpp:359
lldb::SBCommand::SetFlags
void SetFlags(uint32_t flags)
Definition: SBCommandInterpreter.cpp:672
CommandPluginInterfaceImplementation::GetRepeatCommand
const char * GetRepeatCommand(Args &current_command_args, uint32_t index) override
More documentation is available in lldb::CommandObject::GetRepeatCommand, but in short,...
Definition: SBCommandInterpreter.cpp:58
lldb::SBCommandInterpreter::GetProcess
lldb::SBProcess GetProcess()
Definition: SBCommandInterpreter.cpp:332
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb::SBExecutionContext::get
lldb_private::ExecutionContextRef * get() const
Definition: SBExecutionContext.cpp:73
lldb::SBCommandInterpreter::GetBroadcasterClass
static const char * GetBroadcasterClass()
Definition: SBCommandInterpreter.cpp:476
lldb::SBCommand::GetFlags
uint32_t GetFlags()
Definition: SBCommandInterpreter.cpp:666
lldb::SBEvent
Definition: SBEvent.h:21
LLDB_INSTRUMENT
#define LLDB_INSTRUMENT()
Definition: Instrumentation.h:97
lldb::SBProcess
Definition: SBProcess.h:23
lldb::SBCommandInterpreter::GetDebugger
lldb::SBDebugger GetDebugger()
Definition: SBCommandInterpreter.cpp:349
lldb_private::StringList::InsertStringAtIndex
void InsertStringAtIndex(size_t idx, const std::string &str)
Definition: StringList.cpp:133
lldb_private::Debugger::GetTopIOHandlerControlSequence
ConstString GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1049
lldb_private::Args
Definition: Args.h:33
lldb_private::CompletionResult::GetMatches
void GetMatches(StringList &matches) const
Adds all collected completion matches to the given list.
Definition: CompletionRequest.cpp:71
lldb_private::CommandInterpreter::SourceInitFileHome
void SourceInitFileHome(CommandReturnObject &result, bool is_repl=false)
lldb::SBCommandInterpreter::HandleCommand
lldb::ReturnStatus HandleCommand(const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history=false)
Definition: SBCommandInterpreter.cpp:146
CommandReturnObject.h
lldb_private::CommandInterpreter::SetPromptOnQuit
void SetPromptOnQuit(bool enable)
Definition: CommandInterpreter.cpp:147
Listener.h
SBListener.h
lldb::SBExecutionContext
Definition: SBExecutionContext.h:20
lldb_private::ExecutionContextRef::Lock
ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const
Create an ExecutionContext object from this object.
Definition: ExecutionContext.cpp:615
lldb::SBCommandInterpreter::IsValid
bool IsValid() const
Definition: SBCommandInterpreter.cpp:99
lldb_private::CommandInterpreter::AllowExitCodeOnQuit
void AllowExitCodeOnQuit(bool allow)
Specify if the command interpreter should allow that the user can specify a custom exit code when cal...
Definition: CommandInterpreter.cpp:195
lldb_private::StringList::GetSize
size_t GetSize() const
Definition: StringList.cpp:74
lldb::SBFileSpec::GetDescription
bool GetDescription(lldb::SBStream &description) const
Definition: SBFileSpec.cpp:168
lldb::SBCommand::m_opaque_sp
lldb::CommandObjectSP m_opaque_sp
Definition: SBCommandInterpreter.h:404
Target.h
lldb::SBCommandInterpreter::GetIOHandlerControlSequence
const char * GetIOHandlerControlSequence(char ch)
Get the string that needs to be written to the debugger stdin file handle when a control character is...
Definition: SBCommandInterpreter.cpp:135
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::CommandObjectMultiword::SetRemovable
void SetRemovable(bool removable)
Definition: CommandObjectMultiword.h:65
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:288
SBStream.h
lldb::SBCommandInterpreter::AddMultiwordCommand
lldb::SBCommand AddMultiwordCommand(const char *name, const char *help)
Definition: SBCommandInterpreter.cpp:522
lldb_private::CommandInterpreter::HandleCompletion
void HandleCompletion(CompletionRequest &request)
lldb::CommandArgumentType
CommandArgumentType
Definition: lldb-enumerations.h:515
lldb::SBCommandInterpreterRunOptions::ref
lldb_private::CommandInterpreterRunOptions & ref() const
Definition: SBCommandInterpreterRunOptions.cpp:173
lldb::SBDebugger
Definition: SBDebugger.h:34
lldb::ReturnStatus
ReturnStatus
Command Return Status Types.
Definition: lldb-enumerations.h:258
lldb::SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory
void SourceInitFileInCurrentWorkingDirectory(lldb::SBCommandReturnObject &result)
Definition: SBCommandInterpreter.cpp:452
lldb::SBCommand::GetHelpLong
const char * GetHelpLong()
Definition: SBCommandInterpreter.cpp:594
lldb_private::CommandInterpreter::GetQuitExitCode
int GetQuitExitCode(bool &exited) const
Returns the exit code that the user has specified when running the 'quit' command.
Definition: CommandInterpreter.cpp:208
lldb::SBCommandReturnObject::GetStatus
lldb::ReturnStatus GetStatus()
Definition: SBCommandReturnObject.cpp:165
lldb::SBCommandInterpreter::AliasExists
bool AliasExists(const char *cmd)
Definition: SBCommandInterpreter.cpp:116
lldb_private::CommandInterpreter::SourceInitFileCwd
void SourceInitFileCwd(CommandReturnObject &result)
lldb_private::StringList
Definition: StringList.h:26
SBBroadcaster.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb::SBCommandInterpreter::HasAliases
bool HasAliases()
Definition: SBCommandInterpreter.cpp:320
lldb_private::CommandInterpreter::ResolveCommand
void ResolveCommand(const char *command_line, CommandReturnObject &result)
Definition: CommandInterpreter.cpp:215
lldb::SBCommandInterpreter::GetBroadcaster
lldb::SBBroadcaster GetBroadcaster()
Definition: SBCommandInterpreter.cpp:468
lldb_private::StringList::LongestCommonPrefix
std::string LongestCommonPrefix()
Definition: StringList.cpp:107
lldb::SBCommandInterpreter::ref
lldb_private::CommandInterpreter & ref()
Definition: SBCommandInterpreter.cpp:410
lldb::SBFileSpec::ref
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:162
lldb::SBFileSpec::IsValid
bool IsValid() const
Definition: SBFileSpec.cpp:76
lldb::SBCommandInterpreter::HasCustomQuitExitCode
bool HasCustomQuitExitCode()
Returns true if the user has called the 'quit' command with a custom exit code.
Definition: SBCommandInterpreter.cpp:379
lldb::SBCommandInterpreter::GetArgumentTypeAsCString
static const char * GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type)
Definition: SBCommandInterpreter.cpp:482
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::CommandInterpreter::AliasExists
bool AliasExists(llvm::StringRef cmd) const
Determine whether an alias command with this name exists.
CommandObjectMultiword.h
lldb::SBCommandInterpreter::SBCommandInterpreter
SBCommandInterpreter(const lldb::SBCommandInterpreter &rhs)
Definition: SBCommandInterpreter.cpp:84
lldb::SBCommandReturnObject::Clear
void Clear()
Definition: SBCommandReturnObject.cpp:159
lldb::SBCommand::SetHelpLong
void SetHelpLong(const char *)
Definition: SBCommandInterpreter.cpp:608
lldb_private::CommandInterpreter::AddUserCommand
Status AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
lldb::SBCommand
Definition: SBCommandInterpreter.h:289
lldb_private::CompletionRequest::GetCursorArgumentPrefix
llvm::StringRef GetCursorArgumentPrefix() const
Definition: CompletionRequest.h:217
lldb_private::CommandInterpreter::HasAliases
bool HasAliases() const
lldb_private::CommandInterpreter::CommandExists
bool CommandExists(llvm::StringRef cmd) const
Determine whether a root level, built-in command with this name exists.
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb::SBDebugger::reset
void reset(const lldb::DebuggerSP &debugger_sp)
Definition: SBDebugger.cpp:1220
lldb_private::Args::ArgEntry::GetQuoteChar
char GetQuoteChar() const
Definition: Args.h:55
lldb_private::CommandInterpreter::WasInterrupted
bool WasInterrupted() const
lldb::SBCommandInterpreter::CommandExists
bool CommandExists(const char *cmd)
Definition: SBCommandInterpreter.cpp:109
lldb::SBCommand::GetHelp
const char * GetHelp()
Definition: SBCommandInterpreter.cpp:587
lldb::SBCommandInterpreter::HandleCompletion
int HandleCompletion(const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, lldb::SBStringList &matches)
Definition: SBCommandInterpreter.cpp:208
lldb::SBCommand::AddCommand
lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help=nullptr)
Add a new subcommand to the lldb::SBCommand.
Definition: SBCommandInterpreter.cpp:632
lldb-types.h
lldb_private::CommandObject
Definition: CommandObject.h:67
lldb_private::CommandObject::SetOverrideCallback
void SetOverrideCallback(lldb::CommandOverrideCallback callback, void *baton)
Definition: CommandObject.h:294
lldb::SBCommandInterpreter::AddCommand
lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help)
Add a new command to the lldb::CommandInterpreter.
Definition: SBCommandInterpreter.cpp:535
lldb::SBCommand
class LLDB_API SBCommand
Definition: SBDefines.h:40
lldb::SBCommandInterpreter::HasAliasOptions
bool HasAliasOptions()
Definition: SBCommandInterpreter.cpp:326
lldb_private::Status
Definition: Status.h:44
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
lldb::SBCommandInterpreter::WasInterrupted
bool WasInterrupted() const
Definition: SBCommandInterpreter.cpp:129
CommandPluginInterfaceImplementation::IsRemovable
bool IsRemovable() const override
Definition: SBCommandInterpreter.cpp:52
lldb_private::CommandInterpreter::GetDebugger
Debugger & GetDebugger()
Definition: CommandInterpreter.h:436
lldb_private::CommandInterpreter::HasAliasOptions
bool HasAliasOptions() const
lldb::SBCommandInterpreter::ResolveCommand
void ResolveCommand(const char *command_line, SBCommandReturnObject &result)
Resolve the command just as HandleCommand would, expanding abbreviations and aliases.
Definition: SBCommandInterpreter.cpp:395
lldb_private::CommandInterpreter::HandleCommandsFromFile
void HandleCommandsFromFile(FileSpec &file, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands from a file.
lldb::SBCommandInterpreter::HandleCommandsFromFile
void HandleCommandsFromFile(lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result)
Definition: SBCommandInterpreter.cpp:180
lldb_private::CommandInterpreter::IsActive
bool IsActive()
CommandPluginInterfaceImplementation::m_backend
std::shared_ptr< lldb::SBCommandPluginInterface > m_backend
Definition: SBCommandInterpreter.cpp:75
CommandPluginInterfaceImplementation::CommandPluginInterfaceImplementation
CommandPluginInterfaceImplementation(CommandInterpreter &interpreter, const char *name, lldb::SBCommandPluginInterface *backend, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0, const char *auto_repeat_command="")
Definition: SBCommandInterpreter.cpp:37
lldb::SBCommandInterpreter::operator=
const lldb::SBCommandInterpreter & operator=(const lldb::SBCommandInterpreter &rhs)
Definition: SBCommandInterpreter.cpp:92
lldb_private::CommandReturnObject::SetInteractive
void SetInteractive(bool b)
Definition: CommandReturnObject.cpp:158
SBExecutionContext.h
lldb::SBCommand::SetHelp
void SetHelp(const char *)
Definition: SBCommandInterpreter.cpp:601
CommandPluginInterfaceImplementation::m_auto_repeat_command
llvm::Optional< std::string > m_auto_repeat_command
Definition: SBCommandInterpreter.cpp:76
lldb::SBCommandInterpreter::GetArgumentDescriptionAsCString
static const char * GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type)
Definition: SBCommandInterpreter.cpp:489
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
CommandPluginInterfaceImplementation
Definition: SBCommandInterpreter.cpp:35
lldb::SBFileSpec
Definition: SBFileSpec.h:16
SBEvent.h
lldb_private::Args::GetArgumentVector
char ** GetArgumentVector()
Gets the argument vector.
Definition: Args.cpp:265
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Debugger::GetSelectedTarget
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:216
lldb::SBCommand::SBCommand
SBCommand()
Definition: SBCommandInterpreter.cpp:567
SBCommandReturnObject.h
lldb::CommandOverrideCallback
bool(* CommandOverrideCallback)(void *baton, const char **argv)
Definition: lldb-types.h:71
lldb::SBCommandInterpreter::reset
void reset(lldb_private::CommandInterpreter *)
Definition: SBCommandInterpreter.cpp:415
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:100
CommandInterpreter.h
lldb::SBBroadcaster
Definition: SBBroadcaster.h:16
SBProcess.h
SBCommandInterpreter.h
lldb::SBCommandInterpreter::HandleCompletionWithDescriptions
int HandleCompletionWithDescriptions(const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, lldb::SBStringList &matches, lldb::SBStringList &descriptions)
Definition: SBCommandInterpreter.cpp:220
lldb::SBCommandInterpreterRunOptions
Definition: SBCommandInterpreterRunOptions.h:23
lldb::SBCommandInterpreter::SetPromptOnQuit
void SetPromptOnQuit(bool b)
Definition: SBCommandInterpreter.cpp:365
lldb_private::CompletionResult
Definition: CompletionRequest.h:38
lldb::SBStream
Definition: SBStream.h:18
lldb_private::CompletionResult::GetNumberOfResults
std::size_t GetNumberOfResults() const
Definition: CompletionRequest.h:90
lldb::SBCommandInterpreter::EventIsCommandInterpreterEvent
static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event)
Definition: SBCommandInterpreter.cpp:496
lldb::SBCommandInterpreter::SetCommandOverrideCallback
bool SetCommandOverrideCallback(const char *command_name, lldb::CommandOverrideCallback callback, void *baton)
Definition: SBCommandInterpreter.cpp:504
lldb::SBCommand::GetName
const char * GetName()
Definition: SBCommandInterpreter.cpp:581
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
SBTarget.h
lldb_private::Args::ArgEntry::IsQuoted
bool IsQuoted() const
Returns true if this argument was quoted in any way.
Definition: Args.h:54
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb_private::CompletionResult::GetDescriptions
void GetDescriptions(StringList &descriptions) const
Adds all collected completion descriptions to the given list.
Definition: CompletionRequest.cpp:77
lldb::SBCommandInterpreter::m_opaque_ptr
lldb_private::CommandInterpreter * m_opaque_ptr
Definition: SBCommandInterpreter.h:276
lldb
Definition: SBAddress.h:15
lldb::SBCommand::IsValid
bool IsValid()
Definition: SBCommandInterpreter.cpp:571
lldb::SBStringList::AppendList
void AppendList(const char **strv, int strc)
Definition: SBStringList.cpp:69
lldb::SBStream::GetData
const char * GetData()
Definition: SBStream.cpp:43
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb::SBCommandInterpreter::IsActive
bool IsActive()
Return true if the command interpreter is the active IO handler.
Definition: SBCommandInterpreter.cpp:123