文档详情

嵌入式交叉调试与工具软件.ppt

发布:2017-04-19约2.17千字共24页下载文档
文本预览下载声明
北华航天工业学院 房好帅 fanghaoshuai@;1.5 使用交叉版本的gdb调试ARM-Linux程序;1、编译安装arm-linux-gdb;这样就可以直接使用arm-linux-gdb命令,比如 arm-linux-gdb -v 显示其版本号及其他信息如下:;2、编译生成在ARM-Linux平台运行的gdbserver;3、使用交叉gdb调试程序;mytest.c;mytest.c;连接开发板与串口、网线,启动超级终端,设置开发板的IP地址,之后对开发板执行命令:;PC机的Linux系统中的arm-linux-gdb需要连接gdbserver,步骤为:;(3)在 (gdb) 提示符下输入 target remote 03:2001;GDB调试常用命令:;s 单步运行;(gdb) target remote 03:2001 Remote debugging using 03:2001 warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. 0x400007b0 in ?? () (gdb) l 1 Cannot access memory at address 0x0 1 #include stdio.h 2 3 int add2num(int arg0, int arg1) 4 { 5 return arg0 + arg1; 6 } 7 8 int avg3num(int arg0, int arg1, int arg2) 9 { 10 int tmp = add2num(arg0, arg1);;(gdb) 11 tmp = add2num(tmp, arg2); 12 return tmp/3; 13 } 14 15 int main() 16 { 17 int a = 5; 18 int b = 10; 19 int c = 15; 20 int avg = 0; (gdb) 21 printf(three number is:%d, %d, %d, a, b, c); 22 avg = avg3num(a, b, c); 23 printf(average is:%d, avg); 24 return 0; 25 } (gdb) b main Breakpoint 1 at 0x8428: file mytest.c, line 17. (gdb) b 23 Breakpoint 2 at 0x8474: file mytest.c, line 23.;(gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y 0in main at mytest.c:17 2 breakpoint keep y 0in main at mytest.c:23 (gdb) c Continuing. warning: `/lib/libc.so.6: Shared library architecture unknown is not compatible with target architecture arm. warning: Could not load shared library symbols for /lib/ld-linux.so.3. Do you need set solib-search-path or set sysroot? Breakpoint 1, main () at mytest.c:17 17 int a = 5; (gdb) Continuing. Breakpoint 2, main () at mytest.c:23 23 printf(average is:%d, avg); (gdb) p avg $1 = 10;另外一个功能,使用arm-linux-gdb分析core dump(核心转储)文件,可以定位程序错误位置,比如err_test.c:;编译程序时,生成的二进制文件带上调试信??:;可以使用arm-linux-gdb分析core dump文件: arm-linux-gdb err_test core ;1.6 源代码
显示全部
相似文档