LINUX应用调试2:GDB调试应用程序
来源:互联网 发布:自然语言处理余弦算法 编辑:程序博客网 时间:2024/05/21 08:55
二、应用调试2:使用GDB来调试应用程序
编译:
编译gdb 运行于PC
tar xjf gdb-7.4.tar.bz2
cd gdb-7.4/
./configure –target=arm-linux
make
vi Makefile
/prefix
prefix = /usr/local
mkdir tmp
make install prefix=$PWD/tmp
把arm-linux-gdb复制到/bin目录
sudo cp arm-linux-gdb /bin
sudo chmod +x /bin/arm-linux-gdb
编译gdbserver 运行于ARM板
cd gdb/gdbserver/
./configure –host=arm-linux host:表示应用程序编译出来在哪里执行
然后make
出现错误:linux-arm-low.c:642: error: `PTRACE_GETSIGINFO’ undeclared (first use in this function)
linux-arm-low.c:642: error: (Each undeclared identifier is reported only once
linux-arm-low.c:642: error: for each function it appears in.)
缺少头文件
解决方法:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/tools/gcc-3.4.5-glibc-2.3.6/bin
cd /work/tools/gcc-3.4.5-glibc-2.3.6
grep “PTRACE_GETSIGINFO” * -nR
arm-linux/sys-include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202arm-linux/include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202distributed/arm-linux/sys-include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202distributed/arm-linux/include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202
cd -
/work/debug/gdb-7.4/gdb/gdbserverbook@book-desktop:/work/debug/gdb-7.4/gdb/gdbserver$ vi linux-arm-low.c
添加#include <linux/ptrace.h>
cp gdbserver /work/nfs_root/first_fs/bin
编译要调试的应用,编译时加上-g选项
调试:
//192.168.1.104是ARM上的地址
1. 在ARM板上
gdbserver 192.168.1.104:2345 ./test_debug
出现如下:
/ # gdbserver 192.168.1.104:2345 ./test_debug
Process ./test_debug created; pid = 774
Listening on port 2345
2. 在PC上
/bin/arm-linux-gdb ./test_debug
输入:target remote 192.168.1.104:2345
然后: 使用gdb命令来控制程序
另一种方法:
让程序在开发板上直接运行,当它发生错误时,令它产生core dump文件
然后使用gdb根据core dump文件找到发生错误的地方
在ARM板上:
1. ulimit -c unlimited
2. 执行应用程序 : 程序出错时会在当前目录下生成名为core的文件
然后在28th_app_debug目录下cp /work/nfs_root/first_fs/core .
/ # ulimit -c unlimited/ # ./test_debuga = 0x12Segmentation fault (core dumped)
在PC上:
3. /bin/arm-linux-gdb ./test_debug ./core
- LINUX应用调试2:GDB调试应用程序
- linux应用程序调试gdb+gdbserver
- linux下gdb调试应用程序
- linux应用开发-gdb调试
- Linux: gdbserver + gdb insight调试应用程序
- Linux下使用GDB调试应用程序示例
- 使用gdbserver+arm-linux-gdb 调试应用程序
- gdb调试应用程序
- [1]GDB调试应用程序
- [1]GDB调试应用程序
- linux 应用程序设计基础--GDB调试
- GDB调试应用
- GDB调试应用
- gdb远程调试arm+linux上的应用程序
- gdb对于linux应用程序调试实现机制浅析
- 用arm-linux-gdb调试ARM上的应用程序
- Linux下gdb 调试应用程序与动态库
- 用arm-linux-gdb调试ARM上的应用程序
- hdu 1711 KMP
- 基于Hexo+Next主题的个人博客搭建定制优化
- 【抗干扰代码】AVR单片机自动复位由于电压不足导致ENC28J60网卡出现的故障
- 使用hash法高效替换多个字符
- 用Python实现几个简单的图片特效
- LINUX应用调试2:GDB调试应用程序
- 牛刀小试
- 根据四个特征点求解相机位姿
- Struts2-Modeldriven接口用法
- 前端通用编码规范
- html中列表前的序号用带圆圈的数字表示及存在的问题
- 什么是数据库连接池?怎么配置tomcat的数据库连接池?
- 01-复杂度2 Maximum Subsequence Sum (25分)
- HDU 4569 Special equations(思维)——2013 ACM-ICPC长沙赛区全国邀请赛