gdb调试方法

gdb交叉编译链接:https://blog.csdn.net/u013176681/article/details/39120653

gdb在线调试链接:https://blog.csdn.net/u010872301/article/details/80422796

gdb使用方法链接:https://blog.csdn.net/zdy0_2004/article/details/80102076

chenhao 大神的gdb:https://blog.csdn.net/haoel/article/details/2885

 gdb分析coredump文件方法:

1.coredump文件生成:

  ulimit -c unlimited
  echo 1 > /proc/sys/kernel/core_uses_pid
  echo "/tmp/core-%e-%s-%u-%g-%p-%t" > /proc/sys/kernel/core_pattern
  echo 2 > /proc/sys/fs/suid_dumpable

2.aarch64-marvell-linux-gnu-gdb (testprogram) (coredump)。需要注意的是testprogram目标文件必须是加-g选项编译出来的,并且是未去除符号表的,如果去掉调试信息的符号表则无法调试。

1、arm-linux-gcc
每一种硬件都有其对应的最好的编译工具,并不是最新的最好。其实思想很简单,就是在宿主机(PC)上编译目标板子上运行的程序。所以工具链要用目标板的,这样去编译生成可执行的二进制文件。这里有一个工具制作工具链,http://www.kegel.com/crosstool/。虽然它可以自动下,还是先下好吧自己,那个速度,呵呵。
2、arm-linux-gdb
(1)到http://www.gnu.org/software/gdb/download/下载gdb包,这个没有要求,因为它是个软件,只要用对的工具链编译就OK了。
(2)在本机安装arm-linux-gdb客户端。
#tar jxvf gdb-7.2-tar-bz2
#cd gdb-7.2
#./configure --target=arm-linux --prefix=/usr/local/arm-gdb –v(--target配置gdb的目标平台,--prefix配置安装路径)
#make
#make install
这样arm-linux-gdb的客户端就安装到了--prefix所配置安装路径里。
(3)在目标板上安装gdbserver。(其实就是在宿主机编好了复制过去)
#cd gdb-7.2/gdb/gdbserver
#./configure --target=arm-linux --host=arm-linux(--target=arm-linux表示目标平台,--host表示主机端运行的是arm-linux-gdb,不需要配置—prefix,因为gdbserver不在主机端安装运行)
#make CC=/usr/local/arm-linux-gcc-3.4.1/bin/arm-linux-gcc
把生成的 gdbserver 拷贝进目标板,一般在/usr/bin
(4)arm-linux-gdb + gdbserver 调试。
编译要调试的程序   #arm-linux-gcc -g hello.c -o hello
在目标板运行   #gdbserver 10.88.33.14:777 hello (#gdbserver 客户端IP地址:端口 调试的程序名)
在客户机运行   #arm-linux-gdb hello  (我都是在同一个目录里进行的,即mount到目标板的那个目录)
(gdb) target remote 10.88.33.1:777 (target remote 目标板IP地址:端口)
这样就可以调试了,结果会在目标版上显示出,这里用的minicom。输入run是会可能提示The "remote" target does not support "run".Try "help target" or "continue".那就用continue吧。

原文地址:https://www.cnblogs.com/qihualin-1024/p/10288532.html