Skip to main content
`Ctrl`+`K`

# libdebug.interfaces package

## Submodules

## libdebug.interfaces.debugging_interface module

class libdebug.interfaces.debugging_interface.DebuggingInterface

  Bases: `ABC`

  The interface used by _InternalDebugger to communicate with the available debugging backends, such as ptrace or gdb.

  abstract reset() → None

    Resets the state of the interface.

  abstract run() → None

    Runs the specified process.

  abstract attach(pid: int) → None

    Attaches to the specified process.

    Parameters:

      pid (int) – the pid of the process to attach to.

  abstract detach() → None

    Detaches from the process.

  abstract kill() → None

    Instantly terminates the process.

  abstract cont() → None

    Continues the execution of the process.

  abstract wait() → None

    Waits for the process to stop.

  abstract migrate_to_gdb() → None

    Migrates the current process to GDB.

  abstract migrate_from_gdb() → None

    Migrates the current process from GDB.

  abstract step(thread: ThreadContext) → None

    Executes a single instruction of the specified thread.

    Parameters:

      thread (ThreadContext) – The thread to step.

  abstract step_until(thread: ThreadContext, address: int, max_steps: int) → None

    Executes instructions of the specified thread until the specified address is reached.

    Parameters:

      - thread (ThreadContext) – The thread to step.

      - address (int) – The address to reach.

      - max_steps (int) – The maximum number of steps to execute.

  abstract finish(thread: ThreadContext, heuristic: str) → None

    Continues execution until the current function returns or the process stops.

    The command requires a heuristic to determine the end of the function. The available heuristics are: - backtrace: The debugger will place a breakpoint on the saved return address found on the stack and continue execution on all threads. - step-mode: The debugger will step on the specified thread until the current function returns. This will be slower.

    Parameters:

      - thread (ThreadContext) – The thread to finish.

      - heuristic (str, optional) – The heuristic to use. Defaults to “backtrace”.

  abstract maps() → list[MemoryMap]

    Returns the memory maps of the process.

  abstract set_breakpoint(bp: Breakpoint) → None

    Sets a breakpoint at the specified address.

    Parameters:

      bp (Breakpoint) – The breakpoint to set.

  abstract unset_breakpoint(bp: Breakpoint) → None

    Restores the original instruction flow at the specified address.

    Parameters:

      bp (Breakpoint) – The breakpoint to restore.

  abstract set_syscall_handler(handler: SyscallHandler) → None

    Sets a handler for a syscall.

    Parameters:

      handler (HandledSyscall) – The syscall to set.

  abstract unset_syscall_handler(handler: SyscallHandler) → None

    Unsets a handler for a syscall.

    Parameters:

      handler (HandledSyscall) – The syscall to unset.

  abstract set_signal_catcher(catcher: SignalCatcher) → None

    Sets a catcher for a signal.

    Parameters:

      catcher (CaughtSignal) – The signal to set.

  abstract unset_signal_catcher(catcher: SignalCatcher) → None

    Unset a catcher for a signal.

    Parameters:

      catcher (CaughtSignal) – The signal to unset.

  abstract peek_memory(address: int) → int

    Reads the memory at the specified address.

    Parameters:

      address (int) – The address to read.

    Returns:

      The read memory value.

    Return type:

      int

  abstract poke_memory(address: int, data: int) → None

    Writes the memory at the specified address.

    Parameters:

      - address (int) – The address to write.

      - data (int) – The value to write.

## libdebug.interfaces.interface_helper module

libdebug.interfaces.interface_helper.provide_debugging_interface(interface: AvailableInterfaces = AvailableInterfaces.PTRACE) → DebuggingInterface

  Returns an instance of the debugging interface to be used by the _InternalDebugger class.

## libdebug.interfaces.interfaces module

class libdebug.interfaces.interfaces.AvailableInterfaces(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

  Bases: `Enum`

  An enumeration of the available backend interfaces.

  PTRACE = 1

## Module contents