Skip to content

Latest commit

 

History

History
93 lines (69 loc) · 3.14 KB

File metadata and controls

93 lines (69 loc) · 3.14 KB

GreedySearch

classDiagram
    class GreedySearch{
        -Set~ExecutionState~ states
        +ExecutionState.weight
    }
    GreedySearch --|> BasePathSelector
Loading

Base methods such as offer or remove is implemented pretty simple and just a delegation to states.

In peekImpl we find the set of states with maximum weight and peek random among them, so to use this class in implementation of some pathSelector, you just need to override an ExecutionState.weight.

SubpathStatistics

classDiagram
    class SubpathStatistics{
        +int index
        -Map~Subpath, Int~ subpathCount
        subpathCount(ExecutionState)
    }
    class TraverseGraphStatistics{
        onVisit(ExecutionState)
    }
    
    SubpathStatistics --|> TraverseGraphStatistics
    TraverseGraphStatistics o-- InterProceduralUnitGraph
Loading

Subpath = List<Edge>

This class maintains frequency of each subpath with length 2^index, which is presented as List<Edge>, in a certain instance of InterproceduralUnitGraph

  • onVisit(state: ExecutionState) - we calculate subpath of this state and increment its frequency on 1
  • subpathCount(state: ExecutionState) - we calculate subpath of this state and return its frequency

SubpathGuidedSelector

classDiagram
    SubpathGuidedSelector o-- SubpathStatistics
    SubpathGuidedSelector --|> GreedySearch
Loading

Inspired by paper.

We override ExecutionState.weight as -StatementStatistics.subpathCount(this), so we pick the state, which subpath is less traveled.

StatementStatistics

classDiagram
    class StatementStatistics{
        -Map~Stmt, Int~ statementsCount
        -Map~SootMethod, Int~ statementsInMethodCount
        +statementCount(ExecutionState)
        +statementsInMethodCount(ExecutionState)
    }
    
    class TraverseGraphStatistics{
        onVisit(ExecutionState)
    }
    
    StatementStatistics --|> TraverseGraphStatistics
    TraverseGraphStatistics o-- InterProceduralUnitGraph
Loading

This class maintains frequency of each Stmt and number of Stmt, that was visited in some SootMethod, on a certain instance of InterproceduralUnitGraph.

  • onVisit(state: ExecutionState) - increment frequency of state's stmt on 1. If we visit this stmt for the first time, then increment number of Stmt, that we visit in the current state's method, on 1.
  • statementCount(state: ExecutionState) - get a frequency of state's stmt
  • statementsInMethodCount(state: ExecutionState) - get number of stmt, that was visited in the current state's method.

CPInstSelector

classDiagram
    CPInstSelector o-- StatementStatistics
    CPInstSelector --|> NonUniformRandomSearch
Loading

Override ExecutionState.cost as StatementStatistics.statementInMethodCount(this), so we are more likely to explore the least explored method.

ForkDepthSelector

classDiagram
    ForkDepthSelector --|> NonUniformRandomSearch
Loading

Override ExecutionState.cost as ExecutionState.depth, so we are more likely to explore the least deep state in terms of the number of forks on its path.