angr.emulator

class angr.emulator.Emulator

Bases: object

Emulator is a utility that adapts an angr SuccessorsEngine to a more user-friendly interface for concrete execution. It only supports concrete execution.

Saftey: This class is not thread-safe. It should only be used in a single-threaded context. It can be safely shared between multiple threads, provided that only one thread is using it at a time.

__init__(engine, init_state)
Parameters:
  • engine (SuccessorsEngine) – The SuccessorsEngine to use for emulation.

  • init_state (SimState) – The initial state to use for emulation.

property state: SimState

The current state of the emulator.

property breakpoints: set[int]

The set of currently set breakpoints.

add_breakpoint(addr)

Add a breakpoint at the given address.

Parameters:

addr (int) – The address to set the breakpoint at.

Return type:

None

remove_breakpoint(addr)

Remove a breakpoint at the given address, if present.

Parameters:

addr (int) – The address to remove the breakpoint from.

Return type:

None

run(num_inst=None)

Execute the emulator.

Return type:

EmulatorStopReason

Parameters:

num_inst (int | None)

exception angr.emulator.EmulatorException

Bases: AngrError

Base class for exceptions raised by the Emulator.

class angr.emulator.EmulatorStopReason

Bases: Enum

Enum representing the reason for stopping the emulator.

INSTRUCTION_LIMIT = 'instruction_limit'
BREAKPOINT = 'breakpoint'
NO_SUCCESSORS = 'no_successors'
MEMORY_ERROR = 'memory_error'
FAILURE = 'failure'
EXIT = 'exit'
exception angr.emulator.EngineException

Bases: EmulatorException

Exception raised when the emulator encounters an unhandlable error in the engine.

exception angr.emulator.StateDivergedException

Bases: EmulatorException

Exception raised when an engine returns multiple successors.