LLDB  mainline
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
lldb_private::REPL Class Referenceabstract

#include <REPL.h>

Inheritance diagram for lldb_private::REPL:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::REPL:
Collaboration graph
[legend]

Public Types

enum  LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds }
 
- Public Types inherited from lldb_private::IOHandlerDelegate
enum  Completion { Completion::None, Completion::LLDBCommand, Completion::Expression }
 

Public Member Functions

LLVMCastKind getKind () const
 
 REPL (LLVMCastKind kind, Target &target)
 
 ~REPL () override
 
void SetFormatOptions (const OptionGroupFormat &options)
 
void SetValueObjectDisplayOptions (const OptionGroupValueObjectDisplay &options)
 
void SetEvaluateOptions (const EvaluateExpressionOptions &options)
 
void SetCompilerOptions (const char *options)
 
lldb::IOHandlerSP GetIOHandler ()
 
Status RunLoop ()
 
void IOHandlerActivated (IOHandler &io_handler, bool interactive) override
 
bool IOHandlerInterrupt (IOHandler &io_handler) override
 
void IOHandlerInputInterrupted (IOHandler &io_handler, std::string &line) override
 
const char * IOHandlerGetFixIndentationCharacters () override
 
ConstString IOHandlerGetControlSequence (char ch) override
 
const char * IOHandlerGetCommandPrefix () override
 
const char * IOHandlerGetHelpPrologue () override
 
bool IOHandlerIsInputComplete (IOHandler &io_handler, StringList &lines) override
 Called to determine whether typing enter after the last line in lines should end input. More...
 
int IOHandlerFixIndentation (IOHandler &io_handler, const StringList &lines, int cursor_position) override
 Called when a new line is created or one of an identified set of indentation characters is typed. More...
 
void IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
 Called when a line or lines have been retrieved. More...
 
int IOHandlerComplete (IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, StringList &matches, StringList &descriptions) override
 
- Public Member Functions inherited from lldb_private::IOHandlerDelegate
 IOHandlerDelegate (Completion completion=Completion::None)
 
virtual ~IOHandlerDelegate ()=default
 
virtual void IOHandlerDeactivated (IOHandler &io_handler)
 

Static Public Member Functions

static lldb::REPLSP Create (Status &Status, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
 Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler. More...
 

Protected Member Functions

virtual Status DoInitialization ()=0
 
virtual ConstString GetSourceFileBasename ()=0
 
virtual const char * GetAutoIndentCharacters ()=0
 
virtual bool SourceIsComplete (const std::string &source)=0
 
virtual lldb::offset_t GetDesiredIndentation (const StringList &lines, int cursor_position, int tab_size)=0
 
virtual lldb::LanguageType GetLanguage ()=0
 
virtual bool PrintOneVariable (Debugger &debugger, lldb::StreamFileSP &output_sp, lldb::ValueObjectSP &valobj_sp, ExpressionVariable *var=nullptr)=0
 
virtual int CompleteCode (const std::string &current_code, StringList &matches)=0
 

Static Protected Member Functions

static int CalculateActualIndentation (const StringList &lines)
 

Protected Attributes

OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault)
 
OptionGroupValueObjectDisplay m_varobj_options
 
EvaluateExpressionOptions m_expr_options
 
std::string m_compiler_options
 
bool m_enable_auto_indent = true
 
std::string m_indent_str
 
std::string m_current_indent_str
 
uint32_t m_current_indent_level = 0
 
std::string m_repl_source_path
 
bool m_dedicated_repl_mode = false
 
StringList m_code
 
Targetm_target
 
lldb::IOHandlerSP m_io_handler_sp
 
LLVMCastKind m_kind
 
- Protected Attributes inherited from lldb_private::IOHandlerDelegate
Completion m_completion
 

Detailed Description

Definition at line 21 of file REPL.h.

Member Enumeration Documentation

◆ LLVMCastKind

Enumerator
eKindClang 
eKindSwift 
eKindGo 
kNumKinds 

Definition at line 24 of file REPL.h.

Constructor & Destructor Documentation

◆ REPL()

REPL::REPL ( LLVMCastKind  kind,
Target target 
)

◆ ~REPL()

REPL::~REPL ( )
overridedefault

Referenced by getKind(), and REPL().

Member Function Documentation

◆ CalculateActualIndentation()

int REPL::CalculateActualIndentation ( const StringList lines)
staticprotected

Definition at line 146 of file REPL.cpp.

References lldb_private::StringList::GetSize().

Referenced by IOHandlerFixIndentation(), and SetCompilerOptions().

◆ CompleteCode()

virtual int lldb_private::REPL::CompleteCode ( const std::string &  current_code,
StringList matches 
)
protectedpure virtual

◆ Create()

lldb::REPLSP REPL::Create ( Status Status,
lldb::LanguageType  language,
Debugger debugger,
Target target,
const char *  repl_options 
)
static

Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler.

Parameters
[out]errorIf this language is supported but the REPL couldn't be created, this error is populated with the reason.
[in]languageThe language to create a REPL for.
[in]debuggerIf provided, and target is nullptr, the debugger to use when setting up a top-level REPL.
[in]targetIf provided, the target to put the REPL inside.
[in]repl_optionsIf provided, additional options for the compiler when parsing REPL expressions.
Returns
The range of the containing object in the target process.

Definition at line 35 of file REPL.cpp.

References lldb_private::FileSpec::AppendPathComponent(), lldb_private::ConstString::AsCString(), lldb_private::FileSpec::GetFilename(), lldb_private::FileSpec::GetPath(), lldb_private::PluginManager::GetREPLCreateCallbackAtIndex(), GetSourceFileBasename(), m_repl_source_path, and lldb_private::ConstString::SetCString().

Referenced by getKind(), lldb_private::Target::GetREPL(), and lldb_private::Debugger::RunREPL().

◆ DoInitialization()

virtual Status lldb_private::REPL::DoInitialization ( )
protectedpure virtual

Referenced by RunLoop(), and SetCompilerOptions().

◆ GetAutoIndentCharacters()

virtual const char* lldb_private::REPL::GetAutoIndentCharacters ( )
protectedpure virtual

◆ GetDesiredIndentation()

virtual lldb::offset_t lldb_private::REPL::GetDesiredIndentation ( const StringList lines,
int  cursor_position,
int  tab_size 
)
protectedpure virtual

◆ GetIOHandler()

lldb::IOHandlerSP REPL::GetIOHandler ( )

◆ getKind()

LLVMCastKind lldb_private::REPL::getKind ( ) const
inline

Definition at line 26 of file REPL.h.

References Create(), m_kind, REPL(), and ~REPL().

◆ GetLanguage()

virtual lldb::LanguageType lldb_private::REPL::GetLanguage ( )
protectedpure virtual

◆ GetSourceFileBasename()

virtual ConstString lldb_private::REPL::GetSourceFileBasename ( )
protectedpure virtual

Referenced by Create(), and SetCompilerOptions().

◆ IOHandlerActivated()

void REPL::IOHandlerActivated ( IOHandler io_handler,
bool  interactive 
)
overridevirtual

◆ IOHandlerComplete()

int REPL::IOHandlerComplete ( IOHandler io_handler,
const char *  current_line,
const char *  cursor,
const char *  last_char,
int  skip_first_n_matches,
int  max_matches,
StringList matches,
StringList descriptions 
)
overridevirtual

◆ IOHandlerFixIndentation()

int REPL::IOHandlerFixIndentation ( IOHandler io_handler,
const StringList lines,
int  cursor_position 
)
overridevirtual

Called when a new line is created or one of an identified set of indentation characters is typed.

This function determines how much indentation should be added or removed to match the recommended amount for the final line.

Parameters
[in]io_handlerThe IOHandler that responsible for input.
[in]linesThe current input up to the line to be corrected. Lines following the line containing the cursor are not included.
[in]cursor_positionThe number of characters preceding the cursor on the final line at the time.
Returns
Returns an integer describing the number of spaces needed to correct the indentation level. Positive values indicate that spaces should be added, while negative values represent spaces that should be removed.

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 159 of file REPL.cpp.

References CalculateActualIndentation(), lldb_private::IOHandler::GetDebugger(), GetDesiredIndentation(), lldb_private::StringList::GetSize(), lldb_private::Debugger::GetTabSize(), LLDB_INVALID_OFFSET, and m_enable_auto_indent.

Referenced by SetCompilerOptions().

◆ IOHandlerGetCommandPrefix()

const char * REPL::IOHandlerGetCommandPrefix ( )
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 119 of file REPL.cpp.

Referenced by SetCompilerOptions().

◆ IOHandlerGetControlSequence()

ConstString REPL::IOHandlerGetControlSequence ( char  ch)
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 113 of file REPL.cpp.

Referenced by SetCompilerOptions().

◆ IOHandlerGetFixIndentationCharacters()

const char * REPL::IOHandlerGetFixIndentationCharacters ( )
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 109 of file REPL.cpp.

References GetAutoIndentCharacters(), and m_enable_auto_indent.

Referenced by SetCompilerOptions().

◆ IOHandlerGetHelpPrologue()

const char * REPL::IOHandlerGetHelpPrologue ( )
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 121 of file REPL.cpp.

Referenced by SetCompilerOptions().

◆ IOHandlerInputComplete()

void REPL::IOHandlerInputComplete ( IOHandler io_handler,
std::string &  data 
)
overridevirtual

Called when a line or lines have been retrieved.

This function can handle the current line and possibly call IOHandler::SetIsDone(true) when the IO handler is done like when "quit" is entered as a command, of when an empty line is received. It is up to the delegate to determine when a line should cause a IOHandler to exit.

Implements lldb_private::IOHandlerDelegate.

Definition at line 182 of file REPL.cpp.

References ANSI_CTRL_BOLD, ANSI_CTRL_NORMAL, ANSI_ESCAPE1, ANSI_FG_COLOR_RED, lldb_private::StringList::AppendString(), lldb_private::Debugger::CheckTopIOHandlerTypes(), lldb_private::File::Close(), lldb_private::IOHandler::CommandInterpreter, lldb_private::StringList::CopyList(), lldb::eExpressionCompleted, lldb::eExpressionDiscarded, lldb::eExpressionHitBreakpoint, lldb::eExpressionInterrupted, lldb::eExpressionParseError, lldb::eExpressionResultUnavailable, lldb::eExpressionSetupError, lldb::eExpressionStoppedForDebug, lldb::eExpressionTimedOut, lldb::eFormatVoid, lldb_private::eLazyBoolNo, lldb_private::File::eOpenOptionCanCreate, lldb_private::File::eOpenOptionTruncate, lldb_private::File::eOpenOptionWrite, lldb::eReturnStatusQuit, lldb_private::UserExpression::Evaluate(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::Target::GetDebugger(), lldb_private::IOHandler::GetErrorStreamFile(), lldb_private::OptionGroupFormat::GetFormat(), lldb_private::CommandInterpreter::GetIOHandler(), GetLanguage(), lldb_private::Debugger::GetNotifyVoid(), lldb_private::IOHandler::GetOutputStreamFile(), lldb_private::Target::GetPersistentExpressionStateForLanguage(), lldb_private::Debugger::GetPrintDecls(), lldb_private::Target::GetProcessSP(), lldb_private::CommandInterpreter::GetPromptOnQuit(), lldb_private::Thread::GetSelectedFrame(), lldb_private::StringList::GetSize(), lldb_private::ExpressionVariableList::GetSize(), lldb_private::Target::GetSourceManager(), lldb_private::CommandInterpreter::GetSpaceReplPrompts(), lldb_private::CommandReturnObject::GetStatus(), lldb_private::ExpressionVariableList::GetVariableAtIndex(), lldb_private::CommandInterpreter::HandleCommand(), lldb_private::FileSystem::Instance(), lldb_private::UserExpression::kNoResult, m_code, m_dedicated_repl_mode, m_expr_options, m_format_options, m_repl_source_path, m_target, m_varobj_options, lldb_private::FileSystem::Open(), PrintOneVariable(), lldb_private::Debugger::PushIOHandler(), lldb_private::IOHandler::REPL, lldb_private::EvaluateExpressionOptions::SetCoerceToId(), lldb_private::EvaluateExpressionOptions::SetColorizeErrors(), lldb_private::SourceManager::SetDefaultFileAndLine(), lldb_private::EvaluateExpressionOptions::SetGenerateDebugInfo(), lldb_private::CommandReturnObject::SetImmediateErrorStream(), lldb_private::CommandReturnObject::SetImmediateOutputStream(), lldb_private::IOHandler::SetIsDone(), lldb_private::EvaluateExpressionOptions::SetKeepInMemory(), lldb_private::EvaluateExpressionOptions::SetLanguage(), lldb_private::EvaluateExpressionOptions::SetPoundLine(), lldb_private::CommandInterpreter::SetPromptOnQuit(), lldb_private::EvaluateExpressionOptions::SetREPLEnabled(), lldb_private::Thread::SetSelectedFrameByIndex(), lldb_private::EvaluateExpressionOptions::SetUseDynamic(), lldb_private::StringList::SplitIntoLines(), lldb_private::Args::StripSpaces(), lldb_private::Status::Success(), lldb_private::Thread::UnwindInnermostExpression(), lldb_private::OptionGroupValueObjectDisplay::use_dynamic, lldb_private::OptionGroupValueObjectDisplay::use_objc, and lldb_private::File::Write().

Referenced by SetCompilerOptions().

◆ IOHandlerInputInterrupted()

void REPL::IOHandlerInputInterrupted ( IOHandler io_handler,
std::string &  line 
)
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 106 of file REPL.cpp.

Referenced by SetCompilerOptions().

◆ IOHandlerInterrupt()

bool REPL::IOHandlerInterrupt ( IOHandler io_handler)
overridevirtual

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 104 of file REPL.cpp.

Referenced by SetCompilerOptions().

◆ IOHandlerIsInputComplete()

bool REPL::IOHandlerIsInputComplete ( IOHandler io_handler,
StringList lines 
)
overridevirtual

Called to determine whether typing enter after the last line in lines should end input.

This function will not be called on IOHandler objects that are getting single lines.

Parameters
[in]io_handlerThe IOHandler that responsible for updating the lines.
[in]linesThe current multi-line content. May be altered to provide alternative input when complete.
Returns
Return an boolean to indicate whether input is complete, true indicates that no additional input is necessary, while false indicates that more input is required.

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 132 of file REPL.cpp.

References lldb_private::StringList::CopyList(), lldb_private::StringList::GetSize(), lldb_private::StringList::GetStringAtIndex(), and SourceIsComplete().

Referenced by SetCompilerOptions().

◆ PrintOneVariable()

virtual bool lldb_private::REPL::PrintOneVariable ( Debugger debugger,
lldb::StreamFileSP &  output_sp,
lldb::ValueObjectSP &  valobj_sp,
ExpressionVariable var = nullptr 
)
protectedpure virtual

◆ RunLoop()

Status REPL::RunLoop ( )

◆ SetCompilerOptions()

void lldb_private::REPL::SetCompilerOptions ( const char *  options)
inline

◆ SetEvaluateOptions()

void lldb_private::REPL::SetEvaluateOptions ( const EvaluateExpressionOptions options)
inline

Definition at line 68 of file REPL.h.

References m_expr_options.

◆ SetFormatOptions()

void lldb_private::REPL::SetFormatOptions ( const OptionGroupFormat options)
inline

Definition at line 59 of file REPL.h.

References m_format_options.

◆ SetValueObjectDisplayOptions()

void lldb_private::REPL::SetValueObjectDisplayOptions ( const OptionGroupValueObjectDisplay options)
inline

Definition at line 64 of file REPL.h.

References m_varobj_options.

◆ SourceIsComplete()

virtual bool lldb_private::REPL::SourceIsComplete ( const std::string &  source)
protectedpure virtual

Member Data Documentation

◆ m_code

StringList lldb_private::REPL::m_code
protected

Definition at line 151 of file REPL.h.

Referenced by IOHandlerComplete(), and IOHandlerInputComplete().

◆ m_compiler_options

std::string lldb_private::REPL::m_compiler_options
protected

Definition at line 141 of file REPL.h.

Referenced by SetCompilerOptions().

◆ m_current_indent_level

uint32_t lldb_private::REPL::m_current_indent_level = 0
protected

Definition at line 146 of file REPL.h.

◆ m_current_indent_str

std::string lldb_private::REPL::m_current_indent_str
protected

Definition at line 145 of file REPL.h.

◆ m_dedicated_repl_mode

bool lldb_private::REPL::m_dedicated_repl_mode = false
protected

Definition at line 149 of file REPL.h.

Referenced by IOHandlerInputComplete(), and RunLoop().

◆ m_enable_auto_indent

bool lldb_private::REPL::m_enable_auto_indent = true
protected

◆ m_expr_options

EvaluateExpressionOptions lldb_private::REPL::m_expr_options
protected

Definition at line 140 of file REPL.h.

Referenced by IOHandlerInputComplete(), and SetEvaluateOptions().

◆ m_format_options

OptionGroupFormat lldb_private::REPL::m_format_options = OptionGroupFormat(lldb::eFormatDefault)
protected

Definition at line 138 of file REPL.h.

Referenced by IOHandlerInputComplete(), REPL(), and SetFormatOptions().

◆ m_indent_str

std::string lldb_private::REPL::m_indent_str
protected

Definition at line 144 of file REPL.h.

Referenced by GetIOHandler(), and IOHandlerComplete().

◆ m_io_handler_sp

lldb::IOHandlerSP lldb_private::REPL::m_io_handler_sp
protected

Definition at line 154 of file REPL.h.

Referenced by GetIOHandler().

◆ m_kind

LLVMCastKind lldb_private::REPL::m_kind
protected

Definition at line 155 of file REPL.h.

Referenced by getKind().

◆ m_repl_source_path

std::string lldb_private::REPL::m_repl_source_path
protected

Definition at line 148 of file REPL.h.

Referenced by Create(), IOHandlerInputComplete(), and RunLoop().

◆ m_target

Target& lldb_private::REPL::m_target
protected

◆ m_varobj_options

OptionGroupValueObjectDisplay lldb_private::REPL::m_varobj_options
protected

Definition at line 139 of file REPL.h.

Referenced by IOHandlerInputComplete(), REPL(), and SetValueObjectDisplayOptions().


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