Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/kotlin/be/ugent/topl/mio/debugger/Debugger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
messageQueue.waitForResponse("STEP!")
//currentSnapshot = snapshotFull().second
}
fun stepUntil(cond: (WOODDumpResponse) -> Boolean) {
stepInto()
while (!cond(checkpoints.last()!!.snapshot)) {
stepInto()
}
}
open fun stepOver() {
commandBreakpoint = true
send(5)
Expand All @@ -210,10 +216,10 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
}
commandBreakpoint = false
}
fun stepUntil(cond: (WOODDumpResponse) -> Boolean) {
stepInto()
fun stepOverUntil(cond: (WOODDumpResponse) -> Boolean) {
stepOver()
while (!cond(checkpoints.last()!!.snapshot)) {
stepInto()
stepOver()
}
}

Expand Down
37 changes: 33 additions & 4 deletions src/main/kotlin/be/ugent/topl/mio/ui/InteractiveDebugger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ class InteractiveDebugger(
private val stepIntoButton = JButton().apply {
toolTipText = "Step a single instruction"
}
private val stepBackLineButton = JButton().apply {
toolTipText = "Step to the previous line"
}
private val stepLineButton = JButton().apply {
toolTipText = "Step to the next line"
}
private val stepBackLineButton = JButton().apply {
toolTipText = "Step to the previous line"
private val stepOverLineButton = JButton().apply {
toolTipText = "Step over line"
}
private val flashButton = JButton().apply {
toolTipText = "Upload module to microcontroller"
}
private val progressBar = JProgressBar().apply {
isVisible = false
}
private val allButtons = listOf(pauseButton, stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, flashButton)
private val pausedOnlyButtons = listOf(stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton)
private val allButtons = listOf(pauseButton, stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, stepOverLineButton, flashButton)
private val pausedOnlyButtons = listOf(stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, stepOverLineButton)
private var paused = false

init {
Expand Down Expand Up @@ -205,6 +208,31 @@ class InteractiveDebugger(
updateStepBackButton()
updatePcLabel()
}
stepOverLineButton.icon = FlatSVGIcon(javaClass.getResource("/debug-step-over.svg"))
stepOverLineButton.addActionListener {
if (sourceMapping == null) {
stepBackLineButton.isEnabled = false
return@addActionListener
}

println("Step over line")
var startLine = -1
try {
startLine = sourceMapping.getLineForPc(debugger.checkpoints.last()!!.snapshot.pc!!)
} catch(re: RuntimeException) {
System.err.println("WARNING: " + re.message)
}
debugger.stepOverUntil {
try {
sourceMapping.getLineForPc(it.pc!!) != startLine
} catch(re: RuntimeException) {
System.err.println("WARNING: " + re.message)
false
}
}
updateStepBackButton()
updatePcLabel()
}
flashButton.icon = FlatSVGIcon(javaClass.getResource("/debug-update-module.svg"))
flashButton.addActionListener {
/*val dialog = JFileChooser()
Expand Down Expand Up @@ -240,6 +268,7 @@ class InteractiveDebugger(
toolBar.addSeparator()
toolBar.add(stepBackLineButton)
toolBar.add(stepLineButton)
toolBar.add(stepOverLineButton)
toolBar.addSeparator()
toolBar.add(flashButton)
toolBar.addSeparator()
Expand Down
Loading