LLDB mainline
|
#include <REPL.h>
Public Types | |
enum | LLVMCastKind { eKindClang , eKindSwift , eKindGo , kNumKinds } |
![]() | |
enum class | Completion { None , LLDBCommand , 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. | |
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. | |
void | IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override |
Called when a line or lines have been retrieved. | |
void | IOHandlerComplete (IOHandler &io_handler, CompletionRequest &request) override |
![]() | |
IOHandlerDelegate (Completion completion=Completion::None) | |
virtual | ~IOHandlerDelegate ()=default |
virtual void | IOHandlerActivated (IOHandler &io_handler, bool interactive) |
virtual void | IOHandlerDeactivated (IOHandler &io_handler) |
virtual std::optional< std::string > | IOHandlerSuggestion (IOHandler &io_handler, llvm::StringRef line) |
virtual void | IOHandlerComplete (IOHandler &io_handler, CompletionRequest &request) |
virtual const char * | IOHandlerGetFixIndentationCharacters () |
virtual int | 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. | |
virtual void | IOHandlerInputComplete (IOHandler &io_handler, std::string &data)=0 |
Called when a line or lines have been retrieved. | |
virtual void | IOHandlerInputInterrupted (IOHandler &io_handler, std::string &data) |
virtual bool | IOHandlerIsInputComplete (IOHandler &io_handler, StringList &lines) |
Called to determine whether typing enter after the last line in lines should end input. | |
virtual ConstString | IOHandlerGetControlSequence (char ch) |
virtual const char * | IOHandlerGetCommandPrefix () |
virtual const char * | IOHandlerGetHelpPrologue () |
virtual bool | IOHandlerInterrupt (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. | |
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 ¤t_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 |
Target & | m_target |
lldb::IOHandlerSP | m_io_handler_sp |
LLVMCastKind | m_kind |
![]() | |
Completion | m_completion |
Private Member Functions | |
std::string | GetSourcePath () |
REPL::REPL | ( | LLVMCastKind | kind, |
Target & | target | ||
) |
Definition at line 25 of file REPL.cpp.
References lldb_private::Debugger::GetCommandInterpreter(), lldb_private::Target::GetDebugger(), lldb_private::CommandInterpreter::GetExecutionContext(), m_format_options, m_target, m_varobj_options, lldb_private::OptionGroupFormat::OptionParsingStarting(), lldb_private::OptionGroupValueObjectDisplay::OptionParsingStarting(), and lldb_private::Debugger::SetShowProgress().
|
overridedefault |
|
staticprotected |
Definition at line 152 of file REPL.cpp.
References lldb_private::StringList::GetSize().
Referenced by IOHandlerFixIndentation().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerComplete().
|
static |
Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler.
[out] | Status | If this language is supported but the REPL couldn't be created, this error is populated with the reason. |
[in] | language | The language to create a REPL for. |
[in] | debugger | If provided, and target is nullptr, the debugger to use when setting up a top-level REPL. |
[in] | target | If provided, the target to put the REPL inside. |
[in] | repl_options | If provided, additional options for the compiler when parsing REPL expressions. |
Definition at line 36 of file REPL.cpp.
References lldb_private::PluginManager::GetREPLCreateCallbackAtIndex(), and lldb_private::PluginManager::GetREPLSupportedLanguagesAtIndex().
Referenced by lldb_private::Target::GetREPL(), and lldb_private::Debugger::RunREPL().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by RunLoop().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerGetFixIndentationCharacters().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerFixIndentation().
lldb::IOHandlerSP REPL::GetIOHandler | ( | ) |
Definition at line 71 of file REPL.cpp.
References lldb_private::Debugger::GetAutoIndent(), lldb_private::Target::GetDebugger(), lldb_private::Debugger::GetTabSize(), m_enable_auto_indent, m_indent_str, m_io_handler_sp, m_target, and lldb_private::IOHandler::REPL.
Referenced by RunLoop().
|
inline |
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerInputComplete().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by GetSourcePath().
|
private |
Definition at line 57 of file REPL.cpp.
References lldb_private::FileSpec::AppendPathComponent(), lldb_private::FileSpec::GetPath(), GetSourceFileBasename(), lldb_private::ConstString::GetStringRef(), m_repl_source_path, and lldb_private::FileSpec::SetFilename().
Referenced by RunLoop().
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 100 of file REPL.cpp.
References lldb_private::IOHandler::GetErrorStreamFileSP(), lldb_private::Target::GetProcessSP(), m_target, and lldb_private::IOHandler::SetIsDone().
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 491 of file REPL.cpp.
References lldb_private::CompletionRequest::AddCompletion(), lldb_private::CompletionRequest::AddCompletions(), CompleteCode(), lldb_private::StringList::CopyList(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::IOHandlerEditline::GetCurrentLineIndex(), lldb_private::IOHandlerEditline::GetCurrentLines(), lldb_private::CompletionRequest::GetCursorIndex(), lldb_private::Target::GetDebugger(), lldb_private::CompletionResult::GetDescriptions(), lldb_private::CompletionResult::GetMatches(), lldb_private::CompletionRequest::GetRawCursorPos(), lldb_private::CompletionRequest::GetRawLine(), lldb_private::StringList::GetStringAtIndex(), lldb_private::CommandInterpreter::HandleCompletion(), m_code, m_indent_str, and m_target.
|
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.
[in] | io_handler | The IOHandler that responsible for input. |
[in] | lines | The current input up to the line to be corrected. Lines following the line containing the cursor are not included. |
[in] | cursor_position | The number of characters preceding the cursor on the final line at the time. |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 165 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.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 114 of file REPL.cpp.
References GetAutoIndentCharacters(), and m_enable_auto_indent.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
|
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 218 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::ExpressionVariableList::GetSize(), lldb_private::StringList::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, 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(), lldb_private::Status::Success(), lldb_private::Thread::UnwindInnermostExpression(), lldb_private::OptionGroupValueObjectDisplay::use_dynamic, and lldb_private::OptionGroupValueObjectDisplay::use_objc.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
|
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.
[in] | io_handler | The IOHandler that responsible for updating the lines. |
[in] | lines | The current multi-line content. May be altered to provide alternative input when complete. |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 138 of file REPL.cpp.
References lldb_private::StringList::CopyList(), lldb_private::StringList::GetSize(), lldb_private::StringList::GetStringAtIndex(), and SourceIsComplete().
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerInputComplete().
Status REPL::RunLoop | ( | ) |
Definition at line 556 of file REPL.cpp.
References DoInitialization(), error(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::CommandInterpreter::GetCommandObjectForCommand(), lldb_private::Target::GetDebugger(), lldb_private::SourceManager::GetDefaultFileAndLine(), GetIOHandler(), lldb_private::Target::GetProcessSP(), lldb_private::Target::GetSourceManager(), GetSourcePath(), lldb_private::Debugger::HasIOHandlerThread(), lldb_private::Debugger::JoinIOHandlerThread(), m_dedicated_repl_mode, m_repl_source_path, m_target, QuitCommandOverrideCallback(), lldb_private::Debugger::RunIOHandlerAsync(), lldb_private::SourceManager::SetDefaultFileAndLine(), lldb_private::CommandObject::SetOverrideCallback(), and lldb_private::Debugger::StartIOHandlerThread().
|
inline |
Definition at line 72 of file REPL.h.
References m_compiler_options.
|
inline |
Definition at line 68 of file REPL.h.
References m_expr_options.
|
inline |
Definition at line 59 of file REPL.h.
References m_format_options.
|
inline |
Definition at line 64 of file REPL.h.
References m_varobj_options.
|
protectedpure virtual |
Implemented in lldb_private::ClangREPL.
Referenced by IOHandlerIsInputComplete().
|
protected |
Definition at line 149 of file REPL.h.
Referenced by IOHandlerComplete(), and IOHandlerInputComplete().
|
protected |
Definition at line 139 of file REPL.h.
Referenced by SetCompilerOptions().
|
protected |
|
protected |
|
protected |
Definition at line 147 of file REPL.h.
Referenced by IOHandlerInputComplete(), and RunLoop().
|
protected |
Definition at line 141 of file REPL.h.
Referenced by GetIOHandler(), IOHandlerFixIndentation(), and IOHandlerGetFixIndentationCharacters().
|
protected |
Definition at line 138 of file REPL.h.
Referenced by IOHandlerInputComplete(), and SetEvaluateOptions().
|
protected |
Definition at line 136 of file REPL.h.
Referenced by IOHandlerInputComplete(), REPL(), and SetFormatOptions().
|
protected |
Definition at line 142 of file REPL.h.
Referenced by GetIOHandler(), and IOHandlerComplete().
|
protected |
Definition at line 152 of file REPL.h.
Referenced by GetIOHandler().
|
protected |
|
protected |
Definition at line 146 of file REPL.h.
Referenced by GetSourcePath(), IOHandlerInputComplete(), and RunLoop().
|
protected |
Definition at line 151 of file REPL.h.
Referenced by GetIOHandler(), IOHandlerActivated(), IOHandlerComplete(), IOHandlerInputComplete(), REPL(), and RunLoop().
|
protected |
Definition at line 137 of file REPL.h.
Referenced by IOHandlerInputComplete(), REPL(), and SetValueObjectDisplayOptions().