GDB Tool for RISC-V Platform: A Practical Guide

Considering the limited debugging tools for the RISC-V platform, I compiled a version of GDB and GDB server suitable for RISC-V based on the source code from the GDB official website: gdb-12.1. I have verified its functionality on RISC-V terminal devices.
The tools have been uploaded to my personal GitHub:

https://github.com/season727/gdb_12.1_risc-v

Compilation Toolchain:

Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V2.10.2-20240904

Due to GitHub’s file size limitations, this repository only releases the binaries of gdb/gdbserver and the dependency library libgmp.

a. Push the binaries of gdb/gdbserver from the out directory and libgmp to the /usr/lib directory of the RISC-V terminal device, set the PATH search path, and use the ln -s command to create symbolic links.

# Usage, taking the gdb binary as an example

#1 adb push gdb-12.1\out\bin\gdb /tmp/

#2 chmod +x /tmp/gdb

#3 export PATH=/tmp/:$PATH

#4 root@Linux:/usr/lib# ln -s libgmp.so.10.4.1 libgmp.so

#5 root@Linux:/usr/lib# ln -s libgmp.so.10.4.1 libgmp.so.10

#6 gdb path_to_exe

#7 (gdb) run

#8 bt

b. Developers can also download the GDB source code themselves and modify the build_gdb.sh script in gdb-12.1, referencing their own compilation toolchain and modifying CONFIGURE_ARGS compilation parameters to compile the desired GDB tool.

If you like it, remember to follow me, and give my GitHub a star~ I will frequently upload and share debugging tools for various system platforms, including stability analysis and multimedia system analysis tools.
GDB Tool for RISC-V Platform: A Practical GuideLooking forward to more useful tools being launched~GDB Tool for RISC-V Platform: A Practical Guide

Leave a Comment