41 const char *help =
nullptr,
42 const char *syntax =
nullptr,
44 const char *auto_repeat_command =
"")
48 auto_repeat_command ==
nullptr
50 : std::optional<std::string>(auto_repeat_command);
80 std::shared_ptr<lldb::SBCommandPluginInterface>
m_backend;
85 : m_opaque_ptr(interpreter) {
90 : m_opaque_ptr(rhs.m_opaque_ptr) {
106 return this->
operator bool();
108SBCommandInterpreter::operator bool()
const {
111 return m_opaque_ptr !=
nullptr;
166 bool add_to_history) {
170 return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
180 if (command_line &&
IsValid()) {
183 if (override_context.
get())
185 override_context.
get()->
Lock(
true),
192 "SBCommandInterpreter or the command line is not valid");
205 result->
AppendError(
"SBCommandInterpreter is not valid.");
216 if (override_context.
get())
218 override_context.
get()->
Lock(
true),
227 const char *current_line,
const char *cursor,
const char *last_char,
228 int match_start_point,
int max_return_elements,
SBStringList &matches) {
230 max_return_elements, matches);
234 current_line, cursor, last_char, match_start_point, max_return_elements,
235 matches, dummy_descriptions);
239 const char *current_line,
const char *cursor,
const char *last_char,
240 int match_start_point,
int max_return_elements,
SBStringList &matches,
243 max_return_elements, matches, descriptions);
247 if (current_line ==
nullptr || cursor ==
nullptr || last_char ==
nullptr)
250 if (cursor < current_line || last_char < current_line)
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))
280 const size_t partial_name_len = command_partial_str.size();
281 common_prefix.erase(0, partial_name_len);
285 if (lldb_matches.
GetSize() == 1) {
290 common_prefix.push_back(quote_char);
291 common_prefix.push_back(
' ');
299 SBStringList temp_descriptions_list(&lldb_descriptions);
300 descriptions.
AppendList(temp_descriptions_list);
305 const char *current_line,
uint32_t cursor_pos,
int match_start_point,
309 max_return_elements, matches, descriptions);
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);
320 int match_start_point,
321 int max_return_elements,
324 max_return_elements, matches);
326 const char *cursor = current_line + cursor_pos;
327 const char *last_char = current_line + strlen(current_line);
329 max_return_elements, matches);
360 ProcessSP process_sp;
364 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
365 process_sp = target_sp->GetProcessSP();
366 sb_process.
SetSP(process_sp);
424 if (command_line &&
IsValid()) {
428 "SBCommandInterpreter or the command line is not valid");
451 std::unique_lock<std::recursive_mutex> lock;
453 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
456 result->
AppendError(
"SBCommandInterpreter is not valid");
474 std::unique_lock<std::recursive_mutex> lock;
476 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
479 result->
AppendError(
"SBCommandInterpreter is not valid");
490 std::unique_lock<std::recursive_mutex> lock;
492 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
495 result->
AppendError(
"SBCommandInterpreter is not valid");
531 return event.GetBroadcasterClass() ==
540 if (command_name && command_name[0] &&
IsValid()) {
541 llvm::StringRef command_name_str = command_name;
545 assert(command_name_str.empty());
557 lldb::CommandObjectSP new_command_sp(
559 new_command_sp->GetAsMultiwordCommand()->SetRemovable(
true);
577 const char *help,
const char *syntax) {
579 return AddCommand(name, impl, help, syntax,
"");
584 const char *syntax,
const char *auto_repeat_command) {
587 lldb::CommandObjectSP new_command_sp;
588 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
590 auto_repeat_command);
604 return this->
operator bool();
606SBCommand::operator bool()
const {
609 return m_opaque_sp.get() !=
nullptr;
657 lldb::CommandObjectSP new_command_sp(new_command);
658 if (new_command_sp &&
m_opaque_sp->LoadSubCommand(name, new_command_sp))
673 const char *help,
const char *syntax) {
675 return AddCommand(name, impl, help, syntax,
"");
680 const char *help,
const char *syntax,
681 const char *auto_repeat_command) {
688 lldb::CommandObjectSP new_command_sp;
689 new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
690 m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
691 0, auto_repeat_command);
692 if (new_command_sp &&
m_opaque_sp->LoadSubCommand(name, new_command_sp))
#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="")
bool IsRemovable() const override
std::optional< std::string > m_auto_repeat_command
std::optional< std::string > GetRepeatCommand(Args ¤t_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::SBProcess GetProcess()
lldb_private::CommandInterpreter & ref()
void ResolveCommand(const char *command_line, SBCommandReturnObject &result)
Resolve the command just as HandleCommand would, expanding abbreviations and aliases.
lldb::SBDebugger GetDebugger()
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)
void SetPromptOnQuit(bool b)
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::ReturnStatus GetStatus()
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
const lldb_private::FileSpec & ref() const
bool GetDescription(lldb::SBStream &description) const
void SetSP(const lldb::ProcessSP &process_sp)
void AppendList(const char **strv, int strc)
A command line argument class.
char ** GetArgumentVector()
Gets the argument vector.
static std::string EscapeLLDBCommandArgument(const std::string &arg, char quote_char)
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
void SetPromptOnQuit(bool enable)
void SourceInitFileHome(CommandReturnObject &result, bool is_repl)
We will first see if there is an application specific ".lldbinit" file whose name is "~/....
bool HasAliasOptions() const
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.
bool GetPromptOnQuit() const
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)
void SetRemovable(bool removable)
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 SetInteractive(bool b)
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.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
lldb::TargetSP GetSelectedTarget()
bool InterruptRequested()
This is the correct way to query the state of Interruption.
ConstString GetTopIOHandlerControlSequence(char ch)
ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const
Create an ExecutionContext object from this object.
bool Success() const
Test for success condition.
void InsertStringAtIndex(size_t idx, const std::string &str)
std::string LongestCommonPrefix()
A class that represents a running process on the host machine.
ReturnStatus
Command Return Status Types.
bool(* CommandOverrideCallback)(void *baton, const char **argv)
bool IsQuoted() const
Returns true if this argument was quoted in any way.
char GetQuoteChar() const
Used to build individual command argument lists.