9#ifndef LLDB_CORE_IOHANDLER_H
10#define LLDB_CORE_IOHANDLER_H
12#include "lldb/Host/Config.h"
20#include "llvm/ADT/StringRef.h"
64 virtual void Run() = 0;
159 virtual void PrintAsync(
const char *s,
size_t len,
bool is_stdout);
198 llvm::StringRef line);
229 int cursor_position) {
241 std::string &data) = 0;
244 std::string &data) {}
304 const size_t num_lines = lines.
GetSize();
305 const llvm::StringRef end_line =
307 if (num_lines > 0 && llvm::StringRef(lines[num_lines - 1]) == end_line) {
323 const char *editline_name,
324 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
325 bool multi_line,
bool color,
326 uint32_t line_number_start,
335 const char *editline_name,
336 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
337 bool multi_line,
bool color,
338 uint32_t line_number_start,
344 const char *,
bool,
bool, uint32_t,
350 const char *,
const char *,
bool,
bool, uint32_t,
370 return m_delegate.IOHandlerGetControlSequence(ch);
374 return m_delegate.IOHandlerGetCommandPrefix();
383 bool SetPrompt(llvm::StringRef prompt)
override;
393 bool GetLine(std::string &line,
bool &interrupted);
407 void PrintAsync(
const char *s,
size_t len,
bool is_stdout)
override;
412#if LLDB_ENABLE_LIBEDIT
416 int cursor_position);
418 std::optional<std::string> SuggestionCallback(llvm::StringRef line);
422 void RedrawCallback();
426#if LLDB_ENABLE_LIBEDIT
427 std::unique_ptr<Editline> m_editline_up;
446 bool default_response);
456 std::string &data)
override;
468 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
474 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
475 sp->SetPopped(
false);
483 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
490 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
498 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
512 return m_top == io_handler_sp.get();
517 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
518 const size_t num_io_handlers =
m_stack.size();
519 return (num_io_handlers >= 2 &&
520 m_stack[num_io_handlers - 1]->GetType() == top_type &&
521 m_stack[num_io_handlers - 2]->GetType() == second_top_type);
525 return ((
m_top !=
nullptr) ?
m_top->GetControlSequence(ch)
526 : llvm::StringRef());
530 return ((
m_top !=
nullptr) ?
m_top->GetCommandPrefix() :
nullptr);
534 return ((
m_top !=
nullptr) ?
m_top->GetHelpPrologue() :
nullptr);
537 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.
const bool m_default_response
IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, bool 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)
IOHandlerEditline(Debugger &, IOHandler::Type, const lldb::FileSP &, const lldb::LockableStreamFileSP &, const lldb::LockableStreamFileSP &, uint32_t, const char *, const char *, const char *, bool, bool, uint32_t, IOHandlerDelegate &)=delete
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()
void SetBaseLineNumber(uint32_t line)
IOHandlerEditline(Debugger &debugger, IOHandler::Type type, const char *editline_name, llvm::StringRef prompt, llvm::StringRef continuation_prompt, bool multi_line, bool color, uint32_t line_number_start, IOHandlerDelegate &delegate)
void SetContinuationPrompt(llvm::StringRef prompt)
StringList * m_current_lines_ptr
void SetInterruptExits(bool b)
IOHandlerDelegate & m_delegate
bool SetUseColor(bool use_color) override
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()
virtual bool SetUseColor(bool use_color)
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()
bool GetIsRealTerminal()
Check if the input is coming from a real terminal.
virtual const char * GetPrompt()
lldb::FileSP GetInputFileSP()
virtual bool Interrupt()=0
const IOHandler & operator=(const IOHandler &)=delete
virtual void Deactivate()
lldb::LockableStreamFileSP m_output_sp
virtual llvm::StringRef GetControlSequence(char ch)
lldb::LockableStreamFileSP m_error_sp
virtual const char * GetCommandPrefix()
IOHandler(Debugger &debugger, IOHandler::Type type)
bool GetIsInteractive()
Check if the input is being supplied interactively by a user.
bool SetPrompt(const char *)=delete
lldb::LockableStreamFileSP GetErrorStreamFileSP()
IOHandler(const IOHandler &)=delete
lldb::LockableStreamFileSP GetOutputStreamFileSP()
void SetUserData(void *user_data)
A C++ wrapper class for providing threaded access to a value of type T.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
std::shared_ptr< lldb_private::File > FileSP