Go to the documentation of this file.
9 #ifndef LLDB_CORE_IOHANDLER_H
10 #define LLDB_CORE_IOHANDLER_H
13 #include "lldb/Host/Config.h"
22 #include "llvm/ADT/StringRef.h"
65 const lldb::FileSP &input_sp,
const lldb::StreamFileSP &output_sp,
66 const lldb::StreamFileSP &error_sp,
uint32_t flags,
73 virtual void Run() = 0;
166 virtual void PrintAsync(
const char *s,
size_t len,
bool is_stdout);
209 llvm::StringRef line);
240 int cursor_position) {
305 m_end_line((end_line && end_line[0]) ? end_line :
"") {}
318 const size_t num_lines = lines.
GetSize();
319 if (num_lines > 0 && lines[num_lines - 1] ==
m_end_line) {
335 const char *editline_name,
336 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
337 bool multi_line,
bool color_prompts,
345 const lldb::FileSP &input_sp,
346 const lldb::StreamFileSP &output_sp,
347 const lldb::StreamFileSP &error_sp,
uint32_t flags,
348 const char *editline_name,
349 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
350 bool multi_line,
bool color_prompts,
362 const lldb::StreamFileSP &,
const lldb::StreamFileSP &,
363 uint32_t,
const char *,
const char *,
const char *,
bool,
396 bool SetPrompt(llvm::StringRef prompt)
override;
397 bool SetPrompt(
const char *prompt) =
delete;
418 void PrintAsync(
const char *s,
size_t len,
bool is_stdout)
override;
421 #if LLDB_ENABLE_LIBEDIT
422 bool IsInputCompleteCallback(Editline *editline,
StringList &lines);
424 int FixIndentationCallback(Editline *editline,
const StringList &lines,
425 int cursor_position);
427 llvm::Optional<std::string> SuggestionCallback(llvm::StringRef line);
433 #if LLDB_ENABLE_LIBEDIT
434 std::unique_ptr<Editline> m_editline_up;
453 bool default_response);
475 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
481 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
482 sp->SetPopped(
false);
490 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
495 lldb::IOHandlerSP
sp;
497 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
505 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
518 bool IsTop(
const lldb::IOHandlerSP &io_handler_sp)
const {
519 return m_top == io_handler_sp.get();
524 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
525 const size_t num_io_handlers =
m_stack.size();
526 return (num_io_handlers >= 2 &&
527 m_stack[num_io_handlers - 1]->GetType() == top_type &&
528 m_stack[num_io_handlers - 2]->GetType() == second_top_type);
543 bool PrintAsync(
const char *s,
size_t len,
bool is_stdout);
558 #endif // LLDB_CORE_IOHANDLER_H
void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) override
virtual void PrintAsync(const char *s, size_t len, bool is_stdout)
virtual bool IOHandlerInterrupt(IOHandler &io_handler)
ConstString GetControlSequence(char ch) override
bool IsTop(const lldb::IOHandlerSP &io_handler_sp) const
ConstString GetTopIOHandlerControlSequence(char ch)
void SetInterruptExits(bool b)
virtual void TerminalSizeChanged()
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.
IOHandlerDelegate & m_delegate
IOHandlerEditline(Debugger &debugger, IOHandler::Type type, const char *editline_name, llvm::StringRef prompt, llvm::StringRef continuation_prompt, bool multi_line, bool color_prompts, uint32_t line_number_start, IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, bool default_response)
const std::string m_end_line
virtual bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines)
Called to determine whether typing enter after the last line in lines should end input.
std::recursive_mutex m_mutex
virtual ConstString IOHandlerGetControlSequence(char ch)
void PrintAsync(const char *s, size_t len, bool is_stdout) override
virtual const char * IOHandlerGetFixIndentationCharacters()
const IOHandler & operator=(const IOHandler &)=delete
Recorder that records its data as text to a file.
const StringList * GetCurrentLines() const
bool GetLines(StringList &lines, bool &interrupted)
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
virtual void IOHandlerDeactivated(IOHandler &io_handler)
lldb::StreamFileSP m_output_sp
IOHandlerDelegate(Completion completion=Completion::None)
virtual const char * IOHandlerGetHelpPrologue()
bool GetIsRealTerminal()
Check if the input is coming from a real terminal.
repro::DataRecorder * m_data_recorder
std::vector< lldb::IOHandlerSP > collection
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
bool SetPrompt(llvm::StringRef prompt) override
uint32_t m_base_line_number
bool GetIsInteractive()
Check if the input is being supplied interactively by a user.
IOHandler(Debugger &debugger, IOHandler::Type type)
virtual ConstString GetControlSequence(char ch)
virtual const char * GetHelpPrologue()
Predicate< bool > m_popped
virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive)
virtual void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request)
string(SUBSTRING ${p} 10 -1 pStripped) if($
const char * GetContinuationPrompt()
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
void SetBaseLineNumber(uint32_t line)
const IOHandlerStack & operator=(const IOHandlerStack &)=delete
virtual void Deactivate()
uint32_t GetCurrentLineIndex() const
const char * GetTopIOHandlerCommandPrefix()
void Push(const lldb::IOHandlerSP &sp)
void SetContinuationPrompt(llvm::StringRef prompt)
StringList * m_current_lines_ptr
const Flags & GetFlags() const
bool Interrupt() override
const char * GetCommandPrefix() override
bool GetLine(std::string &line, bool &interrupted)
std::string m_continuation_prompt
void Deactivate() override
virtual bool Interrupt()=0
~IOHandlerDelegateMultiline() override=default
virtual void IOHandlerInputInterrupted(IOHandler &io_handler, std::string &data)
const char * GetHelpPrologue() override
lldb::FileSP GetInputFileSP()
lldb::StreamFileSP m_error_sp
std::unique_ptr< Application > ApplicationAP
~IOHandlerConfirm() override
virtual const char * IOHandlerGetCommandPrefix()
A delegate class for use with IOHandler subclasses.
A class that represents a running process on the host machine.
bool PrintAsync(const char *s, size_t len, bool is_stdout)
std::recursive_mutex & GetMutex()
virtual const char * GetCommandPrefix()
void TerminalSizeChanged() override
virtual llvm::Optional< std::string > IOHandlerSuggestion(IOHandler &io_handler, llvm::StringRef line)
~IOHandlerEditline() override
const char * GetPrompt() override
std::recursive_mutex m_output_mutex
const char * GetTopIOHandlerHelpPrologue()
const bool m_default_response
ConstString IOHandlerGetControlSequence(char ch) override
virtual void IOHandlerInputComplete(IOHandler &io_handler, std::string &data)=0
Called when a line or lines have been retrieved.
std::recursive_mutex & GetOutputMutex()
std::string m_line_buffer
void SetUserData(void *user_data)
lldb::StreamFileSP GetOutputStreamFileSP()
virtual bool SetPrompt(llvm::StringRef prompt)
virtual ~IOHandlerDelegate()=default
lldb::StreamFileSP GetErrorStreamFileSP()
virtual const char * GetPrompt()
IOHandlerDelegateMultiline(const char *end_line, Completion completion=Completion::None)