SBCommandInterpreter#
- class lldb.SBCommandInterpreter(*args)#
SBCommandInterpreter handles/interprets commands for lldb.
You get the command interpreter from the
SBDebugger
instance.For example (from test/ python_api/interpreter/TestCommandInterpreterAPI.py),:
def command_interpreter_api(self): '''Test the SBCommandInterpreter APIs.''' exe = os.path.join(os.getcwd(), 'a.out') # Create a target by the debugger. target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Retrieve the associated command interpreter from our debugger. ci = self.dbg.GetCommandInterpreter() self.assertTrue(ci, VALID_COMMAND_INTERPRETER) # Exercise some APIs.... self.assertTrue(ci.HasCommands()) self.assertTrue(ci.HasAliases()) self.assertTrue(ci.HasAliasOptions()) self.assertTrue(ci.CommandExists('breakpoint')) self.assertTrue(ci.CommandExists('target')) self.assertTrue(ci.CommandExists('platform')) self.assertTrue(ci.AliasExists('file')) self.assertTrue(ci.AliasExists('run')) self.assertTrue(ci.AliasExists('bt')) res = lldb.SBCommandReturnObject() ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) self.assertTrue(res.Succeeded()) ci.HandleCommand('process launch', res) self.assertTrue(res.Succeeded()) process = ci.GetProcess() self.assertTrue(process) ...
The HandleCommand() instance method takes two args: the command string and an SBCommandReturnObject instance which encapsulates the result of command execution.
Attributes Summary
Methods Summary
AliasExists
(cmd)Return whether the passed in name or command path exists and is an alias to some other command.
AllowExitCodeOnQuit
(allow)Sets whether the command interpreter should allow custom exit codes for the 'quit' command.
CommandExists
(cmd)Return whether a built-in command with the passed in name or command path exists.
EventIsCommandInterpreterEvent
(SBEvent event)GetArgumentTypeAsCString
(lldb)GetBroadcaster
(SBCommandInterpreter self)GetDebugger
(SBCommandInterpreter self)Get the string that needs to be written to the debugger stdin file handle when a control character is typed.
GetProcess
(SBCommandInterpreter self)GetPromptOnQuit
(SBCommandInterpreter self)Returns the exit code that the user has specified when running the 'quit' command.
GetStatistics
(SBCommandInterpreter self)Returns a list of handled commands, output and error. Each element in the list is a dictionary with the following keys/values: - "command" (string): The command that was given by the user. - "commandName" (string): The name of the executed command. - "commandArguments" (string): The arguments of the executed command. - "output" (string): The output of the command. Empty ("") if no output. - "error" (string): The error of the command. Empty ("") if no error. - "durationInSeconds" (float): The time it took to execute the command. - "timestampInEpochSeconds" (int): The timestamp when the command is executed.
HandleCommand
(-> lldb)HandleCompletion
(SBCommandInterpreter self, ...)HasAliasOptions
(SBCommandInterpreter self)HasAliases
(SBCommandInterpreter self)HasCommands
(SBCommandInterpreter self)Returns true if the user has called the 'quit' command with a custom exit code.
Interrupts the command currently executing in the RunCommandInterpreter thread.
IsActive
()Return true if the command interpreter is the active IO handler.
IsInteractive
(SBCommandInterpreter self)IsValid
(SBCommandInterpreter self)ResolveCommand
(command_line, result)Resolve the command just as HandleCommand would, expanding abbreviations and aliases.
SetPrintCallback
(SBCommandInterpreter self, lldb)SetPromptOnQuit
(SBCommandInterpreter self, ...)UserCommandExists
(cmd)Return whether a user defined command with the passed in name or command path exists.
Returns whether an interrupt flag was raised either by the SBDebugger - when the function is not running on the RunCommandInterpreter thread, or by SBCommandInterpreter::InterruptCommand if it is.
Attributes Documentation
- eBroadcastBitAsynchronousErrorData = <Mock name='mock.SBCommandInterpreter_eBroadcastBitAsynchronousErrorData' id='132416335688432'>#
- eBroadcastBitAsynchronousOutputData = <Mock name='mock.SBCommandInterpreter_eBroadcastBitAsynchronousOutputData' id='132416335688384'>#
- eBroadcastBitQuitCommandReceived = <Mock name='mock.SBCommandInterpreter_eBroadcastBitQuitCommandReceived' id='132416335688336'>#
- eBroadcastBitResetPrompt = <Mock name='mock.SBCommandInterpreter_eBroadcastBitResetPrompt' id='132416335688144'>#
- eBroadcastBitThreadShouldExit = <Mock name='mock.SBCommandInterpreter_eBroadcastBitThreadShouldExit' id='132416335688192'>#
Methods Documentation
- AliasExists(cmd)#
Return whether the passed in name or command path exists and is an alias to some other command.
- Parameters:
cmd (string, in) â The command or command path to search for.
- Return type:
boolean
- Returns:
true if the command exists, false otherwise.
- AllowExitCodeOnQuit(allow)#
Sets whether the command interpreter should allow custom exit codes for the âquitâ command.
- CommandExists(cmd)#
Return whether a built-in command with the passed in name or command path exists.
- Parameters:
cmd (string, in) â The command or command path to search for.
- Return type:
boolean
- Returns:
true if the command exists, false otherwise.
- static EventIsCommandInterpreterEvent(SBEvent event) bool #
- static GetArgumentDescriptionAsCString(lldb::CommandArgumentType const arg_type) char const * #
- static GetArgumentTypeAsCString(lldb::CommandArgumentType const arg_type) char const * #
- GetBroadcaster(SBCommandInterpreter self) SBBroadcaster #
- static GetBroadcasterClass() char const * #
- GetDebugger(SBCommandInterpreter self) SBDebugger #
- GetIOHandlerControlSequence(ch)#
Get the string that needs to be written to the debugger stdin file handle when a control character is typed.
Some GUI programs will intercept âcontrol + charâ sequences and want to have them do what normally would happen when using a real terminal, so this function allows GUI programs to emulate this functionality.
- Parameters:
ch (char, in) â The character that was typed along with the control key
- Return type:
string
- Returns:
The string that should be written into the file handle that is feeding the input stream for the debugger, or nullptr if there is no string for this control key.
- GetPromptOnQuit(SBCommandInterpreter self) bool #
- GetQuitStatus()#
Returns the exit code that the user has specified when running the âquitâ command. Returns 0 if the user hasnât called âquitâ at all or without a custom exit code.
- GetStatistics(SBCommandInterpreter self) SBStructuredData #
- GetTranscript()#
Returns a list of handled commands, output and error. Each element in the list is a dictionary with the following keys/values: - âcommandâ (string): The command that was given by the user. - âcommandNameâ (string): The name of the executed command. - âcommandArgumentsâ (string): The arguments of the executed command. - âoutputâ (string): The output of the command. Empty (ââ) if no output. - âerrorâ (string): The error of the command. Empty (ââ) if no error. - âdurationInSecondsâ (float): The time it took to execute the command. - âtimestampInEpochSecondsâ (int): The timestamp when the command is
executed.
Turn on settings
interpreter.save-transcript
for LLDB to populate this list. Otherwise this list is empty.
- HandleCommand(SBCommandInterpreter self, char const * command_line, SBCommandReturnObject result, bool add_to_history=False) lldb::ReturnStatus #
- HandleCommand(SBCommandInterpreter self, char const * command_line, SBExecutionContext exe_ctx, SBCommandReturnObject result, bool add_to_history=False) lldb::ReturnStatus
- HandleCommandsFromFile(SBCommandInterpreter self, SBFileSpec file, SBExecutionContext override_context, SBCommandInterpreterRunOptions options, SBCommandReturnObject result)#
- HandleCompletion(SBCommandInterpreter self, char const * current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, SBStringList matches) int #
- HandleCompletionWithDescriptions(SBCommandInterpreter self, char const * current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, SBStringList matches, SBStringList descriptions) int #
- HasAliasOptions(SBCommandInterpreter self) bool #
- HasAliases(SBCommandInterpreter self) bool #
- HasCommands(SBCommandInterpreter self) bool #
- HasCustomQuitExitCode()#
Returns true if the user has called the âquitâ command with a custom exit code.
- InterruptCommand()#
Interrupts the command currently executing in the RunCommandInterpreter thread.
- Return type:
boolean
- Returns:
true if there was a command in progress to recieve the interrupt. false if thereâs no command currently in flight.
- IsActive()#
Return true if the command interpreter is the active IO handler.
This indicates that any input coming into the debugger handles will go to the command interpreter and will result in LLDB command line commands being executed.
- IsInteractive(SBCommandInterpreter self) bool #
- IsValid(SBCommandInterpreter self) bool #
- ResolveCommand(command_line, result)#
Resolve the command just as HandleCommand would, expanding abbreviations and aliases. If successful, result->GetOutput has the full expansion.
- SetCommandOverrideCallback(SBCommandInterpreter self, char const * command_name, lldb::CommandOverrideCallback callback) bool #
- SetPrintCallback(SBCommandInterpreter self, lldb::SBCommandPrintCallback callback)#
- SetPromptOnQuit(SBCommandInterpreter self, bool b)#
- SourceInitFileInCurrentWorkingDirectory(SBCommandInterpreter self, SBCommandReturnObject result)#
- SourceInitFileInHomeDirectory(SBCommandInterpreter self, SBCommandReturnObject result)#
- SourceInitFileInHomeDirectory(SBCommandInterpreter self, SBCommandReturnObject result, bool is_repl) None
- UserCommandExists(cmd)#
Return whether a user defined command with the passed in name or command path exists.
- Parameters:
cmd (string, in) â The command or command path to search for.
- Return type:
boolean
- Returns:
true if the command exists, false otherwise.
- WasInterrupted()#
Returns whether an interrupt flag was raised either by the SBDebugger - when the function is not running on the RunCommandInterpreter thread, or by SBCommandInterpreter::InterruptCommand if it is. If your code is doing interruptible work, check this API periodically, and interrupt if it returns true.