LLDB mainline
|
#include <REPL.h>
Public Member Functions | |
REPL (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 |
llvm::StringRef | 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 |
Public Member Functions inherited from lldb_private::IOHandlerDelegate | |
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 llvm::StringRef | 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. | |
Static Public Attributes | |
static char | ID |
LLVM RTTI support. | |
Protected Member Functions | |
virtual llvm::Error | OnExpressionEvaluated (const ExecutionContext &exe_ctx, llvm::StringRef code, const EvaluateExpressionOptions &expr_options, lldb::ExpressionResults execution_results, const lldb::ValueObjectSP &result_valobj_sp, const Status &error) |
Method that can be optionally overriden by subclasses to get notified whenever an expression has been evaluated. | |
virtual Status | DoInitialization ()=0 |
virtual llvm::StringRef | 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 |
Protected Attributes inherited from lldb_private::IOHandlerDelegate | |
Completion | m_completion |
Private Member Functions | |
std::string | GetSourcePath () |
Additional Inherited Members | |
Public Types inherited from lldb_private::IOHandlerDelegate | |
enum class | Completion { None , LLDBCommand , Expression } |
REPL::REPL | ( | Target & | target | ) |
Definition at line 27 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 155 of file REPL.cpp.
References lldb_private::StringList::GetSize().
Referenced by IOHandlerFixIndentation().
|
protectedpure virtual |
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 38 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 |
Referenced by RunLoop().
|
protectedpure virtual |
Referenced by IOHandlerGetFixIndentationCharacters().
|
protectedpure virtual |
Referenced by IOHandlerFixIndentation().
lldb::IOHandlerSP REPL::GetIOHandler | ( | ) |
Definition at line 73 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().
|
protectedpure virtual |
Referenced by IOHandlerInputComplete().
|
protectedpure virtual |
Referenced by GetSourcePath().
|
private |
Definition at line 59 of file REPL.cpp.
References lldb_private::FileSpec::AppendPathComponent(), lldb_private::FileSpec::GetPath(), GetSourceFileBasename(), m_repl_source_path, and lldb_private::FileSpec::SetFilename().
Referenced by RunLoop().
|
overridevirtual |
Reimplemented from lldb_private::IOHandlerDelegate.
Definition at line 102 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 497 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::GetSize(), 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 168 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 116 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 221 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(), DoNoSelectMostRelevantFrame, 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, OnExpressionEvaluated(), 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 141 of file REPL.cpp.
References lldb_private::StringList::CopyList(), lldb_private::StringList::GetSize(), lldb_private::StringList::GetStringAtIndex(), and SourceIsComplete().
|
inlineprotectedvirtual |
Method that can be optionally overriden by subclasses to get notified whenever an expression has been evaluated.
The params of this method include the inputs and outputs of the expression evaluation.
Note: meta commands that start with : are not covered by this method.
Definition at line 120 of file REPL.h.
Referenced by IOHandlerInputComplete().
|
protectedpure virtual |
Referenced by IOHandlerInputComplete().
Status REPL::RunLoop | ( | ) |
Definition at line 560 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 |
Referenced by IOHandlerIsInputComplete().
|
protected |
Definition at line 167 of file REPL.h.
Referenced by IOHandlerComplete(), and IOHandlerInputComplete().
|
protected |
Definition at line 157 of file REPL.h.
Referenced by SetCompilerOptions().
|
protected |
|
protected |
|
protected |
Definition at line 165 of file REPL.h.
Referenced by IOHandlerInputComplete(), and RunLoop().
|
protected |
Definition at line 159 of file REPL.h.
Referenced by GetIOHandler(), IOHandlerFixIndentation(), and IOHandlerGetFixIndentationCharacters().
|
protected |
Definition at line 156 of file REPL.h.
Referenced by IOHandlerInputComplete(), and SetEvaluateOptions().
|
protected |
Definition at line 154 of file REPL.h.
Referenced by IOHandlerInputComplete(), REPL(), and SetFormatOptions().
|
protected |
Definition at line 160 of file REPL.h.
Referenced by GetIOHandler(), and IOHandlerComplete().
|
protected |
Definition at line 170 of file REPL.h.
Referenced by GetIOHandler().
|
protected |
Definition at line 164 of file REPL.h.
Referenced by GetSourcePath(), IOHandlerInputComplete(), and RunLoop().
|
protected |
Definition at line 169 of file REPL.h.
Referenced by GetIOHandler(), IOHandlerActivated(), IOHandlerComplete(), IOHandlerInputComplete(), REPL(), and RunLoop().
|
protected |
Definition at line 155 of file REPL.h.
Referenced by IOHandlerInputComplete(), REPL(), and SetValueObjectDisplayOptions().