Class SDG


  • public class SDG
    extends Object
    System dependence graph - the per-method PDGs joined by parameter and summary edges at resolved call sites.
    • Constructor Detail

      • SDG

        public SDG​(CallGraph callGraph)
        Creates an empty graph over a call graph; PDGs and entries are added afterwards.
        Parameters:
        callGraph - the call graph the procedures come from
    • Method Detail

      • getCallGraph

        public CallGraph getCallGraph()
        Returns:
        the call graph
      • getParameterEdges

        public List<PDGEdge> getParameterEdges()
        Returns:
        the parameter edges
      • getSummaryEdges

        public List<PDGEdge> getSummaryEdges()
        Returns:
        the summary edges
      • getNextNodeId

        public int getNextNodeId()
        Returns:
        the next node id
      • allocateNodeId

        public int allocateNodeId()
        Hands out the next unused node id.
        Returns:
        the allocated id
      • addMethodPDG

        public void addMethodPDG​(MethodReference methodRef,
                                 PDG pdg)
        Registers a method's PDG and folds its nodes and edges into the graph-wide sets, skipping ones already present.
        Parameters:
        methodRef - the method
        pdg - its dependence graph
      • addMethodEntry

        public void addMethodEntry​(MethodReference methodRef,
                                   SDGEntryNode entry)
        Registers a procedure entry node and adds it to the node set.
        Parameters:
        methodRef - the method
        entry - its entry node
      • addNode

        public void addNode​(PDGNode node)
        Adds a node if it is not already present.
        Parameters:
        node - the node to add
      • addEdge

        public void addEdge​(PDGEdge edge)
        Adds an edge if it is not already present, links it to its endpoints and files interprocedural edges under the summary or parameter list.
        Parameters:
        edge - the edge to add
      • registerCallTarget

        public void registerCallTarget​(SDGCallNode callNode,
                                       SDGEntryNode targetEntry)
        Records a resolved callee for a call site and points the call node at it.
        Parameters:
        callNode - the call site
        targetEntry - the callee entry node
      • getPDG

        public PDG getPDG​(MethodReference method)
        Parameters:
        method - the method to look up
        Returns:
        its PDG, or null if none is registered
      • getEntry

        public SDGEntryNode getEntry​(MethodReference method)
        Parameters:
        method - the method to look up
        Returns:
        its entry node, or null if none is registered
      • getCallTargets

        public Set<SDGEntryNode> getCallTargets​(SDGCallNode callNode)
        Parameters:
        callNode - the call site
        Returns:
        the entry nodes registered as targets, empty if none
      • getCallSitesIn

        public Set<SDGCallNode> getCallSitesIn​(MethodReference method)
        Finds the call sites appearing in a method's PDG.
        Parameters:
        method - the caller
        Returns:
        the call sites, empty if the method has no registered PDG
      • getCallSitesTo

        public Set<SDGCallNode> getCallSitesTo​(MethodReference method)
        Finds the call sites resolved to a method.
        Parameters:
        method - the callee
        Returns:
        the call sites targeting it, empty if the method has no entry node
      • getInterproceduralEdges

        public List<PDGEdge> getInterproceduralEdges()
        Returns:
        a fresh list of the parameter edges followed by the summary edges
      • getSummaryEdges

        public List<PDGEdge> getSummaryEdges​(SDGCallNode callNode)
        Selects the summary edges whose source is an actual-in of a call site.
        Parameters:
        callNode - the call site
        Returns:
        the matching summary edges
      • getMethods

        public Set<MethodReference> getMethods()
        Returns:
        an unmodifiable view of the methods with a registered PDG
      • getMethodCount

        public int getMethodCount()
        Returns:
        the number of methods with a registered PDG
      • getTotalNodeCount

        public int getTotalNodeCount()
        Returns:
        the number of nodes
      • getTotalEdgeCount

        public int getTotalEdgeCount()
        Returns:
        the number of edges
      • getInterproceduralEdgeCount

        public int getInterproceduralEdgeCount()
        Returns:
        the number of parameter and summary edges combined
      • getSummaryEdgeCount

        public int getSummaryEdgeCount()
        Returns:
        the number of summary edges
      • getAllNodes

        public List<PDGNode> getAllNodes()
        Returns:
        an unmodifiable view of every node
      • getAllEdges

        public List<PDGEdge> getAllEdges()
        Returns:
        an unmodifiable view of every edge
      • getEntryNodes

        public Collection<SDGEntryNode> getEntryNodes()
        Returns:
        an unmodifiable view of every procedure entry node
      • getFormalIns

        public List<SDGFormalInNode> getFormalIns​(SDGEntryNode entry)
        Parameters:
        entry - the procedure entry node
        Returns:
        the formal-in nodes of the procedure
      • getFormalOuts

        public List<SDGFormalOutNode> getFormalOuts​(SDGEntryNode entry)
        Collects the formal-out node of a procedure, if it has one.
        Parameters:
        entry - the procedure entry node
        Returns:
        a list holding the formal-out node, or empty
      • getCallNodes

        public List<SDGCallNode> getCallNodes​(SDGEntryNode entry)
        Collects the call sites of a procedure from its PDG, plus any registered call node not already in that PDG.
        Parameters:
        entry - the procedure entry node
        Returns:
        the call sites
      • getActualIns

        public List<SDGActualInNode> getActualIns​(SDGCallNode callNode)
        Parameters:
        callNode - the call site
        Returns:
        the actual-in nodes of the call site
      • getActualOuts

        public List<SDGActualOutNode> getActualOuts​(SDGCallNode callNode)
        Collects the actual-out node of a call site, if it has one.
        Parameters:
        callNode - the call site
        Returns:
        a list holding the actual-out node, or empty
      • getCallNodesCount

        public int getCallNodesCount()
        Counts the call nodes across every registered node.
        Returns:
        the number of call nodes