9#ifndef LLDB_CORE_IOHANDLER_H
10#define LLDB_CORE_IOHANDLER_H
13#include "lldb/Host/Config.h"
21#include "llvm/ADT/StringRef.h"
69 virtual void Run() = 0;
162 virtual void PrintAsync(
const char *s,
size_t len,
bool is_stdout);
204 llvm::StringRef line);
235 int cursor_position) {
247 std::string &data) = 0;
250 std::string &data) {}
310 const size_t num_lines = lines.
GetSize();
311 const llvm::StringRef end_line =
313 if (num_lines > 0 && llvm::StringRef(lines[num_lines - 1]) == end_line) {
329 const char *editline_name,
330 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
331 bool multi_line,
bool color,
332 uint32_t line_number_start,
341 const char *editline_name,
342 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
343 bool multi_line,
bool color,
344 uint32_t line_number_start,
350 const char *,
bool,
bool, uint32_t,
355 uint32_t,
const char *,
const char *,
const char *,
bool,
388 bool SetPrompt(llvm::StringRef prompt)
override;
396 bool GetLine(std::string &line,
bool &interrupted);
410 void PrintAsync(
const char *s,
size_t len,
bool is_stdout)
override;
413#if LLDB_ENABLE_LIBEDIT
417 int cursor_position);
419 std::optional<std::string> SuggestionCallback(llvm::StringRef line);
425#if LLDB_ENABLE_LIBEDIT
426 std::unique_ptr<Editline> m_editline_up;
445 bool default_response);
455 std::string &data)
override;
467 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
473 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
474 sp->SetPopped(
false);
482 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
489 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
497 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
511 return m_top == io_handler_sp.get();
516 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
517 const size_t num_io_handlers =
m_stack.size();
518 return (num_io_handlers >= 2 &&
519 m_stack[num_io_handlers - 1]->GetType() == top_type &&
520 m_stack[num_io_handlers - 2]->GetType() == second_top_type);
525 : llvm::StringRef());
536 bool PrintAsync(
const char *s,
size_t len,
bool is_stdout);
"lldb/Utility/ArgCompletionRequest.h"
A class to manage flag bits.
Instances of Editline provide an abstraction over libedit's EditLine facility.
Encapsulates a single expression for use in lldb.
const bool m_default_response
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) override
~IOHandlerConfirm() override
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
llvm::StringRef IOHandlerGetControlSequence(char ch) override
~IOHandlerDelegateMultiline() override=default
const std::string m_end_line
IOHandlerDelegateMultiline(llvm::StringRef end_line, Completion completion=Completion::None)
A delegate class for use with IOHandler subclasses.
virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive)
virtual void IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request)
virtual const char * IOHandlerGetFixIndentationCharacters()
virtual llvm::StringRef IOHandlerGetControlSequence(char ch)
virtual const char * IOHandlerGetHelpPrologue()
virtual void IOHandlerInputComplete(IOHandler &io_handler, std::string &data)=0
Called when a line or lines have been retrieved.
virtual bool IOHandlerInterrupt(IOHandler &io_handler)
virtual void IOHandlerDeactivated(IOHandler &io_handler)
virtual bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines)
Called to determine whether typing enter after the last line in lines should end input.
virtual std::optional< std::string > IOHandlerSuggestion(IOHandler &io_handler, llvm::StringRef line)
virtual ~IOHandlerDelegate()=default
IOHandlerDelegate(Completion completion=Completion::None)
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 const char * IOHandlerGetCommandPrefix()
virtual void IOHandlerInputInterrupted(IOHandler &io_handler, std::string &data)
void PrintAsync(const char *s, size_t len, bool is_stdout) override
bool SetPrompt(llvm::StringRef prompt) override
bool Interrupt() override
const char * GetHelpPrologue() override
bool GetLine(std::string &line, bool &interrupted)
const char * GetCommandPrefix() override
void TerminalSizeChanged() override
~IOHandlerEditline() override
uint32_t m_base_line_number
bool GetLines(StringList &lines, bool &interrupted)
std::string m_continuation_prompt
bool SetPrompt(const char *prompt)=delete
llvm::StringRef GetControlSequence(char ch) override
void SetContinuationPrompt(const char *)=delete
const char * GetContinuationPrompt()
IOHandlerEditline(Debugger &, IOHandler::Type, const lldb::FileSP &, const lldb::StreamFileSP &, const lldb::StreamFileSP &, uint32_t, const char *, const char *, const char *, bool, bool, uint32_t, IOHandlerDelegate &)=delete
void SetBaseLineNumber(uint32_t line)
void SetContinuationPrompt(llvm::StringRef prompt)
StringList * m_current_lines_ptr
void SetInterruptExits(bool b)
IOHandlerDelegate & m_delegate
std::string m_line_buffer
const char * GetPrompt() override
uint32_t GetCurrentLineIndex() const
void Deactivate() override
StringList GetCurrentLines() const
IOHandlerEditline(Debugger &, IOHandler::Type, const char *, const char *, const char *, bool, bool, uint32_t, IOHandlerDelegate &)=delete
const char * GetTopIOHandlerHelpPrologue()
const IOHandlerStack & operator=(const IOHandlerStack &)=delete
bool PrintAsync(const char *s, size_t len, bool is_stdout)
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
bool IsTop(const lldb::IOHandlerSP &io_handler_sp) const
void Push(const lldb::IOHandlerSP &sp)
std::recursive_mutex & GetMutex()
IOHandlerStack(const IOHandlerStack &)=delete
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
std::recursive_mutex m_mutex
std::vector< lldb::IOHandlerSP > collection
const char * GetTopIOHandlerCommandPrefix()
virtual void TerminalSizeChanged()
const Flags & GetFlags() const
virtual void PrintAsync(const char *s, size_t len, bool is_stdout)
Predicate< bool > m_popped
virtual bool SetPrompt(llvm::StringRef prompt)
virtual const char * GetHelpPrologue()
lldb::StreamFileSP GetErrorStreamFileSP()
bool GetIsRealTerminal()
Check if the input is coming from a real terminal.
virtual const char * GetPrompt()
lldb::FileSP GetInputFileSP()
std::recursive_mutex & GetOutputMutex()
virtual bool Interrupt()=0
const IOHandler & operator=(const IOHandler &)=delete
std::recursive_mutex m_output_mutex
virtual void Deactivate()
lldb::StreamFileSP m_error_sp
virtual llvm::StringRef GetControlSequence(char ch)
virtual const char * GetCommandPrefix()
lldb::StreamFileSP GetOutputStreamFileSP()
bool GetIsInteractive()
Check if the input is being supplied interactively by a user.
bool SetPrompt(const char *)=delete
lldb::StreamFileSP m_output_sp
IOHandler(const IOHandler &)=delete
void SetUserData(void *user_data)
A C++ wrapper class for providing threaded access to a value of type T.
std::unique_ptr< Application > ApplicationAP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::StreamFile > StreamFileSP
std::shared_ptr< lldb_private::File > FileSP