LLDB mainline
|
This command implements a lldb parsed scripted command. More...
Classes | |
class | CommandOptions |
Public Member Functions | |
CommandObjectScriptingObjectParsed (CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch) | |
~CommandObjectScriptingObjectParsed () override=default | |
Status | GetOptionsError () |
Status | GetArgsError () |
bool | WantsCompletion () override |
void | HandleArgumentCompletion (CompletionRequest &request, OptionElementVector &option_vec) override |
The default version handles argument definitions that have only one argument type, and use one of the argument types that have an entry in the CommonCompletions. | |
bool | IsRemovable () const override |
ScriptedCommandSynchronicity | GetSynchronicity () |
std::optional< std::string > | GetRepeatCommand (Args &args, uint32_t index) override |
Get the command that appropriate for a "repeat" of the current command. | |
llvm::StringRef | GetHelp () override |
llvm::StringRef | GetHelpLong () override |
Options * | GetOptions () override |
Public Member Functions inherited from lldb_private::CommandObjectParsed | |
CommandObjectParsed (CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0) | |
~CommandObjectParsed () override=default | |
void | Execute (const char *args_string, CommandReturnObject &result) override |
Public Member Functions inherited from lldb_private::CommandObject | |
CommandObject (CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0) | |
virtual | ~CommandObject ()=default |
CommandInterpreter & | GetCommandInterpreter () |
Debugger & | GetDebugger () |
virtual llvm::StringRef | GetHelp () |
virtual llvm::StringRef | GetHelpLong () |
virtual llvm::StringRef | GetSyntax () |
llvm::StringRef | GetCommandName () const |
virtual void | SetHelp (llvm::StringRef str) |
virtual void | SetHelpLong (llvm::StringRef str) |
void | SetSyntax (llvm::StringRef str) |
virtual bool | IsRemovable () const |
virtual bool | IsMultiwordObject () |
bool | IsUserCommand () |
void | SetIsUserCommand (bool is_user) |
virtual CommandObjectMultiword * | GetAsMultiwordCommand () |
virtual bool | IsAlias () |
virtual bool | IsDashDashCommand () |
virtual lldb::CommandObjectSP | GetSubcommandSP (llvm::StringRef sub_cmd, StringList *matches=nullptr) |
virtual lldb::CommandObjectSP | GetSubcommandSPExact (llvm::StringRef sub_cmd) |
virtual CommandObject * | GetSubcommandObject (llvm::StringRef sub_cmd, StringList *matches=nullptr) |
void | FormatLongHelpText (Stream &output_strm, llvm::StringRef long_help) |
void | GenerateHelpText (CommandReturnObject &result) |
virtual void | GenerateHelpText (Stream &result) |
virtual bool | LoadSubCommand (llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) |
virtual llvm::Error | LoadUserSubcommand (llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj, bool can_replace) |
virtual bool | WantsRawCommandString ()=0 |
virtual bool | WantsCompletion () |
virtual Options * | GetOptions () |
void | AddSimpleArgumentList (lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain) |
void | AddIDsArgumentData (IDType type) |
int | GetNumArgumentEntries () |
CommandArgumentEntry * | GetArgumentEntryAtIndex (int idx) |
void | GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask=LLDB_OPT_SET_ALL) |
bool | ParseOptions (Args &args, CommandReturnObject &result) |
void | SetCommandName (llvm::StringRef name) |
virtual void | HandleCompletion (CompletionRequest &request) |
This default version handles calling option argument completions and then calls HandleArgumentCompletion if the cursor is on an argument, not an option. | |
virtual void | HandleArgumentCompletion (CompletionRequest &request, OptionElementVector &opt_element_vector) |
The default version handles argument definitions that have only one argument type, and use one of the argument types that have an entry in the CommonCompletions. | |
bool | HelpTextContainsWord (llvm::StringRef search_word, bool search_short_help=true, bool search_long_help=true, bool search_syntax=true, bool search_options=true) |
Flags & | GetFlags () |
The flags accessor. | |
const Flags & | GetFlags () const |
The flags const accessor. | |
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. | |
bool | HasOverrideCallback () const |
void | SetOverrideCallback (lldb::CommandOverrideCallback callback, void *baton) |
void | SetOverrideCallback (lldb_private::CommandOverrideCallbackWithResult callback, void *baton) |
bool | InvokeOverrideCallback (const char **argv, CommandReturnObject &result) |
void | SetOriginalCommandString (std::string s) |
Set the command input as it appeared in the terminal. | |
virtual void | Execute (const char *args_string, CommandReturnObject &result)=0 |
Static Public Member Functions | |
static CommandObjectSP | Create (CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch, CommandReturnObject &result) |
Static Public Member Functions inherited from lldb_private::CommandObject | |
static const char * | GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) |
static const char * | GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) |
static lldb::CommandArgumentType | LookupArgumentName (llvm::StringRef arg_name) |
static const ArgumentTableEntry * | FindArgumentDataByType (lldb::CommandArgumentType arg_type) |
static void | GetArgumentHelp (Stream &str, lldb::CommandArgumentType arg_type, CommandInterpreter &interpreter) |
static const char * | GetArgumentName (lldb::CommandArgumentType arg_type) |
static bool | IsPairType (ArgumentRepetitionType arg_repeat_type) |
static std::optional< ArgumentRepetitionType > | ArgRepetitionFromString (llvm::StringRef string) |
Protected Member Functions | |
void | DoExecute (Args &args, CommandReturnObject &result) override |
Protected Member Functions inherited from lldb_private::CommandObjectParsed | |
virtual void | DoExecute (Args &command, CommandReturnObject &result)=0 |
bool | WantsRawCommandString () override |
Protected Member Functions inherited from lldb_private::CommandObject | |
bool | ParseOptionsAndNotify (Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx) |
virtual const char * | GetInvalidTargetDescription () |
virtual const char * | GetInvalidProcessDescription () |
virtual const char * | GetInvalidThreadDescription () |
virtual const char * | GetInvalidFrameDescription () |
virtual const char * | GetInvalidRegContextDescription () |
Target & | GetDummyTarget () |
Target & | GetTarget () |
Thread * | GetDefaultThread () |
bool | CheckRequirements (CommandReturnObject &result) |
Check the command to make sure anything required by this command is available. | |
void | Cleanup () |
Private Member Functions | |
void | PrepareOptionsForCompletion (CompletionRequest &request, OptionElementVector &option_vec) |
Private Attributes | |
StructuredData::GenericSP | m_cmd_obj_sp |
ScriptedCommandSynchronicity | m_synchro |
CommandOptions | m_options |
Status | m_options_error |
Status | m_args_error |
bool | m_fetched_help_short: 1 |
bool | m_fetched_help_long: 1 |
Additional Inherited Members | |
Public Types inherited from lldb_private::CommandObject | |
enum | IDType { eBreakpointArgs = 0 , eWatchpointArgs = 1 } |
typedef llvm::StringRef() | ArgumentHelpCallbackFunction() |
typedef std::vector< CommandArgumentData > | CommandArgumentEntry |
typedef std::map< std::string, lldb::CommandObjectSP, std::less<> > | CommandMap |
Protected Attributes inherited from lldb_private::CommandObject | |
CommandInterpreter & | m_interpreter |
ExecutionContext | m_exe_ctx |
std::unique_lock< std::recursive_mutex > | m_api_locker |
std::string | m_cmd_name |
std::string | m_cmd_help_short |
std::string | m_cmd_help_long |
std::string | m_cmd_syntax |
std::string | m_original_command |
Flags | m_flags |
std::vector< CommandArgumentEntry > | m_arguments |
lldb::CommandOverrideCallback | m_deprecated_command_override_callback |
lldb_private::CommandOverrideCallbackWithResult | m_command_override_callback |
void * | m_command_override_baton |
bool | m_is_user_command = false |
This command implements a lldb parsed scripted command.
The command provides a definition of the options and arguments, and a option value setting callback, and then the command's execution function gets passed just the parsed arguments. Note, implementing a command in Python using these base interfaces is a bit of a pain, but it is much easier to export this low level interface, and then make it nicer on the Python side, than to try to do that in a script language neutral way. So I've also added a base class in Python that provides a table-driven way of defining the options and arguments, which automatically fills the option values, making them available as properties in Python.
Definition at line 1237 of file CommandObjectCommands.cpp.
|
inline |
Definition at line 1847 of file CommandObjectCommands.cpp.
References lldb_private::CommandObject::ArgRepetitionFromString(), lldb_private::eArgRepeatOptional, lldb::eArgTypeLastArg, lldb::eArgTypeNone, lldb_private::Status::Fail(), lldb_private::StructuredData::Array::ForEach(), lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormatv(), lldb_private::ScriptInterpreter::GetArgumentsForCommandObject(), lldb_private::StructuredData::Object::GetAsArray(), lldb_private::StructuredData::Object::GetAsDictionary(), lldb_private::StructuredData::Object::GetAsUnsignedInteger(), lldb_private::CommandObject::GetDebugger(), lldb_private::CommandObject::GetFlags(), lldb_private::ScriptInterpreter::GetFlagsForCommandObject(), lldb_private::ScriptInterpreter::GetOptionsForCommandObject(), lldb_private::Debugger::GetScriptInterpreter(), lldb_private::StructuredData::Integer< N >::GetValue(), lldb_private::StructuredData::Dictionary::GetValueForKey(), m_args_error, lldb_private::CommandObject::m_arguments, m_options, m_options_error, CommandObjectScriptingObjectParsed::CommandOptions::ParseUsageMaskFromArray(), lldb_private::Flags::Set(), and CommandObjectScriptingObjectParsed::CommandOptions::SetOptionsFromArray().
|
overridedefault |
|
inlinestatic |
Definition at line 1819 of file CommandObjectCommands.cpp.
References lldb_private::CommandReturnObject::AppendErrorWithFormat(), lldb_private::Status::AsCString(), lldb_private::Status::Fail(), GetArgsError(), GetOptionsError(), and lldb_private::CommandReturnObject::Succeeded().
Referenced by CommandObjectCommandsScriptAdd::DoExecute().
|
inlineoverrideprotectedvirtual |
Implements lldb_private::CommandObjectParsed.
Definition at line 2125 of file CommandObjectCommands.cpp.
References lldb_private::CommandReturnObject::AppendError(), lldb::eReturnStatusInvalid, lldb::eReturnStatusSuccessFinishNoResult, lldb::eReturnStatusSuccessFinishResult, error(), lldb_private::CommandObject::GetDebugger(), lldb_private::CommandReturnObject::GetOutputString(), lldb_private::Debugger::GetScriptInterpreter(), lldb_private::CommandReturnObject::GetStatus(), m_cmd_obj_sp, lldb_private::CommandObject::m_exe_ctx, m_synchro, lldb_private::ScriptInterpreter::RunScriptBasedParsedCommand(), and lldb_private::CommandReturnObject::SetStatus().
|
inline |
Definition at line 2001 of file CommandObjectCommands.cpp.
References lldb_private::Status::Clone(), and m_args_error.
Referenced by Create().
|
inlineoverridevirtual |
Reimplemented from lldb_private::CommandObject.
Definition at line 2085 of file CommandObjectCommands.cpp.
References lldb_private::CommandObject::GetDebugger(), lldb_private::Debugger::GetScriptInterpreter(), lldb_private::ScriptInterpreter::GetShortHelpForCommandObject(), m_cmd_obj_sp, m_fetched_help_short, and lldb_private::CommandObject::SetHelp().
|
inlineoverridevirtual |
Reimplemented from lldb_private::CommandObject.
Definition at line 2100 of file CommandObjectCommands.cpp.
References lldb_private::CommandObject::GetDebugger(), lldb_private::ScriptInterpreter::GetLongHelpForCommandObject(), lldb_private::Debugger::GetScriptInterpreter(), m_cmd_obj_sp, m_fetched_help_long, and lldb_private::CommandObject::SetHelpLong().
|
inlineoverridevirtual |
Reimplemented from lldb_private::CommandObject.
Definition at line 2116 of file CommandObjectCommands.cpp.
References CommandObjectScriptingObjectParsed::CommandOptions::GetNumOptions(), and m_options.
Referenced by HandleArgumentCompletion(), and PrepareOptionsForCompletion().
|
inline |
Definition at line 2000 of file CommandObjectCommands.cpp.
References lldb_private::Status::Clone(), and m_options_error.
Referenced by Create().
|
inlineoverridevirtual |
Get the command that appropriate for a "repeat" of the current command.
[in] | current_command_args | The command arguments. |
[in] | index | This is for internal use - it is how the completion request is tracked in CommandObjectMultiword, and should otherwise be ignored. |
Reimplemented from lldb_private::CommandObject.
Definition at line 2076 of file CommandObjectCommands.cpp.
References lldb_private::CommandObject::GetDebugger(), lldb_private::ScriptInterpreter::GetRepeatCommandForScriptedCommand(), lldb_private::Debugger::GetScriptInterpreter(), and m_cmd_obj_sp.
|
inline |
Definition at line 2074 of file CommandObjectCommands.cpp.
References m_synchro.
|
inlineoverridevirtual |
The default version handles argument definitions that have only one argument type, and use one of the argument types that have an entry in the CommonCompletions.
Override this if you have a more complex argument setup. FIXME: we should be able to extend this to more complex argument definitions provided we have completers for all the argument types.
The input array contains a parsed version of the line.
We've constructed the map of options and their arguments as well if that is helpful for the completion.
[in,out] | request | The completion request that needs to be answered. |
Reimplemented from lldb_private::CommandObject.
Definition at line 2020 of file CommandObjectCommands.cpp.
References lldb_private::Args::GetArgumentCount(), lldb_private::CompletionRequest::GetCursorCharPos(), lldb_private::CompletionRequest::GetCursorIndex(), lldb_private::CommandObject::GetDebugger(), lldb_private::Options::GetDefinitions(), GetOptions(), lldb_private::CompletionRequest::GetParsedLine(), lldb_private::Debugger::GetScriptInterpreter(), lldb_private::CommandObject::HandleArgumentCompletion(), lldb_private::ScriptInterpreter::HandleArgumentCompletionForScriptedCommand(), m_cmd_obj_sp, m_options, PrepareOptionsForCompletion(), and CommandObjectScriptingObjectParsed::CommandOptions::ProcessCompletionDict().
|
inlineoverridevirtual |
Reimplemented from lldb_private::CommandObject.
Definition at line 2072 of file CommandObjectCommands.cpp.
|
inlineprivate |
Definition at line 2005 of file CommandObjectCommands.cpp.
References GetOptions(), lldb_private::CommandObject::m_exe_ctx, m_options, and CommandObjectScriptingObjectParsed::CommandOptions::PrepareOptionsForCompletion().
Referenced by HandleArgumentCompletion().
|
inlineoverridevirtual |
Reimplemented from lldb_private::CommandObject.
Definition at line 2002 of file CommandObjectCommands.cpp.
|
private |
Definition at line 2153 of file CommandObjectCommands.cpp.
Referenced by CommandObjectScriptingObjectParsed(), and GetArgsError().
|
private |
Definition at line 2149 of file CommandObjectCommands.cpp.
Referenced by DoExecute(), GetHelp(), GetHelpLong(), GetRepeatCommand(), and HandleArgumentCompletion().
|
private |
Definition at line 2155 of file CommandObjectCommands.cpp.
Referenced by GetHelpLong().
|
private |
Definition at line 2154 of file CommandObjectCommands.cpp.
Referenced by GetHelp().
|
private |
Definition at line 2151 of file CommandObjectCommands.cpp.
Referenced by CommandObjectScriptingObjectParsed(), GetOptions(), HandleArgumentCompletion(), and PrepareOptionsForCompletion().
|
private |
Definition at line 2152 of file CommandObjectCommands.cpp.
Referenced by CommandObjectScriptingObjectParsed(), and GetOptionsError().
|
private |
Definition at line 2150 of file CommandObjectCommands.cpp.
Referenced by DoExecute(), and GetSynchronicity().