Shortcut to Finding the Cause of a Crash
#1
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:
Code:
00000300 mtspr  SPRG0, r3
00000304 mfspr  r3, SRR0
00000308 addi   r3, r3, 4
0000030c mtspr  SRR0, r3
00000310 mfspr  r3, SPRG0
00000314 rfi
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:
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
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)
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#2
Nice thread Wink I'm still impressed at how fast you are learning all this ASM stuff, it took me AGES to learn the basics. Only thing I haven't seen you touch on is Function Calls (static analysis).
Reply
#3
I simply haven't needed to do any yet. Once I need to I will do it.
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#4
I'm going to try this, to figure out why a code that works fine in Dolphin, immediately crashes the Wii.
I made a Button toggled code for Manhunt 2, that makes the enemies blind/restores their vision.
Now when I say works fine, that was until last night, when I activated the code, in Dolphin, and it generated an error for the first time.
I was able to click on ignore, and game play continued, with the code working fine.

Hopefully I can make it "error" again with the Exception Recovery code running, and it will give me an idea of what may be causing the Wii to crash.

The code is not a C2 or C0 type.

I'm NOPing (4) branch conditionals and changing (1) to a direct branch using 32 bit RAM writes.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)