Skip to content

Commit

Permalink
Fix bug with tracing of approximated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniilStepanov committed Dec 1, 2023
1 parent 0c208ff commit 1185f3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions usvm-jvm-instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ kotlin {
dependencies {
implementation("org.jacodb:jacodb-core:${Versions.jcdb}")
implementation("org.jacodb:jacodb-analysis:${Versions.jcdb}")
implementation("org.jacodb:jacodb-approximations:${Versions.jcdb}")

implementation("com.jetbrains.rd:rd-framework:${Versions.rd}")
implementation("org.ini4j:ini4j:${Versions.ini4j}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.delay
import org.jacodb.api.JcClassOrInterface
import org.jacodb.api.JcClasspath
import org.jacodb.api.cfg.JcInst
import org.jacodb.api.ext.methods
import org.jacodb.approximation.JcEnrichedVirtualMethod
import org.usvm.instrumentation.generated.models.*
import org.usvm.instrumentation.rd.*
import org.usvm.instrumentation.util.findFieldByFullNameOrNull
Expand Down Expand Up @@ -196,13 +196,16 @@ class RdProcessRunner(
val jcClass =
deserializedClassesCache.getOrPut(classId) {
val className = coveredClasses.find { it.classId == classId }
?: error("Deserialization error")
jcClasspath.findClassOrNull(className.className) ?: error("Deserialization error")
?: error("Trace deserialization error")
jcClasspath.findClassOrNull(className.className) ?: error("Trace deserialization error")
}
val jcMethod = jcClass.methods.sortedBy { it.description }[methodId.toInt()]
if (jcClass.declaredMethods.any { it is JcEnrichedVirtualMethod }) {
return listOf()
}
val jcMethod = jcClass.declaredMethods.sortedBy { it.description }[methodId.toInt()]
jcMethod.instList
.find { it.location.index == instructionId }
?: error("Deserialization error")
?: error("Trace deserialization error")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.jacodb.api.JcField
import org.jacodb.api.JcMethod
import org.jacodb.api.cfg.JcInst
import org.jacodb.api.cfg.JcRawFieldRef
import org.jacodb.api.ext.methods
import org.usvm.instrumentation.collector.trace.TraceCollector
import org.usvm.instrumentation.instrumentation.JcInstructionTracer.StaticFieldAccessType
import org.usvm.instrumentation.util.enclosingClass
Expand Down Expand Up @@ -75,7 +74,7 @@ object JcInstructionTracer : Tracer<Trace> {

private fun encodeMethod(jcClass: JcClassOrInterface, jcMethod: JcMethod): EncodedMethod {
val encodedClass = encodeClass(jcClass)
val methodIndex = jcClass.methods
val methodIndex = jcClass.declaredMethods
.sortedBy { it.description }
.indexOf(jcMethod)
.also { if (it == -1) error("Encoding error") }
Expand Down

0 comments on commit 1185f3b

Please sign in to comment.