avrora.stack
Interface AnalyzerPolicy

All Known Implementing Classes:
Analyzer.ContextSensitivePolicy

public interface AnalyzerPolicy

The Policy interface allows for more modular, composable analysis. An instance of this class is passed to the AbstractInterpreter and that instance determines how to handle calls, returns, indirect jumps, and stack operations in the abstract interpretation. Thus, multiple anlayses can share the same core abstract interpreter in a clean way.

See Also:
AbstractInterpreter

Method Summary
 MutableState call(MutableState s, int target_address)
          The call() method is called by the abstract interpreter when it encounters a call instruction within the program.
 MutableState indirectCall(MutableState s, char addr_low, char addr_hi)
          The indirectCall() method is called by the abstract interpreter when it encounters an indirect call within the program.
 MutableState indirectCall(MutableState s, char addr_low, char addr_hi, char ext)
          The indirectCall() method is called by the abstract interpreter when it encounters an indirect call within the program.
 MutableState indirectJump(MutableState s, char addr_low, char addr_hi)
          The indirectJump() method is called by the abstract interpreter when it encounters an indirect jump within the program.
 MutableState indirectJump(MutableState s, char addr_low, char addr_hi, char ext)
          The indirectJump() method is called by the abstract interpreter when it encounters an indirect jump within the program.
 MutableState interrupt(MutableState s, int num)
          The interrupt() is called by the abstract interrupt when it encounters a place in the program when an interrupt might occur.
 char pop(MutableState s)
          The pop() method is called by the abstract interpreter when a pop from the stack is ecountered in the program.
 void push(MutableState s, char val)
          The push() method is called by the abstract interpreter when a push to the stack is encountered in the program.
 void pushState(MutableState newState)
          The pushState method is called by the abstract interpreter when a state is forked by the abstract interpreter (for example when a branch condition is not known and both branches must be taken.
 MutableState ret(MutableState s)
          The ret() method is called by the abstract interpreter when it encounters a return within the program.
 MutableState reti(MutableState s)
          The reti() method is called by the abstract interpreter when it encounters a return from an interrupt within the program.
 

Method Detail

call

public MutableState call(MutableState s,
                         int target_address)
The call() method is called by the abstract interpreter when it encounters a call instruction within the program. Different policies may handle calls differently. For example, a context-sensitive analysis might fork and start analysis the called method in this context, which a context insensitive analsysis may just merge the current state into the entrance state for that address and then reanalyze that code.

Parameters:
s - the current calling abstract state
target_address - the concrete target address of the call
Returns:
the state of the program after the call, null if there is no next state

interrupt

public MutableState interrupt(MutableState s,
                              int num)
The interrupt() is called by the abstract interrupt when it encounters a place in the program when an interrupt might occur.

Parameters:
s - the abstract state just before interrupt
num - the interrupt number that might occur
Returns:
the state of the program after the interrupt, null if there is no next state

ret

public MutableState ret(MutableState s)
The ret() method is called by the abstract interpreter when it encounters a return within the program.

Parameters:
s - the current abstract state
Returns:
the state of the program after the call, null if there is no next state

reti

public MutableState reti(MutableState s)
The reti() method is called by the abstract interpreter when it encounters a return from an interrupt within the program.

Parameters:
s - the current abstract state
Returns:
the state of the program after the call, null if there is no next state

indirectCall

public MutableState indirectCall(MutableState s,
                                 char addr_low,
                                 char addr_hi)
The indirectCall() method is called by the abstract interpreter when it encounters an indirect call within the program. The abstract values of the address are given as parameters, so that a policy can choose to compute possible targets or be conservative or whatever it so chooses.

Parameters:
s - the current abstract state
addr_low - the (abstract) low byte of the address
addr_hi - the (abstract) high byte of the address
Returns:
the state of the program after the call, null if there is no next state

indirectJump

public MutableState indirectJump(MutableState s,
                                 char addr_low,
                                 char addr_hi)
The indirectJump() method is called by the abstract interpreter when it encounters an indirect jump within the program. The abstract values of the address are given as parameters, so that a policy can choose to compute possible targets or be conservative or whatever it so chooses.

Parameters:
s - the current abstract state
addr_low - the (abstract) low byte of the address
addr_hi - the (abstract) high byte of the address
Returns:
the state of the program after the call, null if there is no next state

indirectCall

public MutableState indirectCall(MutableState s,
                                 char addr_low,
                                 char addr_hi,
                                 char ext)
The indirectCall() method is called by the abstract interpreter when it encounters an indirect call within the program. The abstract values of the address are given as parameters, so that a policy can choose to compute possible targets or be conservative or whatever it so chooses.

Parameters:
s - the current abstract state
addr_low - the (abstract) low byte of the address
addr_hi - the (abstract) high byte of the address
ext - the (abstract) extended part of the address
Returns:
the state of the program after the call, null if there is no next state

indirectJump

public MutableState indirectJump(MutableState s,
                                 char addr_low,
                                 char addr_hi,
                                 char ext)
The indirectJump() method is called by the abstract interpreter when it encounters an indirect jump within the program. The abstract values of the address are given as parameters, so that a policy can choose to compute possible targets or be conservative or whatever it so chooses.

Parameters:
s - the current abstract state
addr_low - the (abstract) low byte of the address
addr_hi - the (abstract) high byte of the address
ext - the (abstract) extended part of the address
Returns:
the state of the program after the call, null if there is no next state

push

public void push(MutableState s,
                 char val)
The push() method is called by the abstract interpreter when a push to the stack is encountered in the program. The policy can then choose what outgoing and/or modelling of the stack needs to be done.

Parameters:
s - the current abstract state
val - the abstract value to push onto the stack

pop

public char pop(MutableState s)
The pop() method is called by the abstract interpreter when a pop from the stack is ecountered in the program. The policy can then choose to either return whatever information it has about the stack contents, or return an UNKNOWN value.

Parameters:
s - the current abstract state
Returns:
the abstract value popped from the stack

pushState

public void pushState(MutableState newState)
The pushState method is called by the abstract interpreter when a state is forked by the abstract interpreter (for example when a branch condition is not known and both branches must be taken.

Parameters:
newState - the new state created