9#ifndef LLDB_CORE_IOHANDLER_H
10#define LLDB_CORE_IOHANDLER_H
13#include "lldb/Host/Config.h"
22#include "llvm/ADT/StringRef.h"
63 const lldb::FileSP &input_sp,
const lldb::StreamFileSP &output_sp,
64 const lldb::StreamFileSP &error_sp,
uint32_t flags);
70 virtual void Run() = 0;
163 virtual void PrintAsync(
const char *s,
size_t len,
bool is_stdout);
205 llvm::StringRef line);
236 int cursor_position) {
248 std::string &data) = 0;
251 std::string &data) {}
301 m_end_line((end_line && end_line[0]) ? end_line :
"") {}
314 const size_t num_lines = lines.
GetSize();
315 if (num_lines > 0 && lines[num_lines - 1] ==
m_end_line) {
331 const char *editline_name,
332 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
333 bool multi_line,
bool color_prompts,
340 const lldb::FileSP &input_sp,
341 const lldb::StreamFileSP &output_sp,
342 const lldb::StreamFileSP &error_sp,
uint32_t flags,
343 const char *editline_name,
344 llvm::StringRef prompt, llvm::StringRef continuation_prompt,
345 bool multi_line,
bool color_prompts,
356 const lldb::StreamFileSP &,
const lldb::StreamFileSP &,
357 uint32_t,
const char *,
const char *,
const char *,
bool,
390 bool SetPrompt(llvm::StringRef prompt)
override;
398 bool GetLine(std::string &line,
bool &interrupted);
412 void PrintAsync(
const char *s,
size_t len,
bool is_stdout)
override;
415#if LLDB_ENABLE_LIBEDIT
416 bool IsInputCompleteCallback(Editline *editline,
StringList &lines);
418 int FixIndentationCallback(Editline *editline,
const StringList &lines,
419 int cursor_position);
421 std::optional<std::string> SuggestionCallback(llvm::StringRef line);
427#if LLDB_ENABLE_LIBEDIT
428 std::unique_ptr<Editline> m_editline_up;
447 bool default_response);
457 std::string &data)
override;
469 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
475 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
476 sp->SetPopped(
false);
484 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
489 lldb::IOHandlerSP
sp;
491 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
499 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
512 bool IsTop(
const lldb::IOHandlerSP &io_handler_sp)
const {
513 return m_top == io_handler_sp.get();
518 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
519 const size_t num_io_handlers =
m_stack.size();
520 return (num_io_handlers >= 2 &&
521 m_stack[num_io_handlers - 1]->GetType() == top_type &&
522 m_stack[num_io_handlers - 2]->GetType() == second_top_type);
537 bool PrintAsync(
const char *s,
size_t len,
bool is_stdout);
"lldb/Utility/ArgCompletionRequest.h"
A uniqued constant string class.
A class to manage flag bits.
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
IOHandlerDelegateMultiline(const char *end_line, Completion completion=Completion::None)
ConstString IOHandlerGetControlSequence(char ch) override
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
~IOHandlerDelegateMultiline() override=default
const std::string m_end_line
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 const char * IOHandlerGetHelpPrologue()
virtual ConstString IOHandlerGetControlSequence(char ch)
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
ConstString GetControlSequence(char ch) override
bool SetPrompt(const char *prompt)=delete
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
const StringList * GetCurrentLines() const
std::string m_line_buffer
const char * GetPrompt() override
uint32_t GetCurrentLineIndex() const
void Deactivate() override
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)
ConstString 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 ConstString GetControlSequence(char ch)
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 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.