9#ifndef LLDB_INTERPRETER_COMMANDOBJECT_H
10#define LLDB_INTERPRETER_COMMANDOBJECT_H
36template <
typename ValueType>
38 const std::map<std::string, ValueType> &in_map, llvm::StringRef cmd_str,
42 const bool add_all = cmd_str.empty();
44 for (
auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) {
45 if (add_all || (iter->first.find(std::string(cmd_str), 0) == 0)) {
49 descriptions->AppendString(iter->second->GetHelp());
56template <
typename ValueType>
58 auto end = dict.end();
61 for (
auto pos = dict.begin(); pos != end; ++pos) {
62 size_t len = pos->first.size();
69class CommandObject :
public std::enable_shared_from_this<CommandObject> {
107 typedef std::vector<CommandArgumentData>
110 typedef std::map<std::string, lldb::CommandObjectSP>
CommandMap;
113 llvm::StringRef help =
"", llvm::StringRef syntax =
"",
127 virtual llvm::StringRef
GetHelp();
135 virtual void SetHelp(llvm::StringRef str);
192 return llvm::createStringError(llvm::inconvertibleErrorCode(),
193 "can only add commands to container commands");
207 static const ArgumentTableEntry *
243 static std::optional<ArgumentRepetitionType>
278 bool search_short_help =
true,
279 bool search_long_help =
true,
280 bool search_syntax =
true,
281 bool search_options =
true);
309 virtual std::optional<std::string>
352 return "invalid target, create a target using the 'target create' command";
356 return "Command requires a current process.";
360 return "Command requires a process which is currently stopped.";
364 return "Command requires a process, which is currently stopped.";
368 return "invalid frame, no registers, command requires a process which is "
369 "currently stopped.";
418 const char *help =
nullptr,
const char *syntax =
nullptr,
435 llvm::StringRef help =
"", llvm::StringRef syntax =
"",
A command line argument class.
virtual void DoExecute(Args &command, CommandReturnObject &result)=0
void Execute(const char *args_string, CommandReturnObject &result) override
bool WantsRawCommandString() override
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
~CommandObjectParsed() override=default
bool WantsRawCommandString() override
~CommandObjectRaw() override=default
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
void Execute(const char *args_string, CommandReturnObject &result) override
virtual void DoExecute(llvm::StringRef command, CommandReturnObject &result)=0
std::vector< CommandArgumentData > CommandArgumentEntry
CommandArgumentEntry * GetArgumentEntryAtIndex(int idx)
virtual void SetHelpLong(llvm::StringRef str)
virtual bool WantsRawCommandString()=0
void GenerateHelpText(CommandReturnObject &result)
lldb::CommandOverrideCallback m_deprecated_command_override_callback
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
std::unique_lock< std::recursive_mutex > m_api_locker
bool HasOverrideCallback() const
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
virtual const char * GetInvalidProcessDescription()
virtual llvm::StringRef GetHelpLong()
const Flags & GetFlags() const
The flags const accessor.
llvm::StringRef() ArgumentHelpCallbackFunction()
static const ArgumentTableEntry * FindArgumentDataByType(lldb::CommandArgumentType arg_type)
virtual lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd)
llvm::StringRef GetCommandName() const
void SetIsUserCommand(bool is_user)
static std::optional< ArgumentRepetitionType > ArgRepetitionFromString(llvm::StringRef string)
Target & GetDummyTarget()
static lldb::CommandArgumentType LookupArgumentName(llvm::StringRef arg_name)
void GetFormattedCommandArguments(Stream &str, uint32_t opt_set_mask=LLDB_OPT_SET_ALL)
bool HelpTextContainsWord(llvm::StringRef search_word, bool search_short_help=true, bool search_long_help=true, bool search_syntax=true, bool search_options=true)
virtual bool IsMultiwordObject()
ExecutionContext m_exe_ctx
virtual const char * GetInvalidTargetDescription()
std::vector< CommandArgumentEntry > m_arguments
virtual bool WantsCompletion()
lldb_private::CommandOverrideCallbackWithResult m_command_override_callback
void AddIDsArgumentData(IDType type)
CommandInterpreter & GetCommandInterpreter()
virtual bool IsDashDashCommand()
static const char * GetArgumentTypeAsCString(const lldb::CommandArgumentType arg_type)
virtual void Execute(const char *args_string, CommandReturnObject &result)=0
CommandInterpreter & m_interpreter
Thread * GetDefaultThread()
virtual const char * GetInvalidRegContextDescription()
virtual bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj)
virtual std::optional< std::string > GetRepeatCommand(Args ¤t_command_args, uint32_t index)
Get the command that appropriate for a "repeat" of the current command.
virtual CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr)
void SetOverrideCallback(lldb::CommandOverrideCallback callback, void *baton)
std::string m_cmd_help_long
virtual CommandObjectMultiword * GetAsMultiwordCommand()
virtual Options * GetOptions()
void SetSyntax(llvm::StringRef str)
static const char * GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type)
virtual llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj, bool can_replace)
virtual const char * GetInvalidFrameDescription()
virtual ~CommandObject()=default
void SetCommandName(llvm::StringRef name)
Flags & GetFlags()
The flags accessor.
int GetNumArgumentEntries()
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The default version handles argument definitions that have only one argument type,...
bool ParseOptions(Args &args, CommandReturnObject &result)
void FormatLongHelpText(Stream &output_strm, llvm::StringRef long_help)
virtual llvm::StringRef GetSyntax()
virtual const char * GetInvalidThreadDescription()
void * m_command_override_baton
static void GetArgumentHelp(Stream &str, lldb::CommandArgumentType arg_type, CommandInterpreter &interpreter)
void SetOverrideCallback(lldb_private::CommandOverrideCallbackWithResult callback, void *baton)
virtual bool IsRemovable() const
bool CheckRequirements(CommandReturnObject &result)
Check the command to make sure anything required by this command is available.
virtual void HandleCompletion(CompletionRequest &request)
This default version handles calling option argument completions and then calls HandleArgumentComplet...
static bool IsPairType(ArgumentRepetitionType arg_repeat_type)
std::map< std::string, lldb::CommandObjectSP > CommandMap
static const char * GetArgumentName(lldb::CommandArgumentType arg_type)
virtual llvm::StringRef GetHelp()
std::string m_cmd_help_short
bool InvokeOverrideCallback(const char **argv, CommandReturnObject &result)
virtual void SetHelp(llvm::StringRef str)
virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr)
"lldb/Utility/ArgCompletionRequest.h"
A class to manage flag bits.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A command line option parsing protocol class.
A stream class that can stream formatted output to a file.
void AppendString(const std::string &s)
A class that represents a running process on the host machine.
int AddNamesMatchingPartialString(const std::map< std::string, ValueType > &in_map, llvm::StringRef cmd_str, StringList &matches, StringList *descriptions=nullptr)
std::vector< OptionArgElement > OptionElementVector
bool(* CommandOverrideCallbackWithResult)(void *baton, const char **argv, lldb_private::CommandReturnObject &result)
size_t FindLongestCommandWord(std::map< std::string, ValueType > &dict)
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
bool(* CommandOverrideCallback)(void *baton, const char **argv)
llvm::StringRef operator()() const
ArgumentHelpCallbackFunction * help_callback
Entries in the main argument information table.
lldb::CompletionType completion_type
lldb::CommandArgumentType arg_type
OptionEnumValues enum_values
ArgumentHelpCallback help_function
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
CommandArgumentData(lldb::CommandArgumentType type=lldb::eArgTypeNone, ArgumentRepetitionType repetition=eArgRepeatPlain, uint32_t opt_set=LLDB_OPT_SET_ALL)
lldb::CommandArgumentType arg_type
uint32_t arg_opt_set_association
This arg might be associated only with some particular option set(s).