问题描述
我想直接从java源代码生成一个控制流图。我曾尝试使用 soot 生成控制流图,但 soot 会检查语法错误,如下所示。
D:\isoot>java -cp sootclasses-trunk-jar-with-dependencies.jar soot.tools.CFGViewer --soot-classpath .;"D:\isoot\Java\jre1.8.0_221\lib\rt.jar" --graph=BriefBlockGraph A -src-prec java
Soot started on Tue Apr 20 11:21:41 CST 2021
D:\isoot\A.java:6,22:
Semantic Error: no visible type named Cache2kBuilder
D:\isoot\A.java:6,46:
Semantic Error: no visible type named Cache2kConfiguration
D:\isoot\A.java:7,3:
Semantic Error: no visible type named Cache2kBuilder
D:\isoot\A.java:7:
Semantic Error: can not instantiate Unknown no matching constructor found in Unknown
D:\isoot\A.java:7,32:
Semantic Error: no visible type named Cache2kBuilder
soot.CompilationDeathException: there were errors during parsing and/or type checking (JastAdd frontend)
at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:63)
at soot.JavaClassSource.resolve(JavaClassSource.java:54)
at soot.SootResolver.bringToHierarchyUnchecked(SootResolver.java:235)
at soot.SootResolver.bringToHierarchy(SootResolver.java:208)
at soot.SootResolver.bringToSignatures(SootResolver.java:266)
at soot.SootResolver.processResolveWorklist(SootResolver.java:170)
at soot.SootResolver.resolveClass(SootResolver.java:133)
at soot.Scene.loadClass(Scene.java:853)
at soot.Scene.loadClassAndSupport(Scene.java:839)
at soot.Scene.loadNecessaryClass(Scene.java:1569)
at soot.Scene.loadNecessaryClasses(Scene.java:1582)
at soot.Main.run(Main.java:250)
at soot.Main.main(Main.java:147)
at soot.tools.CFGViewer.main(CFGViewer.java:101)
Ouuups... something went wrong! Sorry about that.
Follow these steps to fix the problem:
1.) Are you sure you used the right command line?
Click here to double-check:
https://soot-build.cs.uni-paderborn.de/doc/sootoptions/
2.) Not sure whether it's a bug? Feel free to discuss
the issue on the Soot mailing list:
https://github.com/Sable/soot/wiki/Getting-help
3.) Sure it's a bug? Click this link to report it.
https://github.com/Sable/soot/issues/new?title=soot.CompilationDeathException+when+...&body=Steps+to+reproduce%3A%0A1.%29+...%0A%0AFiles+used+to+reproduce%3A+%0A...%0A%0ASoot+version%3A+%3Cpre%3Etrunk%3C%2Fpre%3E%0A%0ACommand+line%3A%0A%3Cpre%3E--soot-classpath+.%3BD%3A%5Cisoot%5CJava%5Cjre1.8.0_221%5Clib%5Crt.jar+-p+jtp.printcfg+graph-type%3ABriefBlockGraph+A+-src-prec+java%3C%2Fpre%3E%0A%0AMax+Memory%3A%0A%3Cpre%3E1799MB%3C%2Fpre%3E%0A%0AStack+trace%3A%0A%3Cpre%3Esoot.CompilationDeathException%3A+there+were+errors+during+parsing+and%2For+type+checking+%28JastAdd+frontend%29%0D%0A%09at+soot.JastAddInitialResolver.formAst%28JastAddInitialResolver.java%3A63%29%0D%0A%09at+soot.JavaClassSource.resolve%28JavaClassSource.java%3A54%29%0D%0A%09at+soot.SootResolver.bringToHierarchyUnchecked%28SootResolver.java%3A235%29%0D%0A%09at+soot.SootResolver.bringToHierarchy%28SootResolver.java%3A208%29%0D%0A%09at+soot.SootResolver.bringToSignatures%28SootResolver.java%3A266%29%0D%0A%09at+soot.SootResolver.processResolveWorklist%28SootResolver.java%3A170%29%0D%0A%09at+soot.SootResolver.resolveClass%28SootResolver.java%3A133%29%0D%0A%09at+soot.Scene.loadClass%28Scene.java%3A853%29%0D%0A%09at+soot.Scene.loadClassAndSupport%28Scene.java%3A839%29%0D%0A%09at+soot.Scene.loadNecessaryClass%28Scene.java%3A1569%29%0D%0A%09at+soot.Scene.loadNecessaryClasses%28Scene.java%3A1582%29%0D%0A%09at+soot.Main.run%28Main.java%3A250%29%0D%0A%09at+soot.Main.main%28Main.java%3A147%29%0D%0A%09at+soot.tools.CFGViewer.main%28CFGViewer.java%3A101%29%0D%0A%3C%2Fpre%3E
Please be as precise as possible when giving us
information on how to reproduce the problem. Thanks!
我知道soot可以从.class文件生成控制流图,但是soot对java版本有严格的要求,即只能使用1.7版本的jdk,否则容易报错。这对我来说是致命的缺点,因为我有100个java项目在等待生成控制流图,只有1.7个jdk编译这些项目很困难。
我发现一些用于软件测试的软件可以很容易地直接从源代码中生成控制流图,例如visutin。这种软件是如何生成控制流图的?有没有开源代码?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)