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_hook(hook: SyscallHook) → None

    Sets a syscall hook.

    Parameters:

      hook (SyscallHook) – The syscall hook to set.

  abstract unset_syscall_hook(hook: SyscallHook) → None

    Unsets a syscall hook.

    Parameters:

      hook (SyscallHook) – The syscall hook to unset.

  abstract set_signal_hook(hook: SignalHook) → None

    Sets a signal hook.

    Parameters:

      hook (SignalHook) – The signal hook to set.

  abstract unset_signal_hook(hook: SignalHook) → None

    Unsets a signal hook.

    Parameters:

      hook (SignalHook) – The signal hook 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)

  Bases: `Enum`

  An enumeration of the available backend interfaces.

  PTRACE = 1

## Module contents