refs:
http://liu1227787871.blog.163.com/blog/static/205363197201261204950218/
一)在ARM板上:
1. ulimit -c unlimited
2. 执行应用程序 : 程序出错时会在当前目录下生成名为core的文件
在PC上:
3、首先将core文件拷贝到pc机上
然后:/bin/arm-linux-gdb ./test_debug ./core
二)用gdb server调试
1、编译要调试的应用程序:必须要加-g选项,
按如下编译它:arm-linux-gcc -g -o test_debug test_debug.c
2、运行时出现错误:
/mnt/code/28th_app_debug # ./test_debug
a = 0x12
Segmentation fault
下面就开始进行调试
3、在开发板上:gdbserver 192.168.183.127:2345 ./test_debug
打印出如下信息:
Process ./test_debug created; pid = 751
Listening on port 2345
Process ./test_debug created; pid = 751
Listening on port 2345
其中
192.168.183.127:本开发板的ip
123:端口号,自己随便写的
./test_debug:要调试的程序
4、在PC上:/bin/arm-linux-gdb ./test-debug
target remote 192.168.183.127:2345
5、下面就可以正式调试了!我们先来说一下几个常用的命令
run,backtrace
run,backtrace
(1)l:列出所有源代码
(2)break main:在main处打断点
break test_debug.c:11:在test_debug.c的11行打断点
(3)c:运行到断点处
(4)step:单步执行
(5)next:单步执行,但是step会进入函数里面,但是next不会
(6)print a:打印a这个变量的值
(6)quit:退出,输入此命令则开发板上的gdbserver也退出
更详细的命令,我们在下一节里面会进一步来讲讲的!