Debugging in SPIM
CMPUT 229
University of Alberta
CMPUT 229 (University of Alberta) Debugging in SPIM 1 / 8
Outline
1 Debugging Programs
2 SPIM Debugging Features
3 Example
CMPUT 229 (University of Alberta) Debugging in SPIM 2 / 8
Debugging Programs
How Do You Debug?
CMPUT 229 (University of Alberta) Debugging in SPIM 3 / 8
Debugging Programs
How Do You Debug?
Breakpoints Single-stepping Inspecting variable values
CMPUT 229 (University of Alberta) Debugging in SPIM 3 / 8
SPIM Debugging Features
Breakpoints in SPIM
Can only set breakpoints by address or global symbol name. You can make symbols in your program global using the .globl directive.
Look up the address of the instruction you want to break on in the Text Segments pane in QTSPIM.
See all the global symbols by choosing global symbols in the print menu in QTSPIM.
Use the p(rint) command to show instructions in SPIM.
Use the print symbols command to show global symbols in SPIM.
Set a breakpoint by right clicking on the instruction QTSPIM, or the breakpoint command in SPIM.
CMPUT 229 (University of Alberta) Debugging in SPIM 4 / 8
SPIM Debugging Features
Stepping in SPIM
Click the “Single Step” button in QTSPIM. Use the s(tep) command in SPIM.
Just hit enter to repeat the last command – handy when single-stepping.
CMPUT 229 (University of Alberta) Debugging in SPIM 5 / 8
SPIM Debugging Features
Value Inspection in SPIM
As you know, there aren’t really variables in assembly language.
There are registers, and memory, where we keep values.
In QTSPIM, the registers are listed in the left pane, and values in memory can be found in the Data Segments pane.
In SPIM, use the p(rint) command to print values in registers or memory.
CMPUT 229 (University of Alberta) Debugging in SPIM 6 / 8
Example
Example
A simple program to calculate and display the Fibonacci sequence. But it doesn’t quite work …
CMPUT 229 (University of Alberta) Debugging in SPIM 7 / 8
Questions?
Questions?
CMPUT 229 (University of Alberta) Debugging in SPIM 8 / 8