Skip to content

Callgraph taking a while to build #558

@will-leeson

Description

@will-leeson

I am building a tool that will consume graph representations of programs to perform a task. SootUp has been a great tool for this project. I want to be able to build call graphs for arbitrary functions in a library. I created the following function to build Call Graphs for every method in a given project:

public void buildCallGraphs(){
    for(JavaSootClass aClass : this.localView.getClasses()){
        for(SootMethod aMethod : aClass.getMethods()){
            System.out.println(aMethod.toString());
            MethodSignature entryMethodSignature = aMethod.getSignature();
            CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(globalView, typeHierarchy);

            CallGraph cg = cha.initialize(Collections.singletonList(entryMethodSignature));

            System.out.println("CALLS");
            for(MethodSignature m:cg.callsFrom(entryMethodSignature)){
                System.out.println(m.getName());
            }
            System.out.println("CALLS END");
        }
    }
}

When I run this code, some iterations finish almost instantly, while others take over 10 minutes. I understand building the call graph can be expensive, but this seems high. Does this seem expected? For reference, I am testing it on the linear algebra for java library.

It seems the methods that take longer produce the warnings like the following:

[main] WARN sootup.callgraph.AbstractCallGraphAlgorithm - Could not find "java.lang.Object invokeBasic(java.lang.invoke.BoundMethodHandle)" in MethodHandle and in its superclasses

Is this a coincidence or a cause?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions