Skip to content

events ¤

Enables callbacks into functions to be automatically invoked when various events occur to the debuggee (e.g. STOP on SIGINT) by using a decorator.

Classes:

Functions:

Attributes:

DISABLED module-attribute ¤

DISABLED = 'disabled'

DISABLED_DEADLOCK module-attribute ¤

DISABLED_DEADLOCK = 'disabled-deadlock'

ENABLED module-attribute ¤

ENABLED = 'enabled'

gdb_workaround_stop_event module-attribute ¤

gdb_workaround_stop_event = add_param('gdb-workaround-stop-event', DISABLED, "asynchronous stop events to improve 'commands' functionality", help_docstring=f'
Note that this may cause unexpected behavior with Pwndbg or gdb.execute.

Values explained:

+ `{DISABLED}` - Disable the workaround (default).
+ `{DISABLED_DEADLOCK}` - Disable only deadlock detection; deadlocks may still occur.
+ `{ENABLED}` - Enable asynchronous stop events; gdb.execute may behave unexpectedly (asynchronously).
    ', param_class=PARAM_ENUM, enum_sequence=[DISABLED, DISABLED_DEADLOCK, ENABLED])

P module-attribute ¤

P = ParamSpec('P')

T module-attribute ¤

T = TypeVar('T')

queued_events module-attribute ¤

queued_events: Deque[Callable[..., Any]] = deque()

executing_event module-attribute ¤

executing_event = False

workaround_thread_conn module-attribute ¤

workaround_thread_conn = None

registered module-attribute ¤

registered: dict[
    EventRegistry[Any], dict[EventHandlerPriority, list[Callable[..., None]]]
] = {
    exited: {},
    cont: {},
    new_objfile: {},
    stop: {},
    start: {},
    new_thread: {},
    before_prompt: {},
    memory_changed: {},
    register_changed: {},
}

paused module-attribute ¤

paused = defaultdict(bool)

StartEvent ¤

StartEvent()

Methods:

Attributes:

registered instance-attribute ¤

registered: list[Callable[..., Any]] = []

running instance-attribute ¤

running = False

connect ¤

connect(function: Callable[..., Any]) -> None

disconnect ¤

disconnect(function: Callable[..., Any]) -> None

on_new_objfile ¤

on_new_objfile() -> None

on_exited ¤

on_exited() -> None

on_stop ¤

on_stop() -> None

wrap_safe_event_handler ¤

wrap_safe_event_handler(
    event_handler: Callable[P, T], event_type: Any
) -> Callable[P, T]

Wraps an event handler to ensure it is only executed when the event is safe. Invalid events are queued and executed later when safe.

Note: Avoid using gdb.post_event because of another bug in gdbserver where the gdb.newest_frame function may not work properly.

Workaround to fix bug in gdbserver (gdb.events.new_objfile): #2576 Workaround to fix bug in gdb (gdb.events.stop): #425

pause ¤

pause(event_registry: EventRegistry[Any]) -> None

unpause ¤

unpause(event_registry: EventRegistry[Any]) -> None

event_handler_factory ¤

event_handler_factory(
    event_registry: EventRegistry[Any],
    event_name: str,
    priority: EventHandlerPriority,
) -> Callable[[Callable[..., None]], Callable[..., None]]

Essentially the implementation of pwndbg.dbg_mod.gdb.event_handler().

Takes a gdb.EventRegistry because that contains some events that pwndbg.dbg_mod.EventType doesn't.

Read the first few paragraphs of: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Events-In-Python.html#Events-In-Python

log_objfiles ¤

log_objfiles(ofile: NewObjFileEvent | None = None) -> None

invoke_event ¤

invoke_event(
    event_registry: EventRegistry[Any], event_data: Any = None
) -> None

Invoke all registered handlers for a certain event_registry. event_data may be None if we manually ran this function.

after_reload ¤

after_reload(fire_start: bool = True) -> None

on_reload ¤

on_reload() -> None