Skip to content

Io

For our REPL, we need to drive our own I/O with the process being debugged. This module contains all the strategies we have for doing that.

LIVE_PSEUDO_TERMINAL_OBJECTS = False module-attribute

PTY_AVAILABLE = True module-attribute

SELECT_AVAILABLE = True module-attribute

TC_LFLAG = 3 module-attribute

TERM_CONTROL_AVAILABLE = True module-attribute

IODriver

on_output_event()

Hints that there might be data in either the standard output or the standard error streams. This should be called when an eBroadcastBitSTDOUT or eBroadcastBitSTDERR is encountered by the event loop.

on_process_start(proc)

Allow the I/O driver an opportunity to change aspects of the process after it has been launched, but before it has started executing, if it so wishes.

start(process)

Starts the handling of I/O by this driver on the given process.

stdio()

The names for the stdin, stdout and stderr files, respectively. These will get passed as arguments to SBTarget.Launch

stop()

Stops the handling of I/O by this driver.

IODriverPlainText

Bases: IODriver

Plaintext-based I/O driver. It simply copies input from our standard input to the standard input of a given process, and copies output from the standard output of a given process to out standard output.

in_thr: threading.Thread instance-attribute

likely_output: threading.BoundedSemaphore = threading.BoundedSemaphore(1) instance-attribute

out_thr: threading.Thread instance-attribute

process: lldb.SBProcess = None instance-attribute

stop_requested: threading.Event = threading.Event() instance-attribute

__init__()

on_output_event()

on_process_start(proc)

start(process)

stdio()

stop()

IODriverPseudoTerminal

Bases: IODriver

pty-based I/O driver. Forwards input from standard input and has support for terminal width and height, and for terminal-based file operations on the program being debugged.

has_terminal_control: bool instance-attribute

input_buffer: bytes = b'' instance-attribute

io_thread: threading.Thread instance-attribute

manager: int = manager instance-attribute

process: lldb.SBProcess = None instance-attribute

stop_requested: threading.Event = threading.Event() instance-attribute

termcontrol: OpportunisticTerminalControl = OpportunisticTerminalControl() instance-attribute

worker: str = worker instance-attribute

__init__(manager, worker)

on_output_event()

on_process_start(proc)

start(process)

stdio()

stop()

OpportunisticTerminalControl

Handles optional terminal control for a given file descriptor. Crucially, all the functions in this class should work regardless of whether terminal control is actually supported on not, but should do nothing in case it is not supported.

fd: int = fd instance-attribute

supported: bool = True instance-attribute

__init__(fd=-1)

Creates an opportunistic terminal control object for the given file descriptor. If no file descriptor is given, this class will try to open '/dev/tty', and use that.

get_echo()

Gets the current state of echoing for this terminal.

get_line_buffering()

Gets the current state of line buffering for this terminal.

set_echo(enabled)

Enables or disables echoing for this terminal.

set_line_buffering(enabled)

Enables or disables line buffering for this terminal.

get_io_driver()

Instances a new IODriver using the best strategy available in the current system. Meaning a PTY on Unix and plain text on Windows.

make_pty()

We need to make a pseudo-terminal ourselves if we want the process to handle naturally for the user. Returns a tuple with the path of the worker device and the file descriptor of the manager device if successful.