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
10#include "lldb/lldb-types.h"
11
15#include "lldb/Target/Target.h"
18
23#include "lldb/API/SBEvent.h"
25#include "lldb/API/SBListener.h"
26#include "lldb/API/SBProcess.h"
27#include "lldb/API/SBStream.h"
29#include "lldb/API/SBTarget.h"
30
31#include <memory>
32#include <optional>
33
34using namespace lldb;
35using namespace lldb_private;
36
37namespace lldb_private {
39public:
41 const char *name,
43 const char *help = nullptr,
44 const char *syntax = nullptr,
45 uint32_t flags = 0,
46 const char *auto_repeat_command = "")
47 : CommandObjectParsed(interpreter, name, help, syntax, flags),
48 m_backend(backend) {
50 auto_repeat_command == nullptr
51 ? std::nullopt
52 : std::optional<std::string>(auto_repeat_command);
53 // We don't know whether any given command coming from this interface takes
54 // arguments or not so here we're just disabling the basic args check.
56 m_arguments.push_back({none_arg});
57 }
58
59 bool IsRemovable() const override { return true; }
60
61 /// More documentation is available in lldb::CommandObject::GetRepeatCommand,
62 /// but in short, if std::nullopt is returned, the previous command will be
63 /// repeated, and if an empty string is returned, no commands will be
64 /// executed.
65 std::optional<std::string> GetRepeatCommand(Args &current_command_args,
66 uint32_t index) override {
68 return std::nullopt;
69 else
71 }
72
73protected:
74 void DoExecute(Args &command, CommandReturnObject &result) override {
75 SBCommandReturnObject sb_return(result);
76 SBCommandInterpreter sb_interpreter(&m_interpreter);
77 SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
78 m_backend->DoExecute(debugger_sb, command.GetArgumentVector(), sb_return);
79 }
80 std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
81 std::optional<std::string> m_auto_repeat_command;
82};
83} // namespace lldb_private
84
87}
88
90 : m_opaque_ptr(interpreter) {
91 LLDB_INSTRUMENT_VA(this, interpreter);
92}
93
95 : m_opaque_ptr(rhs.m_opaque_ptr) {
96 LLDB_INSTRUMENT_VA(this, rhs);
97}
98
100
103 LLDB_INSTRUMENT_VA(this, rhs);
104
106 return *this;
107}
108
110 LLDB_INSTRUMENT_VA(this);
111 return this->operator bool();
112}
113SBCommandInterpreter::operator bool() const {
114 LLDB_INSTRUMENT_VA(this);
115
116 return m_opaque_ptr != nullptr;
117}
118
120 LLDB_INSTRUMENT_VA(this, cmd);
121
122 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd)
123 : false);
124}
125
127 LLDB_INSTRUMENT_VA(this, cmd);
128
129 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->UserCommandExists(cmd)
130 : false);
131}
132
134 LLDB_INSTRUMENT_VA(this, cmd);
135
136 return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd)
137 : false);
138}
139
141 LLDB_INSTRUMENT_VA(this);
142
143 return (IsValid() ? m_opaque_ptr->IsActive() : false);
144}
145
147 LLDB_INSTRUMENT_VA(this);
148
149 return (IsValid() ? m_opaque_ptr->GetDebugger().InterruptRequested() : false);
150}
151
153 LLDB_INSTRUMENT_VA(this);
154
155 return (IsValid() ? m_opaque_ptr->InterruptCommand() : false);
156}
157
159 LLDB_INSTRUMENT_VA(this, ch);
160
161 if (!IsValid())
162 return nullptr;
163
164 return ConstString(
166 .GetCString();
167}
168
170SBCommandInterpreter::HandleCommand(const char *command_line,
171 SBCommandReturnObject &result,
172 bool add_to_history) {
173 LLDB_INSTRUMENT_VA(this, command_line, result, add_to_history);
174
175 SBExecutionContext sb_exe_ctx;
176 return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
177}
178
180 const char *command_line, SBExecutionContext &override_context,
181 SBCommandReturnObject &result, bool add_to_history) {
182 LLDB_INSTRUMENT_VA(this, command_line, override_context, result,
183 add_to_history);
184
185 result.Clear();
186 if (command_line && IsValid()) {
187 result.ref().SetInteractive(false);
188 auto do_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
189 if (override_context.get())
190 m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
191 override_context.get()->Lock(true),
192 result.ref());
193 else
194 m_opaque_ptr->HandleCommand(command_line, do_add_to_history,
195 result.ref());
196 } else {
197 result->AppendError(
198 "SBCommandInterpreter or the command line is not valid");
199 }
200
201 return result.GetStatus();
202}
203
205 lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context,
208 LLDB_INSTRUMENT_VA(this, file, override_context, options, result);
209
210 if (!IsValid()) {
211 result->AppendError("SBCommandInterpreter is not valid.");
212 return;
213 }
214
215 if (!file.IsValid()) {
216 SBStream s;
217 file.GetDescription(s);
218 result->AppendErrorWithFormat("File is not valid: %s.", s.GetData());
219 }
220
221 FileSpec tmp_spec = file.ref();
222 if (override_context.get())
224 override_context.get()->Lock(true),
225 options.ref(),
226 result.ref());
227
228 else
229 m_opaque_ptr->HandleCommandsFromFile(tmp_spec, options.ref(), result.ref());
230}
231
233 const char *current_line, const char *cursor, const char *last_char,
234 int match_start_point, int max_return_elements, SBStringList &matches) {
235 LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
236 max_return_elements, matches);
237
238 SBStringList dummy_descriptions;
240 current_line, cursor, last_char, match_start_point, max_return_elements,
241 matches, dummy_descriptions);
242}
243
245 const char *current_line, const char *cursor, const char *last_char,
246 int match_start_point, int max_return_elements, SBStringList &matches,
247 SBStringList &descriptions) {
248 LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point,
249 max_return_elements, matches, descriptions);
250
251 // Sanity check the arguments that are passed in: cursor & last_char have to
252 // be within the current_line.
253 if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
254 return 0;
255
256 if (cursor < current_line || last_char < current_line)
257 return 0;
258
259 size_t current_line_size = strlen(current_line);
260 if (cursor - current_line > static_cast<ptrdiff_t>(current_line_size) ||
261 last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
262 return 0;
263
264 if (!IsValid())
265 return 0;
266
267 lldb_private::StringList lldb_matches, lldb_descriptions;
268 CompletionResult result;
269 CompletionRequest request(current_line, cursor - current_line, result);
271 result.GetMatches(lldb_matches);
272 result.GetDescriptions(lldb_descriptions);
273
274 // Make the result array indexed from 1 again by adding the 'common prefix'
275 // of all completions as element 0. This is done to emulate the old API.
276 if (request.GetParsedLine().GetArgumentCount() == 0) {
277 // If we got an empty string, insert nothing.
278 lldb_matches.InsertStringAtIndex(0, "");
279 lldb_descriptions.InsertStringAtIndex(0, "");
280 } else {
281 // Now figure out if there is a common substring, and if so put that in
282 // element 0, otherwise put an empty string in element 0.
283 std::string command_partial_str = request.GetCursorArgumentPrefix().str();
284
285 std::string common_prefix = lldb_matches.LongestCommonPrefix();
286 const size_t partial_name_len = command_partial_str.size();
287 common_prefix.erase(0, partial_name_len);
288
289 // If we matched a unique single command, add a space... Only do this if
290 // the completer told us this was a complete word, however...
291 if (lldb_matches.GetSize() == 1) {
292 char quote_char = request.GetParsedArg().GetQuoteChar();
293 common_prefix =
294 Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
295 if (request.GetParsedArg().IsQuoted())
296 common_prefix.push_back(quote_char);
297 common_prefix.push_back(' ');
298 }
299 lldb_matches.InsertStringAtIndex(0, common_prefix.c_str());
300 lldb_descriptions.InsertStringAtIndex(0, "");
301 }
302
303 SBStringList temp_matches_list(&lldb_matches);
304 matches.AppendList(temp_matches_list);
305 SBStringList temp_descriptions_list(&lldb_descriptions);
306 descriptions.AppendList(temp_descriptions_list);
307 return result.GetNumberOfResults();
308}
309
311 const char *current_line, uint32_t cursor_pos, int match_start_point,
312 int max_return_elements, SBStringList &matches,
313 SBStringList &descriptions) {
314 LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
315 max_return_elements, matches, descriptions);
316
317 const char *cursor = current_line + cursor_pos;
318 const char *last_char = current_line + strlen(current_line);
320 current_line, cursor, last_char, match_start_point, max_return_elements,
321 matches, descriptions);
322}
323
324int SBCommandInterpreter::HandleCompletion(const char *current_line,
325 uint32_t cursor_pos,
326 int match_start_point,
327 int max_return_elements,
328 lldb::SBStringList &matches) {
329 LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point,
330 max_return_elements, matches);
331
332 const char *cursor = current_line + cursor_pos;
333 const char *last_char = current_line + strlen(current_line);
334 return HandleCompletion(current_line, cursor, last_char, match_start_point,
335 max_return_elements, matches);
336}
337
339 LLDB_INSTRUMENT_VA(this);
340
341 return (IsValid() ? m_opaque_ptr->HasCommands() : false);
342}
343
345 LLDB_INSTRUMENT_VA(this);
346
347 return (IsValid() ? m_opaque_ptr->HasAliases() : false);
348}
349
351 LLDB_INSTRUMENT_VA(this);
352
353 return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
354}
355
357 LLDB_INSTRUMENT_VA(this);
358
359 return (IsValid() ? m_opaque_ptr->IsInteractive() : false);
360}
361
363 LLDB_INSTRUMENT_VA(this);
364
365 SBProcess sb_process;
366 ProcessSP process_sp;
367 if (IsValid()) {
369 if (target_sp) {
370 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
371 process_sp = target_sp->GetProcessSP();
372 sb_process.SetSP(process_sp);
373 }
374 }
375
376 return sb_process;
377}
378
380 LLDB_INSTRUMENT_VA(this);
381
382 SBDebugger sb_debugger;
383 if (IsValid())
384 sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
385
386 return sb_debugger;
387}
388
390 LLDB_INSTRUMENT_VA(this);
391
392 return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
393}
394
396 LLDB_INSTRUMENT_VA(this, b);
397
398 if (IsValid())
400}
401
403 LLDB_INSTRUMENT_VA(this, allow);
404
405 if (m_opaque_ptr)
407}
408
410 LLDB_INSTRUMENT_VA(this);
411
412 bool exited = false;
413 if (m_opaque_ptr)
415 return exited;
416}
417
419 LLDB_INSTRUMENT_VA(this);
420
421 bool exited = false;
422 return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
423}
424
425void SBCommandInterpreter::ResolveCommand(const char *command_line,
426 SBCommandReturnObject &result) {
427 LLDB_INSTRUMENT_VA(this, command_line, result);
428
429 result.Clear();
430 if (command_line && IsValid()) {
431 m_opaque_ptr->ResolveCommand(command_line, result.ref());
432 } else {
433 result->AppendError(
434 "SBCommandInterpreter or the command line is not valid");
435 }
436}
437
439
441 assert(m_opaque_ptr);
442 return *m_opaque_ptr;
443}
444
447 m_opaque_ptr = interpreter;
448}
449
451 SBCommandReturnObject &result) {
452 LLDB_INSTRUMENT_VA(this, result);
453
454 result.Clear();
455 if (IsValid()) {
457 std::unique_lock<std::recursive_mutex> lock;
458 if (target_sp)
459 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
461 } else {
462 result->AppendError("SBCommandInterpreter is not valid");
463 }
464}
465
467 SBCommandReturnObject &result) {
468 LLDB_INSTRUMENT_VA(this, result);
469
470 SourceInitFileInHomeDirectory(result, /*is_repl=*/false);
471}
472
474 SBCommandReturnObject &result, bool is_repl) {
475 LLDB_INSTRUMENT_VA(this, result, is_repl);
476
477 result.Clear();
478 if (IsValid()) {
480 std::unique_lock<std::recursive_mutex> lock;
481 if (target_sp)
482 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
483 m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
484 } else {
485 result->AppendError("SBCommandInterpreter is not valid");
486 }
487}
488
490 SBCommandReturnObject &result) {
491 LLDB_INSTRUMENT_VA(this, result);
492
493 result.Clear();
494 if (IsValid()) {
496 std::unique_lock<std::recursive_mutex> lock;
497 if (target_sp)
498 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
500 } else {
501 result->AppendError("SBCommandInterpreter is not valid");
502 }
503}
504
506 LLDB_INSTRUMENT_VA(this);
507
508 SBBroadcaster broadcaster(m_opaque_ptr, false);
509
510 return broadcaster;
511}
512
515
517 .AsCString();
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 LLDB_INSTRUMENT_VA(this);
564
565 SBStructuredData data;
566 if (!IsValid())
567 return data;
568
569 std::string json_str =
570 llvm::formatv("{0:2}", m_opaque_ptr->GetStatistics()).str();
571 data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
572 return data;
573}
574
576 LLDB_INSTRUMENT_VA(this);
577
578 SBStructuredData data;
579 if (IsValid())
580 // A deep copy is performed by `std::make_shared` on the
581 // `StructuredData::Array`, via its implicitly-declared copy constructor.
582 // This ensures thread-safety between the user changing the returned
583 // `SBStructuredData` and the `CommandInterpreter` changing its internal
584 // `m_transcript`.
585 data.m_impl_up->SetObjectSP(
586 std::make_shared<StructuredData::Array>(m_opaque_ptr->GetTranscript()));
587 return data;
588}
589
591 const char *help) {
592 LLDB_INSTRUMENT_VA(this, name, help);
593
594 lldb::CommandObjectSP new_command_sp(
595 new CommandObjectMultiword(*m_opaque_ptr, name, help));
596 new_command_sp->GetAsMultiwordCommand()->SetRemovable(true);
597 Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
598 if (add_error.Success())
599 return lldb::SBCommand(new_command_sp);
600 return lldb::SBCommand();
601}
602
604 const char *name, lldb::SBCommandPluginInterface *impl, const char *help) {
605 LLDB_INSTRUMENT_VA(this, name, impl, help);
606
607 return AddCommand(name, impl, help, /*syntax=*/nullptr,
608 /*auto_repeat_command=*/"");
609}
610
614 const char *help, const char *syntax) {
615 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
616 return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
617}
618
620 const char *name, lldb::SBCommandPluginInterface *impl, const char *help,
621 const char *syntax, const char *auto_repeat_command) {
622 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
623
624 lldb::CommandObjectSP new_command_sp;
625 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
626 *m_opaque_ptr, name, impl, help, syntax, /*flags=*/0,
627 auto_repeat_command);
628
629 Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true);
630 if (add_error.Success())
631 return lldb::SBCommand(new_command_sp);
632 return lldb::SBCommand();
633}
634
636
637SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {}
638
640 LLDB_INSTRUMENT_VA(this);
641 return this->operator bool();
642}
643SBCommand::operator bool() const {
644 LLDB_INSTRUMENT_VA(this);
645
646 return m_opaque_sp.get() != nullptr;
647}
648
649const char *SBCommand::GetName() {
650 LLDB_INSTRUMENT_VA(this);
651
652 return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
653}
654
655const char *SBCommand::GetHelp() {
656 LLDB_INSTRUMENT_VA(this);
657
658 return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
659 : nullptr);
660}
661
663 LLDB_INSTRUMENT_VA(this);
664
665 return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
666 : nullptr);
667}
668
669void SBCommand::SetHelp(const char *help) {
670 LLDB_INSTRUMENT_VA(this, help);
671
672 if (IsValid())
673 m_opaque_sp->SetHelp(help);
674}
675
676void SBCommand::SetHelpLong(const char *help) {
677 LLDB_INSTRUMENT_VA(this, help);
678
679 if (IsValid())
680 m_opaque_sp->SetHelpLong(help);
681}
682
684 const char *help) {
685 LLDB_INSTRUMENT_VA(this, name, help);
686
687 if (!IsValid())
688 return lldb::SBCommand();
689 if (!m_opaque_sp->IsMultiwordObject())
690 return lldb::SBCommand();
692 m_opaque_sp->GetCommandInterpreter(), name, help);
693 new_command->SetRemovable(true);
694 lldb::CommandObjectSP new_command_sp(new_command);
695 if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
696 return lldb::SBCommand(new_command_sp);
697 return lldb::SBCommand();
698}
699
702 const char *help) {
703 LLDB_INSTRUMENT_VA(this, name, impl, help);
704 return AddCommand(name, impl, help, /*syntax=*/nullptr,
705 /*auto_repeat_command=*/"");
706}
707
710 const char *help, const char *syntax) {
711 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax);
712 return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"");
713}
714
717 const char *help, const char *syntax,
718 const char *auto_repeat_command) {
719 LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command);
720
721 if (!IsValid())
722 return lldb::SBCommand();
723 if (!m_opaque_sp->IsMultiwordObject())
724 return lldb::SBCommand();
725 lldb::CommandObjectSP new_command_sp;
726 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
727 m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
728 /*flags=*/0, auto_repeat_command);
729 if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
730 return lldb::SBCommand(new_command_sp);
731 return lldb::SBCommand();
732}
733
735 LLDB_INSTRUMENT_VA(this);
736
737 return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
738}
739
740void SBCommand::SetFlags(uint32_t flags) {
741 LLDB_INSTRUMENT_VA(this, flags);
742
743 if (IsValid())
744 m_opaque_sp->GetFlags().Set(flags);
745}
#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...
SBStructuredData GetTranscript()
Returns a list of handled commands, output and error.
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:108
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 "~/....
static llvm::StringRef GetStaticBroadcasterClass()
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.
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)
const StructuredData::Array & GetTranscript() const
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:216
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:185
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:429
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1173
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:278
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: SBAddress.h:15
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:331
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
ReturnStatus
Command Return Status Types.
bool(* CommandOverrideCallback)(void *baton, const char **argv)
Definition: lldb-types.h:74
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
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