Environment: Blackfin uClinux (Version: buildroot-2012R1-RC6-BF60X)
Linux host: Ubuntu 10.04.4
You can debug through the serial port or network. The following example uses network debugging as an example.
1. Compile the application on the Linux host: bfin-uClinux-gcc-g-O0-o a. out test. c
-G: Add debugging information to the executable file to make GDB work normally;
-O0: Set the optimization level to 0 for debugging.
2. copy the compiled Executable File A. Out to the root directory of uClinux on the Super Terminal:
Ftpget-u Joey-P 123456 192.168.1.159 A. Out/mnt/HGFS/uClinux-code/abc3000_src/a. Out
Grant a. out executable permissions:
Chmod A + x a. Out
Start gdbserver in uClinux:
Gdbserver localhost: 3456 A. Out (3456 is a port. If it does not conflict with other applications, you can change it to any port)
3. Run the following command on the Linux host: bfin-uClinux-gdb a. Out. GDB (A. Out. GDB is generated during compilation)
After GDB runs on the host, run the following command to connect to the target system: uClinux:
Target remote 192.168.1.122: 3456 (192.168.1.122 is the IP address of uClinux)
In this step, you can perform debugging:
Bytes --------------------------------------------------------------------------------------------------------
The following table lists common gdb commands:
Command |
Effect |
Start and Stop |
|
Quit |
Exit GDB |
Run |
Run the program (you can run command line parameters later) |
Kill |
Stop program |
Breakpoint |
|
Break sum |
Set a breakpoint at the entrance of the sum function |
Break * 0x80483c3 |
Set a breakpoint at address 0x80483c3 |
Delete 1 |
Deletes 1st breakpoints. |
Delete |
Delete all breakpoints |
Run |
|
Stepi |
Execute a command (Statement by statement, which will enter the function) |
Stepi n |
Execute n commands (Statement by Statement) |
Nexti |
Similar to stepi (process-by-process, no function entry) |
Continue |
Continue execution |
Finish |
Returns the result of running to the current function. |
Check Code |
|
Disas |
Disassemble the current function |
Disas sum |
Disassembly function Sum |
Disas 0x80483b7 |
Code near the disassembly address 0x80483b7 |
Disas 0x80483b7 0x80483c7 |
Decompiling code between two addresses |
Print/x $ PC |
Print the program counter in hexadecimal format |
List |
List source code |
List n |
List source code near line N |
Check Data |
|
Print $ R0 |
Print the R0 value in decimal format. |
Print/x $ R0 |
Print the R0 value in hexadecimal format |
Print/T $ R0 |
Print the R0 value in binary format. |
Print 0x100 |
Print 0x100 in decimal format |
Print/x 1024 |
Print the hexadecimal format of 1024 |
Print/T 1024 |
Print the binary format of 1024 |
Print/X ($ PC + 8) |
Print register PC content in hexadecimal format + 8 |
Print * (int *) 0xbffff890 |
Print the integer in 0xbfffff890 |
Print * (int *) ($ PC + 8) |
Print the integer in the address % PC + 8 |
Useful information |
|
Info Frame |
Current stack shard Information |
Info registers |
Information of all registers |
Help |
Obtains information about GDB. |
For more details, see: http://docs.blackfin.uclinux.org/doku.php? Id = debuggers & S [] = GDB