avrora.sim.util
Class SequenceProbe

java.lang.Object
  extended byavrora.sim.util.SequenceProbe
All Implemented Interfaces:
Simulator.Probe

public class SequenceProbe
extends java.lang.Object
implements Simulator.Probe

The SequenceProbe is a probe composer that allows a probe to be fired for every instruction executed between a specified entrypoint and a specified exit point. For example, if the entrypoint is a call instruction and the exit point is the instruction following the call instruction, then the probe will fire for every instruction executed between the call and return, including both the call and the instruction following the call.

This probe supports nested entries (e.g. recursive calls). It is best used on pieces of the program that are single-entry/single-exit such as calls, interrupts, basic blocks, and SSE regions of control flow graphs. It does not work well for loops because of the nesting behavior.


Nested Class Summary
 
Nested classes inherited from class avrora.sim.Simulator.Probe
Simulator.Probe.Empty
 
Field Summary
 int entry_addr
          The immutable entry_addr field stores the address that enables the per-instruction calling of the probe passed in the constructor.
 int exit_addr
          The immutable exit_addr field stores the address that disables the per-instruction calling of the probe passed when the nesting level reaches zero.
 int nesting
          The nesting field stores the current nesting level (i.e. the number of times entry_addr has been reached without exit_addr intervening).
 Simulator.Probe probe
          The immutable probe field stores a reference to the probe passed in the constructor.
 
Constructor Summary
SequenceProbe(Simulator.Probe p, int entry, int exit)
          The constructor for the SequenceProbe class simply stores its arguments into the corresponding public final fields in this object, leaving the probe in a state where it is ready to be inserted into a simulator.
 
Method Summary
 void fireAfter(State state, int pc)
          The fireBefore() method is called before the probed instruction executes.
 void fireBefore(State state, int pc)
          The fireBefore() method is called before the probed instruction executes.
 void reset()
          The reset() method simply resets the nesting level of the sequence probe, as if it had exited from all nested entries into the region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entry_addr

public final int entry_addr
The immutable entry_addr field stores the address that enables the per-instruction calling of the probe passed in the constructor.


exit_addr

public final int exit_addr
The immutable exit_addr field stores the address that disables the per-instruction calling of the probe passed when the nesting level reaches zero.


probe

public final Simulator.Probe probe
The immutable probe field stores a reference to the probe passed in the constructor.


nesting

public int nesting
The nesting field stores the current nesting level (i.e. the number of times entry_addr has been reached without exit_addr intervening).

Constructor Detail

SequenceProbe

public SequenceProbe(Simulator.Probe p,
                     int entry,
                     int exit)
The constructor for the SequenceProbe class simply stores its arguments into the corresponding public final fields in this object, leaving the probe in a state where it is ready to be inserted into a simulator.

Parameters:
p - the probe to fire for each instruction when the sequence is entered
entry - the byte address of the entrypoint to the sequence
exit - the byte address of the exitpoint of the sequence
Method Detail

fireBefore

public void fireBefore(State state,
                       int pc)
The fireBefore() method is called before the probed instruction executes. In the implementation of the sequence probe, if the address is the entrypoint address, then the nesting level is incremented. When the nesting level is greater than one, then the sequence probe will delegate the fireBefore() call to the user probe.

Specified by:
fireBefore in interface Simulator.Probe
Parameters:
state - the state of the simulation
pc - the address at which this instruction resides

fireAfter

public void fireAfter(State state,
                      int pc)
The fireBefore() method is called before the probed instruction executes. When the nesting level is greater than one, then the sequence probe will delegate the fireAfter() call to the user probe. If the address is the exit point, then the nesting level is decremented after the call to fireAfter() of the user probe.

Specified by:
fireAfter in interface Simulator.Probe
Parameters:
state - the state of the simulation
pc - the address at which this instruction resides

reset

public void reset()
The reset() method simply resets the nesting level of the sequence probe, as if it had exited from all nested entries into the region.