Emulator Issues #13794
open[Debugger] Unexpected behavior with Step Out and switch-case
0%
Description
Game Name?
Mario Golf: Toadstool Tour
Game ID?
GFTE01
MD5 Hash?
5fd9909e73df7fb704d2e443e17346b5
What's the problem? Describe what went wrong.
When debugging functions containing switch-case statements, using the Step Out function in Dolphin returns control too early, stopping execution after a switch-case jump rather than at the caller of the function.
This appears to happen when the switch statement compiles into a jump table using bctr
, and Dolphin's debugger misinterprets this indirect jump as the end of the function.
What steps will reproduce the problem?
I tested with multiple different functions containing switch-case statements and encountered the same behavior. This should apply to any game.
I will provide example values that caused me to initially find this bug.
- Place a breakpoint at the start of a function that contains a switch-case statement. (80416AD4)
- Resume until the breakpoint is hit. (Enter main gameplay and switch to a different club)
- Press Step Out.
- Instead of stepping to the caller (804107A0), Dolphin stops inside the function, right after a
bctr
jump. (80416BB4, 80416BC0, depending on which case triggered in the switch) - Pressing Step Out again correctly exits to the caller.
Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.
Yes, 2503a-340
Is the issue present in the latest release? For future reference, please also write down the version number of the latest release.
Yes, 2503a
Is there anything else that can help developers narrow down the issue? (e.g. logs, screenshots,
configuration files, savefiles, savestates)
Savestate with the PC at the prologue of the function containing the switch case (MacOS ARM, 2503)
https://files.catbox.moe/8uephf.sav
No data to display