Skip to content

Commit

Permalink
fixed support for callbacks in static methods and added more method s…
Browse files Browse the repository at this point in the history
…ignatures
  • Loading branch information
StevenArzt committed Sep 24, 2024
1 parent 676c62c commit ddb3478
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/soot/jimple/spark/pag/PAG.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import soot.jimple.InvokeExpr;
import soot.jimple.NewExpr;
import soot.jimple.NullConstant;
import soot.jimple.StaticInvokeExpr;
import soot.jimple.Stmt;
import soot.jimple.VirtualInvokeExpr;
import soot.jimple.spark.builder.GlobalNodeFactory;
Expand All @@ -84,6 +85,7 @@
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.DeferredVirtualEdgeTarget;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.InstanceinvokeSource;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.InvocationVirtualEdgeTarget;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.StaticinvokeSource;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.VirtualEdge;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.VirtualEdgeSource;
import soot.jimple.toolkits.callgraph.VirtualEdgesSummaries.VirtualEdgeTarget;
Expand Down Expand Up @@ -1086,15 +1088,20 @@ public void addCallTarget(Edge e) {
}
VirtualEdgesSummaries summaries = getOnFlyCallGraph().ofcgb().getVirtualEdgeSummaries();
InvokeExpr ie = e.srcStmt().getInvokeExpr();
VirtualEdge ve = summaries.getVirtualEdgesMatchingSubSig(new MethodSubSignature(ie.getMethodRef().getSubSignature()));
VirtualEdge ve = null;
if (ie instanceof InstanceInvokeExpr) {
ve = summaries.getVirtualEdgesMatchingSubSig(new MethodSubSignature(ie.getMethodRef().getSubSignature()));
} else if (ie instanceof StaticInvokeExpr) {
ve = summaries.getVirtualEdgesMatchingFunction(ie.getMethodRef().getSignature());
}
// if there is no virtual edge there is no point in continuing
if (ve == null) {
return;
}
// The source is equal for direct and indirect targets
VirtualEdgeSource edgeSrc = ve.getSource();

if (edgeSrc instanceof InstanceinvokeSource) {
if (edgeSrc instanceof InstanceinvokeSource || edgeSrc instanceof StaticinvokeSource) {
for (VirtualEdgeTarget edgeTgt : ve.getTargets()) {
if (edgeTgt instanceof InvocationVirtualEdgeTarget) {
InvocationVirtualEdgeTarget ieEdgeTgt = (InvocationVirtualEdgeTarget) edgeTgt;
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/virtualedges.xml
Original file line number Diff line number Diff line change
Expand Up @@ -846,4 +846,31 @@
target-position="argument" index="0" />
</targets>
</edge>
<edge>
<source invoketype="instance"
subsignature="void forEachOrdered(java.util.function.Consumer)" />
<targets>
<direct
subsignature="void accept(java.lang.Object)"
target-position="argument" index="0" />
</targets>
</edge>
<edge>
<source invoketype="instance"
subsignature="java.util.stream.Stream generate(java.util.function.Supplier)" />
<targets>
<direct
subsignature="java.lang.Object get()"
target-position="argument" index="0" />
</targets>
</edge>
<edge>
<source invoketype="static"
signature="&lt;java.util.stream.Stream: java.util.stream.Stream iterate(java.lang.Object,java.util.function.UnaryOperator)&gt;" />
<targets>
<direct
subsignature="java.lang.Object apply(java.lang.Object)"
target-position="argument" index="1" />
</targets>
</edge>
</virtualedges>

0 comments on commit ddb3478

Please sign in to comment.