Class BaseCallGraph

  • All Implemented Interfaces:
    Graph<CallGraph,​CallGraphNode,​CallGraphEdge>

    public abstract class BaseCallGraph
    extends CallGraph
    An instance of CallGraph that provides the basic mechanism to resolve UnresolvedCalls.

    The graph underlying this call graph is built lazily through each call to resolve: querying for information about the graph before the completion of the analysis might lead to wrong results.
    • Constructor Detail

      • BaseCallGraph

        public BaseCallGraph()
    • Method Detail

      • init

        public void init​(Application app)
                  throws CallGraphConstructionException
        Description copied from class: CallGraph
        Initializes the call graph of the given program. A call to this method should effectively re-initialize the call graph as if it is yet to be used. This is useful when the same instance is used in multiple analyses.
        Overrides:
        init in class CallGraph
        Parameters:
        app - the application to analyze
        Throws:
        CallGraphConstructionException - if an exception happens while building the call graph
      • resolveNonInstance

        public void resolveNonInstance​(UnresolvedCall call,
                                       java.util.Set<Type>[] types,
                                       java.util.Collection<CFG> targets,
                                       java.util.Collection<NativeCFG> natives,
                                       SymbolAliasing aliasing)
                                throws CallResolutionException
        Resolves the given call as regular (non-instance) call.
        Parameters:
        call - the call to resolve
        types - the runtime types of the parameters of the call
        targets - the list of targets that, after the execution of this method, will contain the CFGs targeted by the call
        natives - the list of targets that, after the execution of this method, will contain the NativeCFGs targeted by the call
        aliasing - the symbol aliasing information
        Throws:
        CallResolutionException - if something goes wrong while resolving the call
      • resolveInstance

        public void resolveInstance​(UnresolvedCall call,
                                    java.util.Set<Type>[] types,
                                    java.util.Collection<CFG> targets,
                                    java.util.Collection<NativeCFG> natives,
                                    SymbolAliasing aliasing)
                             throws CallResolutionException
        Resolves the given call as an instance call.
        Parameters:
        call - the call to resolve
        types - the runtime types of the parameters of the call
        targets - the list of targets that, after the execution of this method, will contain the CFGs targeted by the call
        natives - the list of targets that, after the execution of this method, will contain the NativeCFGs targeted by the call
        aliasing - the symbol aliasing information
        Throws:
        CallResolutionException - if something goes wrong while resolving the call
      • checkMember

        public void checkMember​(UnresolvedCall call,
                                java.util.Set<Type>[] types,
                                java.util.Collection<CFG> targets,
                                java.util.Collection<NativeCFG> natives,
                                SymbolAliasing aliasing,
                                CodeMember cm,
                                boolean instance)
        Checks if the given code member cm is a candidate target for the given call, and proceeds to add it to the set of targets if it is. Aliasing information is used here to match code members that have been aliased and that can be targeted by calls that refer to other names. Note that AbstractCodeMembers are always discarded.
        Parameters:
        call - the call to match
        types - the runtime types of the parameters of the call
        targets - the list of targets that, after the execution of this method, will contain the CFGs targeted by the call
        natives - the list of targets that, after the execution of this method, will contain the NativeCFGs targeted by the call
        aliasing - the symbol aliasing information
        cm - the code member to match
        instance - whether or not the only instance or non-instance members should be matched
      • matchCodeMemberName

        public boolean matchCodeMemberName​(UnresolvedCall call,
                                           java.lang.String qualifier,
                                           java.lang.String name)
        Matches the name (qualifier + target name) of the given call against the given code member.
        Parameters:
        call - the call to match
        qualifier - the qualifier (name of the defining unit) of the code member
        name - the name of the code member
        Returns:
        true if the qualifier and name are compatible with the ones of the call's target
      • getPossibleTypesOfReceiver

        public abstract java.util.Collection<Type> getPossibleTypesOfReceiver​(Expression receiver,
                                                                              java.util.Set<Type> types)
                                                                       throws CallResolutionException
        Returns all the possible types of the given expression that should be considered as possible receivers of the call. How we choose this set varies from the call graph algorithm we decide to adopt (e.g., CHA, RTA, 0-CFA, ...)
        Parameters:
        receiver - an expression
        types - the runtime types of the receiver
        Returns:
        the possible types to use as receivers
        Throws:
        CallResolutionException - if the types cannot be computed
      • getCallSites

        public java.util.Collection<Call> getCallSites​(CodeMember cm)
        Description copied from class: CallGraph
        Yields all the Calls that target the given CodeMember. The returned collection might contain partial results if this call graph is not fully built.
        Specified by:
        getCallSites in class CallGraph
        Parameters:
        cm - the target code member
        Returns:
        the collection of calls that target the code member