嵌入式Linux之gdb配置和使用
背景:
ARM Cortext-A53核+Linux 4.1.12,内核空间64位,用户态32位,gdb版本7.10.1
GDB编译:
1)手动下载gdb-7.10.1.tar.gz源码编译
./configure --host=arm-buildroot-linux-gnueabi --target=arm-buildroot-linux-gnueabi --prefix CC=/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin/arm-buildroot-linux-gnueabi-gcc AR=/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin/arm-buildroot-linux-gnueabi-ar
/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin/arm-buildroot-linux-gnueabi-gdb
target remote 192.168.1.108:3325
set sysroot /opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/arm-buildroot-linux-gnueabi/sysroot
./gdbserver 192.168.1.251:3325
(gdb) run
Starting program: /usr/local/test
warning: Unable to fetch general register.
PC register is not available
-----ptrace(PTRACE_GETREGSET)失败
(gdb) set libthread-db-search-path
(gdb) set auto-load libthread-db [on|off]
(gdb) info auto-load libthread-db
No auto-loaded libthread-db.
(gdb) show auto-load libthread-db
Auto-loading of inferior specific libthread_db is on.
/lib/libthread_db.so.1软链接指向/lib/libthread_db-1.0.so
如果缺少该库,报错如下:
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
同时,要保证该库没有被strip过,因为需要nptl_version符号,否则会报错:
Unable to find libthread_db matching inferior's thread library, ...
(gdb) run
Starting program: /usr/local/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Cannot find user-level thread for LWP 130: generic error