Skip to content

Commit a79544c

Browse files
committed
Keep track of last request step type across RUNNING boundary
1 parent 9db3361 commit a79544c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Common/src/main/kotlin/gay/object/hexdebug/adapter/DebugAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class DebugAdapter(val player: ServerPlayer) : IDebugProtocolServer {
379379

380380
override fun stepIn(args: StepInArguments): CompletableFuture<Void> {
381381
inRangeDebugger(args.threadId)?.let {
382-
handleDebuggerStep(args.threadId, it.executeOnce())
382+
handleDebuggerStep(args.threadId, it.executeUntilStopped(RequestStepType.IN))
383383
}
384384
if (args.singleThread == false) {
385385
resumeAllExcept(args.threadId)

Common/src/main/kotlin/gay/object/hexdebug/debugger/HexDebugger.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class HexDebugger(
4545
var lastEvaluatedMetadata: IotaMetadata? = null
4646
private set
4747

48+
private var lastStepType: RequestStepType? = null
49+
4850
// TODO: delegate to debug env?
4951
val envName: String? get() = currentEnv?.let { it::class.simpleName ?: it::class.jvmName }
5052

@@ -399,7 +401,7 @@ class HexDebugger(
399401
} else if (isAtBreakpoint()) {
400402
DebugStepResult(StopReason.BREAKPOINT)
401403
} else {
402-
executeUntilStopped()
404+
executeUntilStopped(lastStepType)
403405
}
404406

405407
registerNewSource(iotas)?.let {
@@ -411,6 +413,10 @@ class HexDebugger(
411413

412414
fun executeUntilStopped(stepType: RequestStepType? = null): DebugStepResult {
413415
val vm = getVM() ?: return DebugStepResult(null)
416+
417+
lastStepType = stepType
418+
if (stepType == RequestStepType.IN) return executeNextDebugStep(vm)
419+
414420
var lastResult: DebugStepResult? = null
415421
var isEscaping: Boolean? = null
416422
var stepDepth = 0
@@ -451,11 +457,13 @@ class HexDebugger(
451457
isEscaping = result.type == DebugStepType.ESCAPE
452458
}
453459

460+
@Suppress("KotlinConstantConditions")
454461
shouldStop = shouldStop || if (isEscaping) {
455462
result.type != DebugStepType.ESCAPE
456463
} else when (stepType) {
457464
RequestStepType.OVER -> stepDepth <= 0
458465
RequestStepType.OUT -> stepDepth < 0
466+
RequestStepType.IN -> throw IllegalStateException()
459467
}
460468

461469
if (shouldStop && shouldStopAtFrame(nextContinuation)) {
@@ -464,8 +472,6 @@ class HexDebugger(
464472
}
465473
}
466474

467-
fun executeOnce() = getVM()?.let { executeNextDebugStep(it) } ?: DebugStepResult(null)
468-
469475
/**
470476
* Copy of [CastingVM.queueExecuteAndWrapIotas] to allow stepping by one pattern at a time.
471477
*/
@@ -751,4 +757,5 @@ val ContinuationFrame.name get() = this::class.simpleName ?: "Unknown"
751757
enum class RequestStepType {
752758
OVER,
753759
OUT,
760+
IN,
754761
}

0 commit comments

Comments
 (0)