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