To use GDB (GNU Debugger) for debugging on RK3568, you need to make sure that the GDB tool suitable for this platform has been installed. Then, follow the steps below:
-
Connect to RK3568 development board or device.
-
When compiling your code on the development board, you need to ensure that debug information is enabled in the compile options. You can use
-g
the option to generate debug symbols. For example:$ gcc -g myfile.c -o myfile
-
Transfer the compiled executable file
myfile
to the RK3568 device. -
Open a terminal on the RK3568 device and navigate to the directory where the executable is located.
-
To start the GDB debugger, the command is
gdb
.$ gdb
-
Load the executable in GDB.
(gdb) file myfile
-
Set up the debugging environment, such as setting breakpoints, watching variables, etc.
(gdb) break main // 在 main 函数处设置断点 (gdb) run // 运行程序,触发断点停止 (gdb) print variable_name // 观察指定变量的值
-
Use GDB's other commands for debugging.
(gdb) next // 执行下一条语句 (gdb) step // 单步执行 (gdb) continue // 继续执行直到下一个断点