Skip to main content
`Ctrl`+`K`

# libdebug.state package

## Submodules

## libdebug.state.resume_context module

class libdebug.state.resume_context.ResumeContext

  Bases: `object`

  A class representing the context of the resume decision.

  clear() → None

    Clears the context.

## libdebug.state.thread_context module

class libdebug.state.thread_context.ThreadContext(thread_id: int, registers: RegisterHolder)

  Bases: `object`

  This object represents a thread in the context of the target process. It holds information about the thread’s state, registers and stack.

  instruction_pointer: int

    The thread’s instruction pointer.

  syscall_arg0: int

    The thread’s syscall argument 0.

  syscall_arg1: int

    The thread’s syscall argument 1.

  syscall_arg2: int

    The thread’s syscall argument 2.

  syscall_arg3: int

    The thread’s syscall argument 3.

  syscall_arg4: int

    The thread’s syscall argument 4.

  syscall_arg5: int

    The thread’s syscall argument 5.

  syscall_number: int

    The thread’s syscall number.

  syscall_return: int

    The thread’s syscall return value.

  regs: Registers

    The thread’s registers.

  set_as_dead() → None

    Set the thread as dead.

  property dead: bool

    Whether the thread is dead.

  property memory: MemoryView

    The memory view of the debugged process.

  property process_id: int

    The process ID of the thread.

  property pid: int

    The process ID of the thread.

  property thread_id: int

    The thread ID.

  property tid: int

    The thread ID.

  property running: bool

    Whether the process is running.

  property exit_code: int | None

    The thread’s exit code.

  property exit_signal: str | None

    The thread’s exit signal.

  property signal: str | None

    The signal will be forwarded to the thread.

  backtrace() → list

    Returns the current backtrace of the thread.

  current_return_address() → int

    Returns the return address of the current function.

  step() → None

    Executes a single instruction of the process.

  step_until(position: int | str, max_steps: int = -1, file: str = 'default') → None

    Executes instructions of the process until the specified location is reached.

    Parameters:

      - position (int | bytes) – The location to reach.

      - max_steps (int, optional) – The maximum number of steps to execute. Defaults to -1.

      - file (str, optional) – The user-defined backing file to resolve the address in. Defaults to “default”

      - address ((libdebug will first try to solve the address as an absolute)

      - w.r.t. (then as a relative address)

      - file). (the "binary" map)

  finish(heuristic: str = 'backtrace') → 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:

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

  si() → None

    Alias for the step method.

    Executes a single instruction of the process.

  su(position: int | str, max_steps: int = -1) → None

    Alias for the step_until method.

    Executes instructions of the process until the specified location is reached.

    Parameters:

      - position (int | bytes) – The location to reach.

      - max_steps (int, optional) – The maximum number of steps to execute. Defaults to -1.

  fin(heuristic: str = 'backtrace') → None

    Alias for the finish method. 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:

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

## Module contents