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.

Classes:

Functions:

  • get_io_driver

    Instances a new IODriver using the best strategy available in the current

  • make_pty

    We need to make a pseudo-terminal ourselves if we want the process to handle

Attributes:

TERM_CONTROL_AVAILABLE module-attribute ¤

TERM_CONTROL_AVAILABLE = True

SELECT_AVAILABLE module-attribute ¤

SELECT_AVAILABLE = True

PTY_AVAILABLE module-attribute ¤

PTY_AVAILABLE = True

TC_LFLAG module-attribute ¤

TC_LFLAG = 3

LIVE_PSEUDO_TERMINAL_OBJECTS module-attribute ¤

LIVE_PSEUDO_TERMINAL_OBJECTS = False

OpportunisticTerminalControl ¤

OpportunisticTerminalControl(fd: int = -1)

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.

'/dev/tty', and use that.

Methods:

  • get_line_buffering

    Gets the current state of line buffering for this terminal.

  • set_line_buffering

    Enables or disables line buffering for this terminal.

  • get_echo

    Gets the current state of echoing for this terminal.

  • set_echo

    Enables or disables echoing for this terminal.

Attributes:

fd instance-attribute ¤

fd: int = fd

supported instance-attribute ¤

supported: bool = True

get_line_buffering ¤

get_line_buffering() -> bool

Gets the current state of line buffering for this terminal.

set_line_buffering ¤

set_line_buffering(enabled: bool) -> None

Enables or disables line buffering for this terminal.

get_echo ¤

get_echo() -> bool

Gets the current state of echoing for this terminal.

set_echo ¤

set_echo(enabled: bool) -> None

Enables or disables echoing for this terminal.

IODriver ¤

Methods:

  • stdio

    The names for the stdin, stdout and stderr files, respectively. These

  • start

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

  • stop

    Stops the handling of I/O by this driver.

  • on_output_event

    Hints that there might be data in either the standard output or the

  • on_process_start

    Allow the I/O driver an opportunity to change aspects of the process

stdio ¤

stdio() -> tuple[str | None, str | None, str | None]

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

start ¤

start(process: Process) -> None

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

stop ¤

stop() -> None

Stops the handling of I/O by this driver.

on_output_event ¤

on_output_event() -> None

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 ¤

on_process_start(proc: SBProcess) -> None

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.

IODriverPlainText ¤

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.

Methods:

Attributes:

in_thr instance-attribute ¤

in_thr: Thread

out_thr instance-attribute ¤

out_thr: Thread

likely_output instance-attribute ¤

likely_output: BoundedSemaphore = BoundedSemaphore(1)

process instance-attribute ¤

process: SBProcess = None

stop_requested instance-attribute ¤

stop_requested: Event = Event()

stdio ¤

stdio() -> tuple[str | None, str | None, str | None]

on_output_event ¤

on_output_event() -> None

on_process_start ¤

on_process_start(proc: SBProcess) -> None

start ¤

start(process: Process) -> None

stop ¤

stop() -> None

IODriverPseudoTerminal ¤

IODriverPseudoTerminal(manager: int, worker: str)

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.

Methods:

Attributes:

io_thread instance-attribute ¤

io_thread: Thread

has_terminal_control instance-attribute ¤

has_terminal_control: bool

manager instance-attribute ¤

manager: int = manager

worker instance-attribute ¤

worker: str = worker

termcontrol instance-attribute ¤

stop_requested instance-attribute ¤

stop_requested: Event = Event()

input_buffer instance-attribute ¤

input_buffer: bytes = b''

process instance-attribute ¤

process: SBProcess = None

stdio ¤

stdio() -> tuple[str | None, str | None, str | None]

start ¤

start(process: Process) -> None

stop ¤

stop() -> None

on_output_event ¤

on_output_event() -> None

on_process_start ¤

on_process_start(proc: SBProcess) -> None

get_io_driver ¤

get_io_driver() -> IODriver

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 ¤

make_pty() -> tuple[str, int] | None

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.