| |||
Home > Command-Line Development > The hello world example > Debugging hello.c |
Follow these steps to debug hello.c
at
the source level:
Quit the debugger if it is still running.
Enter armcc -g+ hello.c -o hello2 to recompile the program with high-level debugging information.
The -g+
option instructs the compiler to
include debug information.
Enter armsd hello2 to load hello2
into
the debugger.
Enter break main at the armsd
prompt to set a breakpoint on the first statement in main()
.
Enter go to execute the program up to the breakpoint.
The debugger reports that it has stopped at breakpoint #1, and displays the source line.
You can enter debugging commands to examine register contents and source code:
To display the contents of the registers enter: reg.
To list the C source, enter: type.
This displays the whole source file. The type command can also display sections of code. For example, enter: type 1,6 to display lines 1 to 6 of the source.
To list the assembly code enter: list
The assembly code around the current position in the program is shown. You can also list memory at a given address, for example: list 0x8080
Refer to armsd or the ARM Software Development Toolkit Reference Guide for more information on using the command-line debugger.