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 void 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 m_backend->DoExecute(debugger_sb, command.GetArgumentVector(), sb_return);
78 }
79 std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
80 std::optional<std::string> m_auto_repeat_command;
81};
82} // namespace lldb_private
83
86}
87
89 : m_opaque_ptr(interpreter) {
90 LLDB_INSTRUMENT_VA(this, interpreter);
91}
92
94 : m_opaque_ptr(rhs.m_opaque_ptr) {
95 LLDB_INSTRUMENT_VA(this, rhs);
96}
97
99
102 LLDB_INSTRUMENT_VA(this, rhs);
103
105 return *this;
106}
107
109 LLDB_INSTRUMENT_VA(this);
110 return this->operator bool();
111}
112SBCommandInterpreter::operator bool() const {
113 LLDB_INSTRUMENT_VA(this);
114
115 return m_opaque_ptr != nullptr;
116}
117
119 LLDB_INSTRUMENT_VA(this, cmd);
120
121 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd)
122 : false);
123}
124
126 LLDB_INSTRUMENT_VA(this, cmd);
127
128 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->UserCommandExists(cmd)
129 : false);
130}
131
133 LLDB_INSTRUMENT_VA(this, cmd);
134
135 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd)
136 : false);
137}
138
140 LLDB_INSTRUMENT_VA(this);
141
142 return (IsValid() ? m_opaque_ptr->IsActive() : false);
143}
144
146 LLDB_INSTRUMENT_VA(this);
147
148 return (IsValid() ? m_opaque_ptr->GetDebugger().InterruptRequested() : false);
149}
150
152 LLDB_INSTRUMENT_VA(this);
153
154 return (IsValid() ? m_opaque_ptr->InterruptCommand() : false);
155}
156
158 LLDB_INSTRUMENT_VA(this, ch);
159
160 if (!IsValid())
161 return nullptr;
162
163 return ConstString(
165 .GetCString();
166}
167
169SBCommandInterpreter::HandleCommand(const char *command_line,
170 SBCommandReturnObject &result,
171 bool add_to_history) {
172 LLDB_INSTRUMENT_VA(this, command_line, result, add_to_history);
173
174 SBExecutionContext sb_exe_ctx;
175 return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
176}
177
179 const char *command_line, SBExecutionContext &override_context,
180 SBCommandReturnObject &result, bool add_to_history) {
181 LLDB_INSTRUMENT_VA(this, command_line, override_context, result,
182 add_to_history);
183
184 result.Clear();
185 if (command_line && IsValid()) {
186 result.ref().SetInteractive(false);
187 auto do_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
188 if (override_context.get())
189 m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
190 override_context.get()->Lock(true),
191 result.ref());
192 else
193 m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
194 result.ref());
195 } else {
196 result->AppendError(
197 "SBCommandInterpreter or the command line is not valid");
198 }
199
200 return result.GetStatus();
201}
202
204 lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context,
207 LLDB_INSTRUMENT_VA(this, file, override_context, options, result);
208
209 if (!IsValid()) {
210 result->AppendError("SBCommandInterpreter is not valid.");
211 return;
212 }
213
214 if (!file.IsValid()) {
215 SBStream s;
216 file.GetDescription(s);
217 result->AppendErrorWithFormat("File is not valid: %s.", s.GetData());
218 }
219
220 FileSpec tmp_spec = file.ref();
221 if (override_context.get())
223 override_context.get()->Lock(true),
224 options.ref(),
225 result.ref());
226
227 else
228 m_opaque_ptr->HandleCommandsFromFile(tmp_spec, options.ref(), result.ref());
229}
230
232 const char *current_line, const char *cursor, const char *last_char,
233 int match_start_point, int max_return_elements, SBStringList &matches) {
234 LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
235 max_return_elements, matches);
236
237 SBStringList dummy_descriptions;
239 current_line, cursor, last_char, match_start_point, max_return_elements,
240 matches, dummy_descriptions);
241}
242
244 const char *current_line, const char *cursor, const char *last_char,
245 int match_start_point, int max_return_elements, SBStringList &matches,
246 SBStringList &descriptions) {
247 LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
248 max_return_elements, matches, descriptions);
249
250 // Sanity check the arguments that are passed in: cursor & last_char have to
251 // be within the current_line.
252 if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
253 return 0;
254
255 if (cursor < current_line || last_char < current_line)
256 return 0;
257
258 size_t current_line_size = strlen(current_line);
259 if (cursor - current_line > static_cast<ptrdiff_t>(current_line_size) ||
260 last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
261 return 0;
262
263 if (!IsValid())
264 return 0;
265
266 lldb_private::StringList lldb_matches, lldb_descriptions;
267 CompletionResult result;
268 CompletionRequest request(current_line, cursor - current_line, result);
270 result.GetMatches(lldb_matches);
271 result.GetDescriptions(lldb_descriptions);
272
273 // Make the result array indexed from 1 again by adding the 'common prefix'
274 // of all completions as element 0. This is done to emulate the old API.
275 if (request.GetParsedLine().GetArgumentCount() == 0) {
276 // If we got an empty string, insert nothing.
277 lldb_matches.InsertStringAtIndex(0, "");
278 lldb_descriptions.InsertStringAtIndex(0, "");
279 } else {
280 // Now figure out if there is a common substring, and if so put that in
281 // element 0, otherwise put an empty string in element 0.
282 std::string command_partial_str = request.GetCursorArgumentPrefix().str();
283
284 std::string common_prefix = lldb_matches.LongestCommonPrefix();
285 const size_t partial_name_len = command_partial_str.size();
286 common_prefix.erase(0, partial_name_len);
287
288 // If we matched a unique single command, add a space... Only do this if
289 // the completer told us this was a complete word, however...
290 if (lldb_matches.GetSize() == 1) {
291 char quote_char = request.GetParsedArg().GetQuoteChar();
292 common_prefix =
293 Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
294 if (request.GetParsedArg().IsQuoted())
295 common_prefix.push_back(quote_char);
296 common_prefix.push_back(' ');
297 }
298 lldb_matches.InsertStringAtIndex(0, common_prefix.c_str());
299 lldb_descriptions.InsertStringAtIndex(0, "");
300 }
301
302 SBStringList temp_matches_list(&lldb_matches);
303 matches.AppendList(temp_matches_list);
304 SBStringList temp_descriptions_list(&lldb_descriptions);
305 descriptions.AppendList(temp_descriptions_list);
306 return result.GetNumberOfResults();
307}
308
310 const char *current_line, uint32_t cursor_pos, int match_start_point,
311 int max_return_elements, SBStringList &matches,
312 SBStringList &descriptions) {
313 LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
314 max_return_elements, matches, descriptions);
315
316 const char *cursor = current_line + cursor_pos;
317 const char *last_char = current_line + strlen(current_line);
319 current_line, cursor, last_char, match_start_point, max_return_elements,
320 matches, descriptions);
321}
322
323int SBCommandInterpreter::HandleCompletion(const char *current_line,
324 uint32_t cursor_pos,
325 int match_start_point,
326 int max_return_elements,
327 lldb::SBStringList &matches) {
328 LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
329 max_return_elements, matches);
330
331 const char *cursor = current_line + cursor_pos;
332 const char *last_char = current_line + strlen(current_line);
333 return HandleCompletion(current_line, cursor, last_char, match_start_point,
334 max_return_elements, matches);
335}
336
338 LLDB_INSTRUMENT_VA(this);
339
340 return (IsValid() ? m_opaque_ptr->HasCommands() : false);
341}
342
344 LLDB_INSTRUMENT_VA(this);
345
346 return (IsValid() ? m_opaque_ptr->HasAliases() : false);
347}
348
350 LLDB_INSTRUMENT_VA(this);
351
352 return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
353}
354
356 LLDB_INSTRUMENT_VA(this);
357
358 return (IsValid() ? m_opaque_ptr->IsInteractive() : false);
359}
360
362 LLDB_INSTRUMENT_VA(this);
363
364 SBProcess sb_process;
365 ProcessSP process_sp;
366 if (IsValid()) {
368 if (target_sp) {
369 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
370 process_sp = target_sp->GetProcessSP();
371 sb_process.SetSP(process_sp);
372 }
373 }
374
375 return sb_process;
376}
377
379 LLDB_INSTRUMENT_VA(this);
380
381 SBDebugger sb_debugger;
382 if (IsValid())
383 sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
384
385 return sb_debugger;
386}
387
389 LLDB_INSTRUMENT_VA(this);
390
391 return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
392}
393
395 LLDB_INSTRUMENT_VA(this, b);
396
397 if (IsValid())
399}
400
402 LLDB_INSTRUMENT_VA(this, allow);
403
404 if (m_opaque_ptr)
406}
407
409 LLDB_INSTRUMENT_VA(this);
410
411 bool exited = false;
412 if (m_opaque_ptr)
414 return exited;
415}
416
418 LLDB_INSTRUMENT_VA(this);
419
420 bool exited = false;
421 return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
422}
423
424void SBCommandInterpreter::ResolveCommand(const char *command_line,
425 SBCommandReturnObject &result) {
426 LLDB_INSTRUMENT_VA(this, command_line, result);
427
428 result.Clear();
429 if (command_line && IsValid()) {
430 m_opaque_ptr->ResolveCommand(command_line, result.ref());
431 } else {
432 result->AppendError(
433 "SBCommandInterpreter or the command line is not valid");
434 }
435}
436
438
440 assert(m_opaque_ptr);
441 return *m_opaque_ptr;
442}
443
446 m_opaque_ptr = interpreter;
447}
448
450 SBCommandReturnObject &result) {
451 LLDB_INSTRUMENT_VA(this, result);
452
453 result.Clear();
454 if (IsValid()) {
456 std::unique_lock<std::recursive_mutex> lock;
457 if (target_sp)
458 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
460 } else {
461 result->AppendError("SBCommandInterpreter is not valid");
462 }
463}
464
466 SBCommandReturnObject &result) {
467 LLDB_INSTRUMENT_VA(this, result);
468
469 SourceInitFileInHomeDirectory(result, /*is_repl=*/false);
470}
471
473 SBCommandReturnObject &result, bool is_repl) {
474 LLDB_INSTRUMENT_VA(this, result, is_repl);
475
476 result.Clear();
477 if (IsValid()) {
479 std::unique_lock<std::recursive_mutex> lock;
480 if (target_sp)
481 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
482 m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
483 } else {
484 result->AppendError("SBCommandInterpreter is not valid");
485 }
486}
487
489 SBCommandReturnObject &result) {
490 LLDB_INSTRUMENT_VA(this, result);
491
492 result.Clear();
493 if (IsValid()) {
495 std::unique_lock<std::recursive_mutex> lock;
496 if (target_sp)
497 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
499 } else {
500 result->AppendError("SBCommandInterpreter is not valid");
501 }
502}
503
505 LLDB_INSTRUMENT_VA(this);
506
507 SBBroadcaster broadcaster(m_opaque_ptr, false);
508
509 return broadcaster;
510}
511
514
516}
517
519 const lldb::CommandArgumentType arg_type) {
520 LLDB_INSTRUMENT_VA(arg_type);
521
523 .GetCString();
524}
525
527 const lldb::CommandArgumentType arg_type) {
528 LLDB_INSTRUMENT_VA(arg_type);
529
531 .GetCString();
532}
533
535 const lldb::SBEvent &event) {
536 LLDB_INSTRUMENT_VA(event);
537
538 return event.GetBroadcasterClass() ==
540}
541
543 const char *command_name, lldb::CommandOverrideCallback callback,
544 void *baton) {
545 LLDB_INSTRUMENT_VA(this, command_name, callback, baton);
546
547 if (command_name && command_name[0] && IsValid()) {
548 llvm::StringRef command_name_str = command_name;
549 CommandObject *cmd_obj =
550 m_opaque_ptr->GetCommandObjectForCommand(command_name_str);
551 if (cmd_obj) {
552 assert(command_name_str.empty());
553 cmd_obj->SetOverrideCallback(callback, baton);
554 return true;
555 }
556 }
557 return false;
558}
559
561 LLDB_INSTRUMENT_VA(this);
562
563 SBStructuredData data;
564 if (!IsValid())
565 return data;
566
567 std::string json_str =
568 llvm::formatv("{0:2}", m_opaque_ptr->GetStatistics()).str();
569 data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
570 return data;
571}
572
574 const char *help) {
575 LLDB_INSTRUMENT_VA(this, name, help);
576
577 lldb::CommandObjectSP new_command_sp(
578 new CommandObjectMultiword(*m_opaque_ptr, name, help));
579 new_command_sp->GetAsMultiwordCommand()->SetRemovable(true);
580 Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
581 if (add_error.Success())
582 return lldb::SBCommand(new_command_sp);
583 return lldb::SBCommand();
584}
585
587 const char *name, lldb::SBCommandPluginInterface *impl, const char *help) {
588 LLDB_INSTRUMENT_VA(this, name, impl, help);
589
590 return AddCommand(name, impl, help, /*syntax=*/nullptr,
591 /*auto_repeat_command=*/"");
592}
593
597 const char *help, const char *syntax) {
598 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
599 return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
600}
601
603 const char *name, lldb::SBCommandPluginInterface *impl, const char *help,
604 const char *syntax, const char *auto_repeat_command) {
605 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
606
607 lldb::CommandObjectSP new_command_sp;
608 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
609 *m_opaque_ptr, name, impl, help, syntax, /*flags=*/0,
610 auto_repeat_command);
611
612 Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
613 if (add_error.Success())
614 return lldb::SBCommand(new_command_sp);
615 return lldb::SBCommand();
616}
617
619
620SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {}
621
623 LLDB_INSTRUMENT_VA(this);
624 return this->operator bool();
625}
626SBCommand::operator bool() const {
627 LLDB_INSTRUMENT_VA(this);
628
629 return m_opaque_sp.get() != nullptr;
630}
631
632const char *SBCommand::GetName() {
633 LLDB_INSTRUMENT_VA(this);
634
635 return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
636}
637
638const char *SBCommand::GetHelp() {
639 LLDB_INSTRUMENT_VA(this);
640
641 return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
642 : nullptr);
643}
644
646 LLDB_INSTRUMENT_VA(this);
647
648 return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
649 : nullptr);
650}
651
652void SBCommand::SetHelp(const char *help) {
653 LLDB_INSTRUMENT_VA(this, help);
654
655 if (IsValid())
656 m_opaque_sp->SetHelp(help);
657}
658
659void SBCommand::SetHelpLong(const char *help) {
660 LLDB_INSTRUMENT_VA(this, help);
661
662 if (IsValid())
663 m_opaque_sp->SetHelpLong(help);
664}
665
667 const char *help) {
668 LLDB_INSTRUMENT_VA(this, name, help);
669
670 if (!IsValid())
671 return lldb::SBCommand();
672 if (!m_opaque_sp->IsMultiwordObject())
673 return lldb::SBCommand();
675 m_opaque_sp->GetCommandInterpreter(), name, help);
676 new_command->SetRemovable(true);
677 lldb::CommandObjectSP new_command_sp(new_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
685 const char *help) {
686 LLDB_INSTRUMENT_VA(this, name, impl, help);
687 return AddCommand(name, impl, help, /*syntax=*/nullptr,
688 /*auto_repeat_command=*/"");
689}
690
693 const char *help, const char *syntax) {
694 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
695 return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
696}
697
700 const char *help, const char *syntax,
701 const char *auto_repeat_command) {
702 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
703
704 if (!IsValid())
705 return lldb::SBCommand();
706 if (!m_opaque_sp->IsMultiwordObject())
707 return lldb::SBCommand();
708 lldb::CommandObjectSP new_command_sp;
709 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
710 m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
711 /*flags=*/0, auto_repeat_command);
712 if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
713 return lldb::SBCommand(new_command_sp);
714 return lldb::SBCommand();
715}
716
718 LLDB_INSTRUMENT_VA(this);
719
720 return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
721}
722
723void SBCommand::SetFlags(uint32_t flags) {
724 LLDB_INSTRUMENT_VA(this, flags);
725
726 if (IsValid())
727 m_opaque_sp->GetFlags().Set(flags);
728}
#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)
StructuredDataImplUP m_impl_up
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:603
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,...
void 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:188
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:214
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:193
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:437
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1160
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:279
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
static ObjectSP ParseJSON(llvm::StringRef json_text)
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:325
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
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:436
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