Help you learn how to use gdb to debug SPARC assembly language programs
Paul, Section 2.7
Suppose we need to debug program rect.S...
Recall: gdb with C is very powerful
To use:
gcc -g -o myprog myprog.c"-g" option commands compiler to place debug information in object file
Generates an enhanced symbol table -- as described later in the course
Executable binary file thus also contains debug information
emacs (or xemacs)ESC x gdb myproggdb uses debug information to relate executable code to source files/lines
gdb uses that file/line information to communicate with Emacs
[Refer to "The gdb Debugger for Assembly Language Programs" summary sheet]
gdb with assembly language programs is much less powerful
We don't use the compiler, and so we have no way of getting debug information into the object files or executable binary file
gdb does not have source file/line information
No point in running under Emacs
Commands (e.g. list, breakpoint) that reference files and lines will not work
gcc -o rect rect.S
gdb rect
run
Note: Does not display lines
Same as with C, except cannot refer to source file names or line numbers
break main run
Must use nexti (ni) and stepi (si) instead of next (n) and step (s)
ni ni
info registers
Print the contents of all registers
print/d $l0
Print the contents of register %l0 in decimal format
Note: $l0, not %l0
x/i $pc
Print the contents of memory at the address contained in register %pc
display/i $pc
Add to the display list
At each program break, display the contents of memory at the address contained in register %pc
Very common/useful
(Same as with C)
(Same as with C)
Copyright © 2002 by Robert M. Dondero, Jr.