Skip to content

Commit b8c2030

Browse files
committed
Support WARDuino Tracing snapshot policy
1 parent baae5ba commit b8c2030

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/kotlin/be/ugent/topl/mio/debugger/Debugger.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import be.ugent.topl.mio.woodstate.Checkpoint
66
import be.ugent.topl.mio.woodstate.HexaEncoder
77
import be.ugent.topl.mio.woodstate.WOODDumpResponse
88
import be.ugent.topl.mio.woodstate.WOODState
9+
import com.fasterxml.jackson.core.JacksonException
910
import com.fasterxml.jackson.databind.ObjectMapper
1011
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
1112
import java.io.Closeable
@@ -72,7 +73,7 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
7273
checkpoints.add(checkpoint)
7374

7475
checkpointsUpdated()
75-
} catch(e: Exception) {
76+
} catch(e: JacksonException) {
7677
println("ERROR!")
7778
println(payloadStr)
7879
println(e)
@@ -453,11 +454,19 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
453454
class AtEveryInstruction() : SnapshotPolicy(1) {
454455
override fun toString() = "Snapshot at every instruction"
455456
}
456-
data class Checkpointing(val interval: Int = 20) : SnapshotPolicy(2) {
457+
data class Checkpointing(val interval: Int = 100) : SnapshotPolicy(2) {
457458
override fun serialize(): String {
458459
return super.serialize() + HexaEncoder.serializeUInt32BE(interval)
459460
}
460461
}
462+
data class Tracing(val minimumArgCount: Int = 1, val states: List<ExecutionState>) : SnapshotPolicy(3) {
463+
override fun serialize(): String {
464+
return super.serialize() +
465+
HexaEncoder.convertToLEB128(minimumArgCount) +
466+
HexaEncoder.convertToLEB128(states.size) +
467+
states.joinToString("") { HexaEncoder.convertToLEB128(it.ordinal + 1) }
468+
}
469+
}
461470
}
462471

463472
fun setSnapshotPolicy(policy: SnapshotPolicy) {

0 commit comments

Comments
 (0)