Thursday, August 4, 2011

Further Debugging in arm-elf-gdb

Here are a few quick words on using GDB, with particular reference to ARM files.

Inspect Registers
To have a look at a particular register, use the command print $[register_name]
For example,
print $r0
print $r1
print $pc
print can be abbreviated to p
p $r0
p $r1
p $pc

Change Register Values
Use the command print $[register_name] = [value]
For example,
print $r0 = 10
print $r1 = 0x20
print $pc = _start
Again, the abbreviation p can be used in place of print

Formatting Output
Format can be specified by using /[symbol] after the print command. Possible symbols are:
a for address
x for hexadecimal
d for signed decimal
u for unsigned decimal
o for octal
t for binary ('two')
c for character
f for floating point
For example
print/a $pcprint/x $r0p/c $r1p/t $cpsr 
(Use the last command to check the NZCV and interrupt flags)

No comments:

Post a Comment