Open hannobraun opened 1 month ago
This just got a bit more broken, as a result of fixing https://github.com/hannobraun/caterpillar/issues/54. When trying to continue, as suggested in the workaround, the debugger crashes. A new workaround might be to set a breakpoint, then click "Reset" instead of "Continue".
To be clear, the fixed "Continue" operation has the correct behavior. The problem is with "Stop" stopping at an invisible instruction.
This problem is no longer reproducible, as it is being masked by https://github.com/hannobraun/caterpillar/issues/55. The bug is still present in the code though, and should become reproducible again, once https://github.com/hannobraun/caterpillar/issues/55 is fixed.
Description
When pressing "Stop" in the debugger, the process can stop at an invisible instruction that has no fragment associated with it. In fact, this happens reliably when stopping the Snake game.
In this screenshot, the process has just executed the call to the
submit_frame
host function, which was then handled by the game engine. (The way the game engine is currently, it doesn't handle commands until a frame has been submitted, which is why the game always reliably stops here.) Since the effect has been handled, the process has advanced to the next instruction, which happens to be the invisible "return" instruction, which has no fragment associated with it that the debugger could show.This is especially problematic, since the step button is displayed next to the active fragment, which means no step button is displayed here.
Workaround
You can set a breakpoint anywhere in the code displayed here, and then press "Continue". This will run the game for another frame and stop at the breakpoint. From there, you have a "Step Into" button again. (Beware of https://github.com/hannobraun/caterpillar/issues/52 though.)
Proposed Solution
The debugger can detect this condition, and simply tell the process to evaluate one more instruction. (And if that leads to the same result, just repeat until we reach a fragment or the process finishes.)
As of this writing, no command exists that could tell the process to do that, but it should be trivial to add one. (And I'm pretty sure I'll add one soon anyway, as I think it's required for fixing https://github.com/hannobraun/caterpillar/issues/52.)