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