soot-oss / SootUp

A new version of Soot with a completely overhauled architecture
https://soot-oss.github.io/SootUp/
GNU Lesser General Public License v2.1
575 stars 76 forks source link

[Feature]: Method calls sorted by sequence #1086

Open chanmaoganda opened 2 weeks ago

chanmaoganda commented 2 weeks ago

Missing Feature

callFrom(methodSignature) returns a no-sorted set, consider making a sorted list by the call sequence?

I'm currently doing a research of type-bug

Suppose i have a program below

public class A {
    private int m() { System.out.println("A.m"); return 0; }
    public static void main(String... args) { type_bug.refined.B b = new type_bug.refined.C(); b.m(); }
}

abstract class B extends A implements I {
}

class C extends B {
    public void m() { System.out.println("C.m"); }
}

interface I {
    public void m();
}

i use the following code to get the Methods called in A.main()

final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view);
CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(view);
// Create CG by initializing CHA with entry method(s)CallGraph cg = cha.initialize(Collections.singletonList(methodSignature));
cg.callsFrom(methodSignature).forEach(System.out::println);

i got the following output: <type_bug.refined.C: void m()> <type_bug.refined.C: void ()> <type_bug.refined.I: void m()>

while the correct sequence should be like: <type_bug.refined.C: void ()> <type_bug.refined.C: void m()> <type_bug.refined.I: void m()>

i wonder if there is a way to sort the method call correctly😊

JonasKlauke commented 2 weeks ago

The new Version will save Statemens for each call. You could sort the the calls by this statements with the statementlist of the method body. I get your usecase. This is a good API extension. Similar to a method that gives you targets of a specific statement in a method