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