A little question about the args to construct call graph
Closed this issue · 1 comments
cshezhang commented
Description
I want to use CHA to construct the call graph, but the following args throw an exception.
Main.main(
"-pp",
"-cp", "target/test-classes/",
"--input-classes", main,
"-a", ThrowAnalysis.ID + "=exception:explicit",
"-a", CFGBuilder.ID + "=exception:explicit;dump:true",
"-a", "cg=algorithm:cha"
);
However, if cg=algorithm:cha
is replaced with cg
, Taie can work properly.
The main exception trace:
cfg finishes, elapsed time: 0.01s
cg starts ...
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.ArrayDeque.addLast(ArrayDeque.java:303)
at java.base/java.util.ArrayDeque.add(ArrayDeque.java:494)
at pascal.taie.analysis.graph.callgraph.CHABuilder.buildCallGraph(CHABuilder.java:70)
at pascal.taie.analysis.graph.callgraph.CHABuilder.build(CHABuilder.java:61)
at pascal.taie.analysis.graph.callgraph.CallGraphBuilder.analyze(CallGraphBuilder.java:64)
at pascal.taie.analysis.graph.callgraph.CallGraphBuilder.analyze(CallGraphBuilder.java:37)
at pascal.taie.analysis.AnalysisManager.runProgramAnalysis(AnalysisManager.java:148)
at pascal.taie.analysis.AnalysisManager.runAnalysis(AnalysisManager.java:135)
at pascal.taie.analysis.AnalysisManager.lambda$execute$0(AnalysisManager.java:104)
at pascal.taie.util.Timer.runAndCount(Timer.java:93)
at pascal.taie.analysis.AnalysisManager.lambda$execute$1(AnalysisManager.java:103)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at pascal.taie.analysis.AnalysisManager.execute(AnalysisManager.java:102)
at pascal.taie.Main.executePlan(Main.java:152)
at pascal.taie.Main.lambda$main$0(Main.java:60)
at pascal.taie.util.Timer.lambda$runAndCount$0(Timer.java:112)
at pascal.taie.util.Timer.runAndCount(Timer.java:93)
at pascal.taie.util.Timer.runAndCount(Timer.java:111)
at pascal.taie.util.Timer.runAndCount(Timer.java:107)
at pascal.taie.Main.main(Main.java:51)
Could you please kindly spot the potential usage issue? Thank you!
silverbullettt commented
The problem is that you did not specify a main method.
When CHA builds a call graph, it needs to start with a main method (a.k.a. entry method), which can be specified by option -m
. You can change --input-classes main
to -m main
(--input-classes
only tells Tai-e the classes needed to loaded into the world, but not the main method).