08-04-2019, 04:50 AM
So you created a code, and while testing, the game crashes. What do you do?
Normally, you would restart the game, set a breakpoint on your code address, and painstakingly go stepping through code, frame by frame in some cases to try and pinpoint the cause of the crash.
This can take a long time, (you might get lucky though) and this in the long run, is extremely inefficient. So what you do is take advantage of these steps to skip all the hassle and go straight to the cause of the crash.
1.) Use Star's Exception Recovery code, which can be found here > https://mkwii.com/showthread.php?tid=116...83#pid2283
2.) With your faulty code and Exception Recovery activated, boot the game, and set a breakpoint on the instruction address: 00000300
3.) Play the game normally with the set breakpoint, and it will pause the game the instant the game crashes.
4.) You will see this set of code:
This is where the Exception Recovery code comes in. Just simply step through this set of code, and you will jump back to where the crash happened.
5.) All you need to do now is look at the instruction ABOVE the one you are on. This instruction is what caused the crash. Like this example:
You can gather a LOT of information from this. In this example, it would be that r30's value was set so that r7 tried to grab a value from an invalid address. So what do you do with the new-found info?
6.) Using what you found, look at your code and try to single out the cause, it could be bad coding that could be remedied with some fixes, or it could be an unsafe register.
7.) Once you have "fixed" the code, do the same steps again and if the game never breaks, you are good to go.
There you go! A nifty shortcut to bypass the struggles of predicting crashes and stepping through unneeded amounts of code.
Credits: Star (Exception Recovery)
Normally, you would restart the game, set a breakpoint on your code address, and painstakingly go stepping through code, frame by frame in some cases to try and pinpoint the cause of the crash.
This can take a long time, (you might get lucky though) and this in the long run, is extremely inefficient. So what you do is take advantage of these steps to skip all the hassle and go straight to the cause of the crash.
1.) Use Star's Exception Recovery code, which can be found here > https://mkwii.com/showthread.php?tid=116...83#pid2283
2.) With your faulty code and Exception Recovery activated, boot the game, and set a breakpoint on the instruction address: 00000300
3.) Play the game normally with the set breakpoint, and it will pause the game the instant the game crashes.
4.) You will see this set of code:
Code:
00000300 mtspr SPRG0, r3
00000304 mfspr r3, SRR0
00000308 addi r3, r3, 4
0000030c mtspr SRR0, r3
00000310 mfspr r3, SPRG0
00000314 rfi
5.) All you need to do now is look at the instruction ABOVE the one you are on. This instruction is what caused the crash. Like this example:
Code:
8039C8B8 lis r3, 0x807E
8039C8BC lhz r8, -0x2878 (r3)
8039C8C0 lwz r7, 0x0248 (r30) <----The cause of the crash
8039C8C4 rlwinm r7, r7, 0, 24, 28 <----The one we jumped to
8039C8C8 cmpw r7, r8
8039C8CC bgt ->0x803A780C
6.) Using what you found, look at your code and try to single out the cause, it could be bad coding that could be remedied with some fixes, or it could be an unsafe register.
7.) Once you have "fixed" the code, do the same steps again and if the game never breaks, you are good to go.
There you go! A nifty shortcut to bypass the struggles of predicting crashes and stepping through unneeded amounts of code.
Credits: Star (Exception Recovery)