vorpal-research / kfg Goto Github PK
View Code? Open in Web Editor NEWLibrary for building CFG for Java bytecode
License: Apache License 2.0
Library for building CFG for Java bytecode
License: Apache License 2.0
create a way to lazily initialize containers
Exception when building cfg for this method
Binaries available here:
http://mirror.linux-ia64.org/apache//commons/math/binaries/commons-math3-3.6.1-bin.zip
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.remove(ArrayList.java:535)
at org.jetbrains.research.kfg.builder.cfg.CfgBuilder.pop(CfgBuilder.kt:80)
at org.jetbrains.research.kfg.builder.cfg.CfgBuilder.convertLocalStore(CfgBuilder.kt:373)
at org.jetbrains.research.kfg.builder.cfg.CfgBuilder.convertVarInsn(CfgBuilder.kt:418)
at org.jetbrains.research.kfg.builder.cfg.CfgBuilder.buildInstructions(CfgBuilder.kt:944)
at org.jetbrains.research.kfg.builder.cfg.CfgBuilder.build(CfgBuilder.kt:973)
at org.jetbrains.research.kfg.ClassManager.initialize(ClassManager.kt:81)
at org.jetbrains.research.kex.Kex.<init>(kex.kt:119)
at org.jetbrains.research.kex.MainKt.main(main.kt:7)
Invalid frame info for method
org/apache/commons/pool/impl/GenericKeyedObjectPool::destroy(java/util/Map, org/apache/commons/pool/KeyedPoolableObjectFactory): void
Implement pass system and pass manager for kfg visitors, similar to LLVM
Looks like equality check is inverted.
VoidType is equal to any other type for now.
Currently Phi instructions are built using dominator trees. It's the most complex part of the library which led to a lot of bugs.
All necessary information about phi's is already contained in jvm frames and it's easy to access. Need to consider using information from frames to avoid unnecessary complication.
fun createKFGGraphs(jars: List<Container>): MutableMap<String, MutableList<Graph>> {
log.info("Creating CGF for $containers")
val kfgGraphs = mutableMapOf<String, MutableList<Graph>>()
for (jar in jars) {
val cm = ClassManager(KfgConfig(Flags.readAll, failOnError = true))
cm.initialize(jar)
val graphs = mutableListOf<Graph>()
for (klass in cm.concreteClasses) {
for (method in klass.allMethods) {
if (!method.isNative)
graphs.add(method.toGraph(method.name + "::" + method.prototype.replace("/", ".")))
}
}
kfgGraphs[jar.name] = graphs
jar.update(cm, jar.path, jar.classLoader)
}
return kfgGraphs
}
Вылетает exception при попытке создать cfg как описано в readme:
Exception in thread "main" java.io.FileNotFoundException: D:\IdeaProjects\kex\kex-test-0.0.1-jar-with-dependencies.jar\kex-test-0.0.1-jar-with-dependencies.jar (Системе не удается найти указанный путь)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:126)
at org.jetbrains.research.kfg.util.JarBuilder.<init>(jar.kt:105)
at org.jetbrains.research.kfg.container.JarContainer.update(JarContainer.kt:115)
at org.jetbrains.research.kfg.container.JarContainer.update(JarContainer.kt:18)
При отладке выяснил, что проблема где-то здесь
val absolutePath = target.toAbsolutePath()
val jarName = file.name.substringAfterLast(File.separator).removeSuffix(".jar")
val jarPath = absolutePath.resolve("$jarName.jar")
val builder = JarBuilder("$jarPath", manifest)
В absolutePath
у меня D:\IdeaProjects\kex\kex-test-0.0.1-jar-with-dependencies.jar
, а в jarPath
, который потом в JarBuilder
передаётся, D:\IdeaProjects\kex\kex-test-0.0.1-jar-with-dependencies.jar\kex-test-0.0.1-jar-with-dependencies.jar
, что кажется очень странным
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.