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

#include <REPL.h>

Inheritance diagram for lldb_private::REPL:
Inheritance graph
Collaboration diagram for lldb_private::REPL:
Collaboration graph

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...
void IOHandlerComplete (IOHandler &io_handler, CompletionRequest &request) override
- Public Member Functions inherited from lldb_private::IOHandlerDelegate
 IOHandlerDelegate (Completion completion=Completion::None)
virtual ~IOHandlerDelegate ()=default
virtual void IOHandlerDeactivated (IOHandler &io_handler)
virtual llvm::Optional< std::stringIOHandlerSuggestion (IOHandler &io_handler, llvm::StringRef line)

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 void CompleteCode (const std::string &current_code, CompletionRequest &request)=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
lldb::IOHandlerSP m_io_handler_sp
LLVMCastKind m_kind
- Protected Attributes inherited from lldb_private::IOHandlerDelegate
Completion m_completion

Private Member Functions

std::string GetSourcePath ()

Detailed Description

Definition at line 21 of file REPL.h.

Member Enumeration Documentation

◆ LLVMCastKind


Definition at line 24 of file REPL.h.

Constructor & Destructor Documentation

◆ REPL()

REPL::REPL ( LLVMCastKind  kind,
Target target 

◆ ~REPL()


Member Function Documentation

◆ CalculateActualIndentation()

int REPL::CalculateActualIndentation ( const StringList lines)

Definition at line 147 of file REPL.cpp.

References lldb_private::StringList::GetSize(), and string().

Referenced by IOHandlerFixIndentation().

◆ CompleteCode()

virtual void lldb_private::REPL::CompleteCode ( const std::string current_code,
CompletionRequest request 
protectedpure virtual

Referenced by IOHandlerComplete().

◆ Create()

lldb::REPLSP REPL::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.

[out]StatusIf 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.
The range of the containing object in the target process.

Definition at line 35 of file REPL.cpp.

References lldb_private::PluginManager::GetREPLCreateCallbackAtIndex().

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

◆ DoInitialization()

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

Referenced by RunLoop().

◆ 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

Referenced by IOHandlerFixIndentation().

◆ GetIOHandler()

lldb::IOHandlerSP REPL::GetIOHandler ( )

◆ getKind()

LLVMCastKind lldb_private::REPL::getKind ( ) const

Definition at line 26 of file REPL.h.

References m_kind.

◆ GetLanguage()

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

Referenced by IOHandlerInputComplete().

◆ GetSourceFileBasename()

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

Referenced by GetSourcePath().

◆ GetSourcePath()

std::string REPL::GetSourcePath ( )

◆ IOHandlerActivated()

void REPL::IOHandlerActivated ( IOHandler io_handler,
bool  interactive 

◆ IOHandlerComplete()

void REPL::IOHandlerComplete ( IOHandler io_handler,
CompletionRequest request 

◆ IOHandlerFixIndentation()

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

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.

[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 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 160 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.

◆ IOHandlerGetCommandPrefix()

const char * REPL::IOHandlerGetCommandPrefix ( )

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 119 of file REPL.cpp.

◆ IOHandlerGetControlSequence()

ConstString REPL::IOHandlerGetControlSequence ( char  ch)

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 113 of file REPL.cpp.

◆ IOHandlerGetFixIndentationCharacters()

const char * REPL::IOHandlerGetFixIndentationCharacters ( )

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 109 of file REPL.cpp.

References GetAutoIndentCharacters(), and m_enable_auto_indent.

◆ IOHandlerGetHelpPrologue()

const char * REPL::IOHandlerGetHelpPrologue ( )

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 121 of file REPL.cpp.

◆ IOHandlerInputComplete()

void REPL::IOHandlerInputComplete ( IOHandler io_handler,
std::string data 

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 213 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::IOHandler::CommandInterpreter, lldb_private::StringList::CopyList(), lldb::eExpressionCompleted, lldb::eExpressionDiscarded, lldb::eExpressionHitBreakpoint, lldb::eExpressionInterrupted, lldb::eExpressionParseError, lldb::eExpressionResultUnavailable, lldb::eExpressionSetupError, lldb::eExpressionStoppedForDebug, lldb::eExpressionThreadVanished, lldb::eExpressionTimedOut, lldb::eFormatVoid, lldb_private::eLazyBoolNo, lldb_private::File::eOpenOptionCanCreate, lldb_private::File::eOpenOptionTruncate, lldb_private::File::eOpenOptionWriteOnly, lldb::eReturnStatusQuit, error(), lldb_private::UserExpression::Evaluate(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::Target::GetDebugger(), lldb_private::IOHandler::GetErrorStreamFileSP(), lldb_private::OptionGroupFormat::GetFormat(), lldb_private::CommandInterpreter::GetIOHandler(), GetLanguage(), lldb_private::Debugger::GetNotifyVoid(), lldb_private::IOHandler::GetOutputStreamFileSP(), lldb_private::Target::GetPersistentExpressionStateForLanguage(), lldb_private::Debugger::GetPrintDecls(), lldb_private::ExecutionContext::GetProcessSP(), 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::ExecutionContext::GetThreadPtr(), lldb_private::Debugger::GetUseColor(), 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, message(), lldb_private::FileSystem::Open(), PrintOneVariable(), ReadCode(), lldb_private::IOHandler::REPL, lldb_private::Debugger::RunIOHandlerAsync(), lldb_private::EvaluateExpressionOptions::SetCoerceToId(), lldb_private::EvaluateExpressionOptions::SetColorizeErrors(), lldb_private::SourceManager::SetDefaultFileAndLine(), lldb_private::ExecutionContext::SetFrameSP(), 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(), string(), lldb_private::Status::Success(), lldb_private::toString(), lldb_private::Thread::UnwindInnermostExpression(), lldb_private::OptionGroupValueObjectDisplay::use_dynamic, and lldb_private::OptionGroupValueObjectDisplay::use_objc.

◆ IOHandlerInputInterrupted()

void REPL::IOHandlerInputInterrupted ( IOHandler io_handler,
std::string line 

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 106 of file REPL.cpp.

◆ IOHandlerInterrupt()

bool REPL::IOHandlerInterrupt ( IOHandler io_handler)

Reimplemented from lldb_private::IOHandlerDelegate.

Definition at line 104 of file REPL.cpp.

◆ IOHandlerIsInputComplete()

bool REPL::IOHandlerIsInputComplete ( IOHandler io_handler,
StringList lines 

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.

[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.
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 133 of file REPL.cpp.

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

◆ PrintOneVariable()

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

Referenced by IOHandlerInputComplete().

◆ RunLoop()

Status REPL::RunLoop ( )

◆ SetCompilerOptions()

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

Definition at line 72 of file REPL.h.

References m_compiler_options.

◆ SetEvaluateOptions()

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

Definition at line 68 of file REPL.h.

References m_expr_options.

◆ SetFormatOptions()

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

Definition at line 59 of file REPL.h.

References m_format_options.

◆ SetValueObjectDisplayOptions()

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

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

Definition at line 149 of file REPL.h.

Referenced by IOHandlerComplete(), and IOHandlerInputComplete().

◆ m_compiler_options

std::string lldb_private::REPL::m_compiler_options

Definition at line 139 of file REPL.h.

Referenced by SetCompilerOptions().

◆ m_current_indent_level

uint32_t lldb_private::REPL::m_current_indent_level = 0

Definition at line 144 of file REPL.h.

◆ m_current_indent_str

std::string lldb_private::REPL::m_current_indent_str

Definition at line 143 of file REPL.h.

◆ m_dedicated_repl_mode

bool lldb_private::REPL::m_dedicated_repl_mode = false

Definition at line 147 of file REPL.h.

Referenced by IOHandlerInputComplete(), and RunLoop().

◆ m_enable_auto_indent

bool lldb_private::REPL::m_enable_auto_indent = true

◆ m_expr_options

EvaluateExpressionOptions lldb_private::REPL::m_expr_options

Definition at line 138 of file REPL.h.

Referenced by IOHandlerInputComplete(), and SetEvaluateOptions().

◆ m_format_options

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

Definition at line 136 of file REPL.h.

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

◆ m_indent_str

std::string lldb_private::REPL::m_indent_str

Definition at line 142 of file REPL.h.

Referenced by GetIOHandler(), and IOHandlerComplete().

◆ m_io_handler_sp

lldb::IOHandlerSP lldb_private::REPL::m_io_handler_sp

Definition at line 152 of file REPL.h.

Referenced by GetIOHandler().

◆ m_kind

LLVMCastKind lldb_private::REPL::m_kind

Definition at line 153 of file REPL.h.

Referenced by getKind().

◆ m_repl_source_path

std::string lldb_private::REPL::m_repl_source_path

Definition at line 146 of file REPL.h.

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

◆ m_target

Target& lldb_private::REPL::m_target

◆ m_varobj_options

OptionGroupValueObjectDisplay lldb_private::REPL::m_varobj_options

Definition at line 137 of file REPL.h.

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

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