Skip to content

Commit f53217e

Browse files
committed
Add step over line button
Similar to the step line button but this one steps over instead of in.
1 parent e5b8c01 commit f53217e

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
201201
messageQueue.waitForResponse("STEP!")
202202
//currentSnapshot = snapshotFull().second
203203
}
204+
fun stepUntil(cond: (WOODDumpResponse) -> Boolean) {
205+
stepInto()
206+
while (!cond(checkpoints.last()!!.snapshot)) {
207+
stepInto()
208+
}
209+
}
204210
open fun stepOver() {
205211
commandBreakpoint = true
206212
send(5)
@@ -210,10 +216,10 @@ open class Debugger(private val connection: Connection, start: Boolean = true, p
210216
}
211217
commandBreakpoint = false
212218
}
213-
fun stepUntil(cond: (WOODDumpResponse) -> Boolean) {
214-
stepInto()
219+
fun stepOverUntil(cond: (WOODDumpResponse) -> Boolean) {
220+
stepOver()
215221
while (!cond(checkpoints.last()!!.snapshot)) {
216-
stepInto()
222+
stepOver()
217223
}
218224
}
219225

src/main/kotlin/be/ugent/topl/mio/ui/InteractiveDebugger.kt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,23 @@ class InteractiveDebugger(
6363
private val stepIntoButton = JButton().apply {
6464
toolTipText = "Step a single instruction"
6565
}
66+
private val stepBackLineButton = JButton().apply {
67+
toolTipText = "Step to the previous line"
68+
}
6669
private val stepLineButton = JButton().apply {
6770
toolTipText = "Step to the next line"
6871
}
69-
private val stepBackLineButton = JButton().apply {
70-
toolTipText = "Step to the previous line"
72+
private val stepOverLineButton = JButton().apply {
73+
toolTipText = "Step over line"
7174
}
7275
private val flashButton = JButton().apply {
7376
toolTipText = "Upload module to microcontroller"
7477
}
7578
private val progressBar = JProgressBar().apply {
7679
isVisible = false
7780
}
78-
private val allButtons = listOf(pauseButton, stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, flashButton)
79-
private val pausedOnlyButtons = listOf(stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton)
81+
private val allButtons = listOf(pauseButton, stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, stepOverLineButton, flashButton)
82+
private val pausedOnlyButtons = listOf(stepBackButton, stepOverButton, stepIntoButton, stepLineButton, stepBackLineButton, stepOverLineButton)
8083
private var paused = false
8184

8285
init {
@@ -205,6 +208,31 @@ class InteractiveDebugger(
205208
updateStepBackButton()
206209
updatePcLabel()
207210
}
211+
stepOverLineButton.icon = FlatSVGIcon(javaClass.getResource("/debug-step-over.svg"))
212+
stepOverLineButton.addActionListener {
213+
if (sourceMapping == null) {
214+
stepBackLineButton.isEnabled = false
215+
return@addActionListener
216+
}
217+
218+
println("Step over line")
219+
var startLine = -1
220+
try {
221+
startLine = sourceMapping.getLineForPc(debugger.checkpoints.last()!!.snapshot.pc!!)
222+
} catch(re: RuntimeException) {
223+
System.err.println("WARNING: " + re.message)
224+
}
225+
debugger.stepOverUntil {
226+
try {
227+
sourceMapping.getLineForPc(it.pc!!) != startLine
228+
} catch(re: RuntimeException) {
229+
System.err.println("WARNING: " + re.message)
230+
false
231+
}
232+
}
233+
updateStepBackButton()
234+
updatePcLabel()
235+
}
208236
flashButton.icon = FlatSVGIcon(javaClass.getResource("/debug-update-module.svg"))
209237
flashButton.addActionListener {
210238
/*val dialog = JFileChooser()
@@ -240,6 +268,7 @@ class InteractiveDebugger(
240268
toolBar.addSeparator()
241269
toolBar.add(stepBackLineButton)
242270
toolBar.add(stepLineButton)
271+
toolBar.add(stepOverLineButton)
243272
toolBar.addSeparator()
244273
toolBar.add(flashButton)
245274
toolBar.addSeparator()

0 commit comments

Comments
 (0)