Package winappdbg :: Module breakpoint :: Class Breakpoint
[hide private]
[frames] | no frames]

Class Breakpoint

source code


Base class for breakpoints. Here's the breakpoints state machine.


See Also: CodeBreakpoint, PageBreakpoint, HardwareBreakpoint

Instance Methods [hide private]
 
__init__(self, address, size=1, condition=True, action=None)
Breakpoint object.
source code
 
__repr__(self)
repr(x)
source code
 
__bad_transition(self, state)
Raises an AssertionError exception for an invalid state transition.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

    State machine
bool
is_disabled(self)
Returns: True if the breakpoint is in DISABLED state.
source code
bool
is_enabled(self)
Returns: True if the breakpoint is in ENABLED state.
source code
bool
is_one_shot(self)
Returns: True if the breakpoint is in ONESHOT state.
source code
bool
is_running(self)
Returns: True if the breakpoint is in RUNNING state.
source code
int
get_state(self)
Returns: The current state of the breakpoint (DISABLED, ENABLED, ONESHOT, RUNNING).
source code
str
get_state_name(self)
Returns: The name of the current state of the breakpoint.
source code
 
disable(self, aProcess, aThread)
Transition to DISABLED state.
source code
 
enable(self, aProcess, aThread)
Transition to ENABLED state.
source code
 
one_shot(self, aProcess, aThread)
Transition to ONESHOT state.
source code
 
running(self, aProcess, aThread)
Transition to RUNNING state.
source code
 
hit(self, event)
Notify a breakpoint that it's been hit.
source code
    Information
bool
is_here(self, address)
Returns: True if the address is within the range of the breakpoint.
source code
int
get_address(self)
Returns: The target memory address for the breakpoint.
source code
int
get_size(self)
Returns: The size in bytes of the breakpoint.
source code
tuple( int, int )
get_span(self)
Returns: Starting and ending address of the memory range covered by the breakpoint.
source code
    Conditional breakpoints
bool
is_conditional(self)
Returns: True if the breakpoint has a condition callback defined.
source code
bool
is_unconditional(self)
Returns: True if the breakpoint doesn't have a condition callback defined.
source code
bool, function
get_condition(self)
Returns: Returns the condition callback for conditional breakpoints.
source code
 
set_condition(self, condition=True)
Sets a new condition callback for the breakpoint.
source code
bool
eval_condition(self, event)
Evaluates the breakpoint condition, if any was set.
source code
    Automatic breakpoints
bool
is_automatic(self)
Returns: True if the breakpoint has an action callback defined.
source code
bool
is_interactive(self)
Returns: True if the breakpoint doesn't have an action callback defined.
source code
bool, function
get_action(self)
Returns: Returns the action callback for automatic breakpoints.
source code
 
set_action(self, action=None)
Sets a new action callback for the breakpoint.
source code
 
run_action(self, event)
Executes the breakpoint action callback, if any was set.
source code
Class Variables [hide private]
str typeName = 'breakpoint'
User friendly breakpoint type string.
dict { int → str } stateNames = {0: 'disabled', 1: 'enabled', 2: 'one shot', 3: '...
User-friendly names for each breakpoint state.
    Breakpoint states
int DISABLED = 0
Disabled → Enabled, OneShot
int ENABLED = 1
EnabledRunning, Disabled
int ONESHOT = 2
OneShotDisabled
int RUNNING = 3
RunningEnabled, Disabled
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, address, size=1, condition=True, action=None)
(Constructor)

source code 

Breakpoint object.

Parameters:
  • address (int) - Memory address for breakpoint.
  • size (int) - Size of breakpoint in bytes (defaults to 1).
  • condition (function) - (Optional) Condition callback function.

    The callback signature is:

       def condition_callback(event):
           return True     # returns True or False
    

    Where event is an Event object, and the return value is a boolean (True to dispatch the event, False otherwise).

  • action (function) - (Optional) Action callback function. If specified, the event is handled by this callback instead of being dispatched normally.

    The callback signature is:

       def action_callback(event):
           pass        # no return value
    

    Where event is an Event object.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

is_disabled(self)

source code 
Returns: bool
True if the breakpoint is in DISABLED state.

is_enabled(self)

source code 
Returns: bool
True if the breakpoint is in ENABLED state.

is_one_shot(self)

source code 
Returns: bool
True if the breakpoint is in ONESHOT state.

is_running(self)

source code 
Returns: bool
True if the breakpoint is in RUNNING state.

is_here(self, address)

source code 
Returns: bool
True if the address is within the range of the breakpoint.

get_address(self)

source code 
Returns: int
The target memory address for the breakpoint.

get_size(self)

source code 
Returns: int
The size in bytes of the breakpoint.

get_span(self)

source code 
Returns: tuple( int, int )
Starting and ending address of the memory range covered by the breakpoint.

get_state(self)

source code 
Returns: int
The current state of the breakpoint (DISABLED, ENABLED, ONESHOT, RUNNING).

get_state_name(self)

source code 
Returns: str
The name of the current state of the breakpoint.

is_conditional(self)

source code 
Returns: bool
True if the breakpoint has a condition callback defined.

See Also: __init__

is_unconditional(self)

source code 
Returns: bool
True if the breakpoint doesn't have a condition callback defined.

get_condition(self)

source code 
Returns: bool, function
Returns the condition callback for conditional breakpoints. Returns True for unconditional breakpoints.

set_condition(self, condition=True)

source code 

Sets a new condition callback for the breakpoint.

Parameters:
  • condition (function) - (Optional) Condition callback function.

See Also: __init__

eval_condition(self, event)

source code 

Evaluates the breakpoint condition, if any was set.

Parameters:
  • event (Event) - Debug event triggered by the breakpoint.
Returns: bool
True to dispatch the event, False otherwise.

is_automatic(self)

source code 
Returns: bool
True if the breakpoint has an action callback defined.

is_interactive(self)

source code 
Returns: bool
True if the breakpoint doesn't have an action callback defined.

get_action(self)

source code 
Returns: bool, function
Returns the action callback for automatic breakpoints. Returns None for interactive breakpoints.

set_action(self, action=None)

source code 

Sets a new action callback for the breakpoint.

Parameters:
  • action (function) - (Optional) Action callback function.

run_action(self, event)

source code 

Executes the breakpoint action callback, if any was set.

Parameters:
  • event (Event) - Debug event triggered by the breakpoint.

__bad_transition(self, state)

source code 

Raises an AssertionError exception for an invalid state transition.

Parameters:
  • state (int) - Intended breakpoint state.
Raises:
  • Exception - Always.

See Also: stateNames

disable(self, aProcess, aThread)

source code 

Transition to DISABLED state.

  • When hit: OneShot → Disabled
  • Forced by user: Enabled, OneShot, Running → Disabled
  • Transition from running state may require special handling by the breakpoint implementation class.
Parameters:
  • aProcess (Process) - Process object.
  • aThread (Thread) - Thread object.

enable(self, aProcess, aThread)

source code 

Transition to ENABLED state.

  • When hit: Running → Enabled
  • Forced by user: Disabled, Running → Enabled
  • Transition from running state may require special handling by the breakpoint implementation class.
Parameters:
  • aProcess (Process) - Process object.
  • aThread (Thread) - Thread object.

one_shot(self, aProcess, aThread)

source code 

Transition to ONESHOT state.

  • Forced by user: Disabled → OneShot
Parameters:
  • aProcess (Process) - Process object.
  • aThread (Thread) - Thread object.

running(self, aProcess, aThread)

source code 

Transition to RUNNING state.

  • When hit: Enabled → Running
Parameters:
  • aProcess (Process) - Process object.
  • aThread (Thread) - Thread object.

hit(self, event)

source code 

Notify a breakpoint that it's been hit.

This triggers the corresponding state transition and sets the breakpoint property of the given Event object.

Parameters:
  • event (Event) - Debug event to handle (depends on the breakpoint type).
Raises:
  • AssertionError - Disabled breakpoints can't be hit.

Class Variable Details [hide private]

stateNames

User-friendly names for each breakpoint state.
Type:
dict { int → str }
Value:
{0: 'disabled', 1: 'enabled', 2: 'one shot', 3: 'running'}