Package com.tonic.analysis.pdg.sdg.slice
Class SDGSlicer
- java.lang.Object
-
- com.tonic.analysis.pdg.sdg.slice.SDGSlicer
-
public class SDGSlicer extends Object
Interprocedural slicer over a system dependence graph, using the two-phase ascend/descend walk so slices stay context sensitive across call sites.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<List<SDGCallNode>>findCallingContexts(PDGNode node, int maxDepth)Enumerates the call-site chains through which a node can be reached, walking call edges up to a bounded depth.SDGgetSdg()SliceResultinterproceduralBackwardSlice(PDGNode criterion)Collects everything the criterion may depend on, across procedures.SliceResultinterproceduralForwardSlice(PDGNode criterion)Collects everything that may depend on the criterion, across procedures.booleanisContextSensitive()booleanisUseSummaryEdges()SliceResultsliceWithCallingContext(PDGNode criterion, List<SDGCallNode> callingContext)Slices backward from a criterion reached through a known chain of call sites, so only parameter flows matching that chain are followed.SDGSlicerwithContextSensitivity(boolean contextSensitive)Toggles matching calls to returns instead of walking all interprocedural edges.SDGSlicerwithSummaryEdges(boolean use)Toggles following summary edges, which short-circuit a call's input-to-output flow.
-
-
-
Constructor Detail
-
SDGSlicer
public SDGSlicer(SDG sdg)
Creates a slicer over a graph, with summary edges and context sensitivity on.- Parameters:
sdg- the graph to slice
-
-
Method Detail
-
getSdg
public SDG getSdg()
- Returns:
- the sdg
-
isUseSummaryEdges
public boolean isUseSummaryEdges()
- Returns:
- whether use summary edges
-
isContextSensitive
public boolean isContextSensitive()
- Returns:
- whether context sensitive
-
withSummaryEdges
public SDGSlicer withSummaryEdges(boolean use)
Toggles following summary edges, which short-circuit a call's input-to-output flow.- Parameters:
use- true to follow summary edges- Returns:
- this slicer
-
withContextSensitivity
public SDGSlicer withContextSensitivity(boolean contextSensitive)
Toggles matching calls to returns instead of walking all interprocedural edges.- Parameters:
contextSensitive- true for the context sensitive walk- Returns:
- this slicer
-
interproceduralBackwardSlice
public SliceResult interproceduralBackwardSlice(PDGNode criterion)
Collects everything the criterion may depend on, across procedures.- Parameters:
criterion- the node to slice back from- Returns:
- the backward slice
-
interproceduralForwardSlice
public SliceResult interproceduralForwardSlice(PDGNode criterion)
Collects everything that may depend on the criterion, across procedures.- Parameters:
criterion- the node to slice forward from- Returns:
- the forward slice
-
sliceWithCallingContext
public SliceResult sliceWithCallingContext(PDGNode criterion, List<SDGCallNode> callingContext)
Slices backward from a criterion reached through a known chain of call sites, so only parameter flows matching that chain are followed.- Parameters:
criterion- the node to slice back fromcallingContext- the call sites leading to the criterion, outermost first- Returns:
- the backward slice restricted to that context
-
findCallingContexts
public List<List<SDGCallNode>> findCallingContexts(PDGNode node, int maxDepth)
Enumerates the call-site chains through which a node can be reached, walking call edges up to a bounded depth.- Parameters:
node- the node to find contexts formaxDepth- how many call levels to ascend- Returns:
- one list of call sites per context, outermost call first
-
-