LLDB mainline
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
lldb::SBCommandInterpreter Class Reference

#include <SBCommandInterpreter.h>

Public Types

enum  {
  eBroadcastBitThreadShouldExit = (1 << 0) , eBroadcastBitResetPrompt = (1 << 1) , eBroadcastBitQuitCommandReceived = (1 << 2) , eBroadcastBitAsynchronousOutputData = (1 << 3) ,
  eBroadcastBitAsynchronousErrorData = (1 << 4)
}
 

Public Member Functions

 SBCommandInterpreter ()
 
 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs)
 
 ~SBCommandInterpreter ()
 
const lldb::SBCommandInterpreteroperator= (const lldb::SBCommandInterpreter &rhs)
 
 operator bool () const
 
bool IsValid () const
 
bool CommandExists (const char *cmd)
 Return whether a built-in command with the passed in name or command path exists.
 
bool UserCommandExists (const char *cmd)
 Return whether a user defined command with the passed in name or command path exists.
 
bool AliasExists (const char *cmd)
 Return whether the passed in name or command path exists and is an alias to some other command.
 
lldb::SBBroadcaster GetBroadcaster ()
 
bool HasCommands ()
 
bool HasAliases ()
 
bool HasAliasOptions ()
 
bool IsInteractive ()
 
lldb::SBProcess GetProcess ()
 
lldb::SBDebugger GetDebugger ()
 
lldb::SBCommand AddMultiwordCommand (const char *name, const char *help)
 
lldb::SBCommand AddCommand (const char *name, lldb::SBCommandPluginInterface *impl, const char *help)
 Add a new command to the lldb::CommandInterpreter.
 
lldb::SBCommand AddCommand (const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax)
 Add a new command to the lldb::CommandInterpreter.
 
lldb::SBCommand AddCommand (const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax, const char *auto_repeat_command)
 Add a new command to the lldb::CommandInterpreter.
 
void SourceInitFileInGlobalDirectory (lldb::SBCommandReturnObject &result)
 
void SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result)
 
void SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result, bool is_repl)
 
void SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result)
 
lldb::ReturnStatus HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history=false)
 
lldb::ReturnStatus HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history=false)
 
void HandleCommandsFromFile (lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result)
 
int HandleCompletion (const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, lldb::SBStringList &matches)
 
int HandleCompletion (const char *current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, lldb::SBStringList &matches)
 
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)
 
int HandleCompletionWithDescriptions (const char *current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, lldb::SBStringList &matches, lldb::SBStringList &descriptions)
 
bool WasInterrupted () const
 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.
 
bool InterruptCommand ()
 Interrupts the command currently executing in the RunCommandInterpreter thread.
 
bool SetCommandOverrideCallback (const char *command_name, lldb::CommandOverrideCallback callback, void *baton)
 
bool IsActive ()
 Return true if the command interpreter is the active IO handler.
 
const char * GetIOHandlerControlSequence (char ch)
 Get the string that needs to be written to the debugger stdin file handle when a control character is typed.
 
bool GetPromptOnQuit ()
 
void SetPromptOnQuit (bool b)
 
void AllowExitCodeOnQuit (bool allow)
 Sets whether the command interpreter should allow custom exit codes for the 'quit' command.
 
bool HasCustomQuitExitCode ()
 Returns true if the user has called the 'quit' command with a custom exit code.
 
int GetQuitStatus ()
 Returns the exit code that the user has specified when running the 'quit' command.
 
void ResolveCommand (const char *command_line, SBCommandReturnObject &result)
 Resolve the command just as HandleCommand would, expanding abbreviations and aliases.
 
SBStructuredData GetStatistics ()
 
SBStructuredData GetTranscript ()
 Returns a list of handled commands, output and error.
 

Static Public Member Functions

static const char * GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
 
static const char * GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
 
static bool EventIsCommandInterpreterEvent (const lldb::SBEvent &event)
 
static const char * GetBroadcasterClass ()
 

Protected Member Functions

 SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr)
 Access using SBDebugger::GetCommandInterpreter();.
 
lldb_private::CommandInterpreterref ()
 
lldb_private::CommandInterpreterget ()
 
void reset (lldb_private::CommandInterpreter *)
 

Private Attributes

lldb_private::CommandInterpreterm_opaque_ptr
 

Friends

class lldb_private::CommandPluginInterfaceImplementation
 
class SBDebugger
 

Detailed Description

Definition at line 24 of file SBCommandInterpreter.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
eBroadcastBitThreadShouldExit 
eBroadcastBitResetPrompt 
eBroadcastBitQuitCommandReceived 
eBroadcastBitAsynchronousOutputData 
eBroadcastBitAsynchronousErrorData 

Definition at line 26 of file SBCommandInterpreter.h.

Constructor & Destructor Documentation

◆ SBCommandInterpreter() [1/3]

SBCommandInterpreter::SBCommandInterpreter ( )

Definition at line 85 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA.

◆ SBCommandInterpreter() [2/3]

SBCommandInterpreter::SBCommandInterpreter ( const lldb::SBCommandInterpreter rhs)

Definition at line 94 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA.

◆ ~SBCommandInterpreter()

SBCommandInterpreter::~SBCommandInterpreter ( )
default

◆ SBCommandInterpreter() [3/3]

SBCommandInterpreter::SBCommandInterpreter ( lldb_private::CommandInterpreter interpreter_ptr)
protected

Access using SBDebugger::GetCommandInterpreter();.

Definition at line 89 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA.

Member Function Documentation

◆ AddCommand() [1/3]

lldb::SBCommand SBCommandInterpreter::AddCommand ( const char *  name,
lldb::SBCommandPluginInterface impl,
const char *  help 
)

Add a new command to the lldb::CommandInterpreter.

The new command won't support autorepeat. If you need this functionality, use the override of this function that accepts the auto_repeat_command parameter.

Parameters
[in]nameThe name of the command.
[in]implThe handler of this command.
[in]helpThe general description to show as part of the help message of this command.
Returns
A lldb::SBCommand representing the newly created command.

Definition at line 603 of file SBCommandInterpreter.cpp.

References AddCommand(), and LLDB_INSTRUMENT_VA.

Referenced by AddCommand().

◆ AddCommand() [2/3]

lldb::SBCommand SBCommandInterpreter::AddCommand ( const char *  name,
lldb::SBCommandPluginInterface impl,
const char *  help,
const char *  syntax 
)

Add a new command to the lldb::CommandInterpreter.

The new command won't support autorepeat. If you need this functionality, use the override of this function that accepts the auto_repeat_command parameter.

Parameters
[in]nameThe name of the command.
[in]implThe handler of this command.
[in]helpThe general description to show as part of the help message of this command.
[in]syntaxThe syntax to show as part of the help message of this command. This could include a description of the different arguments and flags this command accepts.
Returns
A lldb::SBCommand representing the newly created command.

Definition at line 612 of file SBCommandInterpreter.cpp.

References AddCommand(), and LLDB_INSTRUMENT_VA.

◆ AddCommand() [3/3]

lldb::SBCommand SBCommandInterpreter::AddCommand ( const char *  name,
lldb::SBCommandPluginInterface impl,
const char *  help,
const char *  syntax,
const char *  auto_repeat_command 
)

Add a new command to the lldb::CommandInterpreter.

Parameters
[in]nameThe name of the command.
[in]implThe handler of this command.
[in]helpThe general description to show as part of the help message of this command.
[in]syntaxThe syntax to show as part of the help message of this command. This could include a description of the different arguments and flags this command accepts.
[in]auto_repeat_commandAutorepeating is triggered when the user presses Enter successively after executing a command. If nullptr is provided, the previous exact command will be repeated. If "" is provided, autorepeating is disabled. Otherwise, the provided string is used as a repeat command.
Returns
A lldb::SBCommand representing the newly created command.

Definition at line 619 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::AddUserCommand(), LLDB_INSTRUMENT_VA, m_opaque_ptr, and lldb_private::Status::Success().

◆ AddMultiwordCommand()

lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand ( const char *  name,
const char *  help 
)

◆ AliasExists()

bool SBCommandInterpreter::AliasExists ( const char *  cmd)

Return whether the passed in name or command path exists and is an alias to some other command.

Parameters
[in]cmdThe command or command path to search for.
Returns
true if the command exists, false otherwise.

Definition at line 133 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::AliasExists(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ AllowExitCodeOnQuit()

void SBCommandInterpreter::AllowExitCodeOnQuit ( bool  allow)

Sets whether the command interpreter should allow custom exit codes for the 'quit' command.

Definition at line 402 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::AllowExitCodeOnQuit(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ CommandExists()

bool SBCommandInterpreter::CommandExists ( const char *  cmd)

Return whether a built-in command with the passed in name or command path exists.

Parameters
[in]cmdThe command or command path to search for.
Returns
true if the command exists, false otherwise.

Definition at line 119 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::CommandExists(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ EventIsCommandInterpreterEvent()

bool SBCommandInterpreter::EventIsCommandInterpreterEvent ( const lldb::SBEvent event)
static

Definition at line 536 of file SBCommandInterpreter.cpp.

References GetBroadcasterClass(), and LLDB_INSTRUMENT_VA.

◆ get()

CommandInterpreter * SBCommandInterpreter::get ( )
protected

Definition at line 438 of file SBCommandInterpreter.cpp.

References m_opaque_ptr.

Referenced by lldb::SBDebugger::Create().

◆ GetArgumentDescriptionAsCString()

const char * SBCommandInterpreter::GetArgumentDescriptionAsCString ( const lldb::CommandArgumentType  arg_type)
static

◆ GetArgumentTypeAsCString()

const char * SBCommandInterpreter::GetArgumentTypeAsCString ( const lldb::CommandArgumentType  arg_type)
static

◆ GetBroadcaster()

SBBroadcaster SBCommandInterpreter::GetBroadcaster ( )

Definition at line 505 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ GetBroadcasterClass()

const char * SBCommandInterpreter::GetBroadcasterClass ( )
static

◆ GetDebugger()

SBDebugger SBCommandInterpreter::GetDebugger ( )

◆ GetIOHandlerControlSequence()

const char * SBCommandInterpreter::GetIOHandlerControlSequence ( char  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
[in]chThe character that was typed along with the control key
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.

Definition at line 158 of file SBCommandInterpreter.cpp.

References lldb_private::ConstString::GetCString(), lldb_private::CommandInterpreter::GetDebugger(), lldb_private::Debugger::GetTopIOHandlerControlSequence(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ GetProcess()

SBProcess SBCommandInterpreter::GetProcess ( )

◆ GetPromptOnQuit()

bool SBCommandInterpreter::GetPromptOnQuit ( )

◆ GetQuitStatus()

int SBCommandInterpreter::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.

Definition at line 418 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::GetQuitExitCode(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ GetStatistics()

SBStructuredData SBCommandInterpreter::GetStatistics ( )

◆ GetTranscript()

SBStructuredData SBCommandInterpreter::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.

Definition at line 575 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::GetTranscript(), IsValid(), LLDB_INSTRUMENT_VA, lldb::SBStructuredData::m_impl_up, and m_opaque_ptr.

◆ HandleCommand() [1/2]

lldb::ReturnStatus SBCommandInterpreter::HandleCommand ( const char *  command_line,
lldb::SBCommandReturnObject result,
bool  add_to_history = false 
)

Definition at line 170 of file SBCommandInterpreter.cpp.

References HandleCommand(), and LLDB_INSTRUMENT_VA.

Referenced by lldb::SBDebugger::HandleCommand(), and HandleCommand().

◆ HandleCommand() [2/2]

lldb::ReturnStatus SBCommandInterpreter::HandleCommand ( const char *  command_line,
SBExecutionContext exe_ctx,
SBCommandReturnObject result,
bool  add_to_history = false 
)

◆ HandleCommandsFromFile()

void SBCommandInterpreter::HandleCommandsFromFile ( lldb::SBFileSpec file,
lldb::SBExecutionContext override_context,
lldb::SBCommandInterpreterRunOptions options,
lldb::SBCommandReturnObject  result 
)

◆ HandleCompletion() [1/2]

int SBCommandInterpreter::HandleCompletion ( const char *  current_line,
const char *  cursor,
const char *  last_char,
int  match_start_point,
int  max_return_elements,
lldb::SBStringList matches 
)

Definition at line 232 of file SBCommandInterpreter.cpp.

References HandleCompletionWithDescriptions(), and LLDB_INSTRUMENT_VA.

Referenced by HandleCompletion().

◆ HandleCompletion() [2/2]

int SBCommandInterpreter::HandleCompletion ( const char *  current_line,
uint32_t  cursor_pos,
int  match_start_point,
int  max_return_elements,
lldb::SBStringList matches 
)

Definition at line 324 of file SBCommandInterpreter.cpp.

References HandleCompletion(), and LLDB_INSTRUMENT_VA.

◆ HandleCompletionWithDescriptions() [1/2]

int SBCommandInterpreter::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 
)

◆ HandleCompletionWithDescriptions() [2/2]

int SBCommandInterpreter::HandleCompletionWithDescriptions ( const char *  current_line,
uint32_t  cursor_pos,
int  match_start_point,
int  max_return_elements,
lldb::SBStringList matches,
lldb::SBStringList descriptions 
)

◆ HasAliases()

bool SBCommandInterpreter::HasAliases ( )

◆ HasAliasOptions()

bool SBCommandInterpreter::HasAliasOptions ( )

◆ HasCommands()

bool SBCommandInterpreter::HasCommands ( )

◆ HasCustomQuitExitCode()

bool SBCommandInterpreter::HasCustomQuitExitCode ( )

Returns true if the user has called the 'quit' command with a custom exit code.

Definition at line 409 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::GetQuitExitCode(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ InterruptCommand()

bool SBCommandInterpreter::InterruptCommand ( )

Interrupts the command currently executing in the RunCommandInterpreter thread.

Returns
true if there was a command in progress to recieve the interrupt. false if there's no command currently in flight.

Definition at line 152 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::InterruptCommand(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ IsActive()

bool SBCommandInterpreter::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.

Definition at line 140 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::IsActive(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ IsInteractive()

bool SBCommandInterpreter::IsInteractive ( )

◆ IsValid()

bool SBCommandInterpreter::IsValid ( ) const

◆ operator bool()

SBCommandInterpreter::operator bool ( ) const
explicit

Definition at line 113 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA.

◆ operator=()

const SBCommandInterpreter & SBCommandInterpreter::operator= ( const lldb::SBCommandInterpreter rhs)

Definition at line 101 of file SBCommandInterpreter.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_ptr.

◆ ref()

CommandInterpreter & SBCommandInterpreter::ref ( )
protected

Definition at line 440 of file SBCommandInterpreter.cpp.

References m_opaque_ptr.

◆ reset()

void SBCommandInterpreter::reset ( lldb_private::CommandInterpreter interpreter)
protected

Definition at line 445 of file SBCommandInterpreter.cpp.

References m_opaque_ptr.

Referenced by lldb::SBDebugger::GetCommandInterpreter().

◆ ResolveCommand()

void SBCommandInterpreter::ResolveCommand ( const char *  command_line,
SBCommandReturnObject result 
)

Resolve the command just as HandleCommand would, expanding abbreviations and aliases.

If successful, result->GetOutput has the full expansion.

Definition at line 425 of file SBCommandInterpreter.cpp.

References lldb_private::CommandReturnObject::AppendError(), lldb::SBCommandReturnObject::Clear(), IsValid(), LLDB_INSTRUMENT_VA, m_opaque_ptr, lldb::SBCommandReturnObject::ref(), and lldb_private::CommandInterpreter::ResolveCommand().

◆ SetCommandOverrideCallback()

bool SBCommandInterpreter::SetCommandOverrideCallback ( const char *  command_name,
lldb::CommandOverrideCallback  callback,
void *  baton 
)

◆ SetPromptOnQuit()

void SBCommandInterpreter::SetPromptOnQuit ( bool  b)

◆ SourceInitFileInCurrentWorkingDirectory()

void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory ( lldb::SBCommandReturnObject result)

◆ SourceInitFileInGlobalDirectory()

void SBCommandInterpreter::SourceInitFileInGlobalDirectory ( lldb::SBCommandReturnObject result)

◆ SourceInitFileInHomeDirectory() [1/2]

void SBCommandInterpreter::SourceInitFileInHomeDirectory ( lldb::SBCommandReturnObject result)

◆ SourceInitFileInHomeDirectory() [2/2]

void SBCommandInterpreter::SourceInitFileInHomeDirectory ( lldb::SBCommandReturnObject result,
bool  is_repl 
)

◆ UserCommandExists()

bool SBCommandInterpreter::UserCommandExists ( const char *  cmd)

Return whether a user defined command with the passed in name or command path exists.

Parameters
[in]cmdThe command or command path to search for.
Returns
true if the command exists, false otherwise.

Definition at line 126 of file SBCommandInterpreter.cpp.

References IsValid(), LLDB_INSTRUMENT_VA, m_opaque_ptr, and lldb_private::CommandInterpreter::UserCommandExists().

◆ WasInterrupted()

bool SBCommandInterpreter::WasInterrupted ( ) const

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.

Definition at line 146 of file SBCommandInterpreter.cpp.

References lldb_private::CommandInterpreter::GetDebugger(), lldb_private::Debugger::InterruptRequested(), IsValid(), LLDB_INSTRUMENT_VA, and m_opaque_ptr.

Friends And Related Function Documentation

◆ lldb_private::CommandPluginInterfaceImplementation

Definition at line 335 of file SBCommandInterpreter.h.

◆ SBDebugger

friend class SBDebugger
friend

Definition at line 346 of file SBCommandInterpreter.h.

Member Data Documentation

◆ m_opaque_ptr

lldb_private::CommandInterpreter* lldb::SBCommandInterpreter::m_opaque_ptr
private

The documentation for this class was generated from the following files: