我想直接从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版本有严格的要求,即只能使用jdk的1.7版本,否则很容易报错。这对我来说是一个致命的缺点,因为我有100个java项目在等待生成控制流图,而仅用1.7jdk编译这些项目是很困难的。
我发现一些用于软件测试的软件可以很容易地直接从源代码生成控制流图,比如visutin。这种软件是如何生成控制流图的?有开源代码吗?
视蛋白
1条答案
按热度按时间4dc9hkyq1#
为什么不纠正语法错误然后运行soot呢?这比构建自己的语法容错工具要容易得多,至少要少花3个月的时间。实际上,问题似乎是你有一个不完整的项目,依赖关系没有解决,
Cache2kBuilder
在这种情况下。如何开发?解析代码(例如,使用antlr),将解析树转换为符号化的可视化表示。默认情况下,antlr在某种程度上是容错的。
烟尘本身是开源代码顺便说一句,你可以调整它来满足你的需要,也许它可以通过一些调整来处理一个不完整的解析树。当然,您只能将可以解析的部分可视化,而不能将损坏的部分可视化。
这里还提到了其他工具。