Download How to debug you GBA codes?

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
How to debug you GBA codes?
Computer Organization and Assembly 2010
Tz-Huan Huang
Debugging tools
• A debugger
–g
gdb,, insight,
g , etc
• An emulator which supports debugging
with your debugger
– Visual boy advance (VBA), etc
• Unfortunately, the win32 version of VBA
doesn’tt support gdb debugging any
doesn
more…
Visual Boy Advance,
Advance SDL version
• Fortunately, VBA-SDL bundles a tiny
gg itself.
debugger
• Go to http://vba.ngemu.com to
download it.
it
Basic steps
1.
2.
3.
4.
Build your assignment
Find the address of “myfilter’’
myfilter
Run VBA-SDL with debugging mode
Break your code at the address of
y lte
“myfilter’’
5. debug your codes
6. Repeat 1-5 until no bug left, then you
can submit yyour assignment
g
1 Build your program
1.
• (Install devkitPro first.)
• Launch the command
command-line
line box
• Go to the directory where you put the
h 3 ttemplate.
hw3
l t
– For example,
p
if yyou unzip
p hw3.zip
p to
c:\asm2010\hw3, then type the following
command to g
go there:
– c:\> cd c:\asm2010\hw3
• Type ``make’’
make to build your program.
program
2 Find the address of “myfilter”
2.
myfilter
• Use the “nm” tool bundled in devkitPro.
• For example, if you install devkitPro int
c:\devkitPro, you will find (either is ok)
– c:\devkitPro\devkitARM\bin\arm-eabi-nm.exe,
– c:\devkitPro\devkitARM\arm-eabi\bin\nm.exe
or
• R
Run “nm
“
h
hw3.elf”
3 lf” to fi
find
d the
h address
dd
off
“myfilter”
y
C:\> c:\...\arm-eabi-nm.exe hw3.elf
| g
grep
p myfilter
y
[ADDR] T myfilter
3 Run VBA
3.
VBA-SDL
SDL with debugging
• Download VBA-SDL and unzip it
• In command
command-line
line box, type
– C:\> [path to VBA-SDL]\VisualBoyAdvanceSDL –d
d hw3.gba
hw3 gba
4 Break your code at “myfilter”
4.
myfilter
• In VBA-SDL debugger, add a breakpoint:
– ba [addr]
[
]
where [addr] is the address of “myfilter”
• Type c to continue the program until the
break point
5 Debug your codes
5.
• Useful commands:
–
–
–
–
–
–
–
–
–
–
–
–
–
–
ba
bd
bl
c
d
eb
eh
ew
mb
mh
mw
n
q
r
Adds an ARM breakpoint
Deletes a breakpoint
Lists breakpoints
Continues execution
Disassembles instructions
Modify memory location (byte)
Modify memory location (half-word)
Modify memory location (word)
Shows memory contents (bytes)
Shows memory contents (half-words)
Shows memory contents (words)
Executes the next instruction
Quits the emulator
Sh
Shows
ARM registers
i t
• Use h or ? for more information
Happy
appy debugg
debugging!
g!