| | How to Debug Your Subroutines | |
| | Author | Message |
---|
-LeetGamer- Admin
Posts : 247 Points : 397 Reputation : 4 Join date : 2010-09-29 Age : 30
| Subject: How to Debug Your Subroutines Wed Sep 29, 2010 2:43 am | |
| This tutorial is on how to decode your non-working subroutines and find out what line is wrong. Steps: 1) Make sure your hook is working 2) Checking everything else 1) Make sure your hooks work Write a subroutine like this: - Code:
-
Lui t0, $0880 Lui t1, $1010 Sw t1, $1000(t0) Jr ra Nop
Now don't write the subroutine at address 0x1000, start at like 0x2000. Use the hook, go to the address 0x00001000 in the decoder, if you see the value: 0x10100000 in the decoder at that address then the hook works fine, if not then the problem is your hook. 2) Checking everything else Now that you know the hook is not your problem you can de-bug your subroutine, you will need to re-write it with a extra line each line but it is very usefull. Here is an example subroutine that doesn't work: - Code:
-
Lui t0, $0880 Lw t0, $1000(t0) J $00000000 Jr ra
Now the line that will freeze at is line three. So here is what I would add: - Code:
-
Lui t0, $0880 Beq zero, zero, $2 Nop Lw t0, $1000(t0) Beq zero, zero, $2 Nop J $00000000 Nop Beq zero, zero, $1 //Make sure this is 1 and not 2 Nop Jr ra Nop
Now this will execute the first line and then do nothing because it would keep jumping from branch to branch all the way to the jr ra. The value of 'Beq zero, zero, $2' is 0x10000002 now in game you want to change these the 2 to a 1, this will change the branch from branching to the next branch and to the next line, so the branch that you freeze on means that the next actual line after that branch has a problem, in this case the second 'Beq zero, zero, $2' will be the one that will freeze when I change it from 2 to 1. This can be a bit anoying to have to re-write your subroutine but you can use copy and paste because it is the same MIPS line when you add in the branches. Hope this help fix your subroutines! | |
| | | GunstarBlue
Posts : 37 Points : 41 Reputation : 0 Join date : 2010-09-29
| Subject: Re: How to Debug Your Subroutines Wed Oct 06, 2010 7:31 pm | |
| Ok, I just started to debug a pretty complicated subroutine and I had two questions. First question is, what do I do when I get to the lines in my subroutines that already have nops? Since Im adding - Code:
-
Beq zero, zero, $2 Nop do I still add that same line between the nops? 2nd question is, when exactly do I put the code - Code:
-
Beq zero, zero, $1 //Make sure this is 1 and not 2 if I have more the one jr ra in my subroutine? | |
| | | -LeetGamer- Admin
Posts : 247 Points : 397 Reputation : 4 Join date : 2010-09-29 Age : 30
| Subject: Re: How to Debug Your Subroutines Wed Oct 06, 2010 8:28 pm | |
| - GunstarBlue wrote:
- Ok, I just started to debug a pretty complicated subroutine and I had two questions.
First question is, what do I do when I get to the lines in my subroutines that already have nops? Since Im adding
- Code:
-
Beq zero, zero, $2 Nop do I still add that same line between the nops?
2nd question is, when exactly do I put the code
- Code:
-
Beq zero, zero, $1 //Make sure this is 1 and not 2 if I have more the one jr ra in my subroutine?
1) Do it for every line 2) That is for the very last jr ra in the code | |
| | | GunstarBlue
Posts : 37 Points : 41 Reputation : 0 Join date : 2010-09-29
| Subject: Re: How to Debug Your Subroutines Thu Oct 07, 2010 12:03 pm | |
| Ok, I re-wrote my sub with the extra lines so that I could debug. I went into the game and activated the code and everything is fine, but I don't know where the hell Im supposed to go to change the value to 1 so that I can check the branches.
I went to the decoder and I looked at where I wrote my code but this tutorial is not clear enough for me to understand what values I need to start changing to 1 so that it can go to the next branch.
If anyone can help I'd be very appreciative.
Thanks
-EDIT- Ok, I think I know what you're saying, the problem is the values for the
Beq zero, zero, $2 in my subroutines = values like 1000feb3 and so on, so what do I even switch them to to make branch to the next chain? Is it still 1? | |
| | | -LeetGamer- Admin
Posts : 247 Points : 397 Reputation : 4 Join date : 2010-09-29 Age : 30
| Subject: Re: How to Debug Your Subroutines Thu Oct 07, 2010 12:18 pm | |
| Right now the branches just branch to each other up til the jr ra. Now you need to subtract the branch value by 1 so it will branch to the line before the next branch, if you freeze then you know where the line is that freezes. | |
| | | GunstarBlue
Posts : 37 Points : 41 Reputation : 0 Join date : 2010-09-29
| Subject: Re: How to Debug Your Subroutines Thu Oct 07, 2010 12:38 pm | |
| Alright, I get it. I changed it and it froze after the very first line.
I'll post the rest of my findings in the original thread you were helping me in, as it has nothing to do with debugging. | |
| | | -LeetGamer- Admin
Posts : 247 Points : 397 Reputation : 4 Join date : 2010-09-29 Age : 30
| Subject: Re: How to Debug Your Subroutines Thu Oct 07, 2010 12:47 pm | |
| - GunstarBlue wrote:
- Alright, I get it. I changed it and it froze after the very first line.
I'll post the rest of my findings in the original thread you were helping me in, as it has nothing to do with debugging. Then the first line has an error | |
| | | Sponsored content
| Subject: Re: How to Debug Your Subroutines | |
| |
| | | | How to Debug Your Subroutines | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| |