全部博文(82)
分类: LINUX
2011-10-27 14:10:39
这篇文章将分成3部分:
第一步:安装arm-linux-gcc 参考 http://www.cnblogs.com/xubing/archive/2010/06/02/1749798.html
第二步:安装、配置Eclipse 参考http://www.cnblogs.com/xubing/archive/2010/06/07/1752405.html
第三步:编译、配置GDB Server & GDB Client 参考http://www.cnblogs.com/xubing/archive/2010/06/07/1753257.html#2174927
前两部分都是比较简单的。下面来说说第三部分
按照第三部分做完基本上可以调试一些很小的程序,调试项目会由于缺少必要的库或者其他原因失败。
我就遇到这种问题:
Reading symbols from /home/xss/workspace/LPC3250Project/Debug/LPC3250Project...done.
warning: Can not parse XML target description; XML support was disabled at compile time
warning: `/lib/ld-linux.so.2': Shared library architecture unknown is not compatible with target architecture arm.
warning: `/lib/ld-linux.so.2': Shared library architecture unknown is not compatible with target architecture arm.
warning: `/lib/libpthread.so.0': Shared library architecture unknown is not compatible with target architecture arm.
warning: .dynamic section for "/lib/libpthread.so.0" is not at the expected address (wrong library or version mismatch?)
warning: `/lib/libm.so.6': Shared library architecture unknown is not compatible with target architecture arm.
warning: .dynamic section for "/lib/libm.so.6" is not at the expected address (wrong library or version mismatch?)
warning: `/lib/libgcc_s.so.1': Shared library architecture unknown is not compatible with target architecture arm.
warning: .dynamic section for "/lib/libgcc_s.so.1" is not at the expected address (wrong library or version mismatch?)
warning: `/lib/libc.so.6': Shared library architecture unknown is not compatible with target architecture arm.
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
Stopped due to shared library event
Stopped due to shared library event
后来我
调试过程如下:
(gdb) b main
Breakpoint 1 at 0x9870: file obexftp.c, line 376.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00009870 in main at obexftp.c:376
(gdb) c
Continuing.
Error while mapping shared library sections:
/work/install/bluetooth//lib/libobexftp.so.0: No such file or directory.
Error while mapping shared library sections:
/work/install/bluetooth//lib/libc.so.6: No such file or directory.
Breakpoint 1, main (argc=1, argv=0xbed0dec4) at obexftp.c:384
384 if (strstr(argv[0], "ls") != NULL) most_recent_cmd = 'l';
(gdb)
若产生这个错误主要是由于该调试的应用程序使用到了额外的库,而这个库在gdb默认的搜索路径内没有
(相对与远程调试,gdb默认搜索的路径即为交叉编译器的库路径,下面我会介绍到)
因此,这里我们需要修改一下gdb默认的共享库搜索路径。
修改的办法是设置GDB的环境变量:
(gdb) show solib-absolute-prefix
The current system root is "/opt/montavista/pro/devkit/arm/v5t_le/target".
上面这个路径即GDB默认的绝对搜索路径,即交叉编译器库路径
(gdb) show solib-search-path
The search path for loading non-absolute shared library symbol files is .
(gdb) set solib-search-path /work/install/bluetooth/lib
这个路径为若在solib-absolute-prefix指定的路径内没有搜索到库,则再继续尝试从该路径进行搜索。
这点倒有点类似于系统默认库搜索路径与LD_LIBRARY_PATH的关系。
详细参考GDB手册中相关部分:
设置好solib-search-path后再运行程序:
(gdb) set solib-search-path /work/install/bluetooth/lib/
(gdb) c
Continuing.
Error while reading shared library symbols:
Dwarf Error: Can't read DWARF data from '/opt/montavista/pro/devkit/arm/v5t_le/target/usr/lib/debug/lib/ld-2.5.90.so.debug'
Breakpoint 1, main (argc=1, argv=0xbe896eb4) at obexftp.c:384
384 if (strstr(argv[0], "ls") != NULL) most_recent_cmd = 'l';
(gdb) l
379 char *output_file = NULL;
380 char *move_src = NULL;
381 /* char *inbox; */
382
383 /* preset mode of operation depending on our name */
384 if (strstr(argv[0], "ls") != NULL) most_recent_cmd = 'l';
385 if (strstr(argv[0], "get") != NULL) most_recent_cmd = 'g';
386 if (strstr(argv[0], "put") != NULL) most_recent_cmd = 'p';
387 if (strstr(argv[0], "rm") != NULL) most_recent_cmd = 'k';
388
(gdb)
运行成功
说实话,这样调试比较难用,后来我直接移植GDB到开发板直接调试。很好用,就放弃远程调试了。
参考网页:http://blog.chinaunix.net/space.php?uid=23381466&do=blog&id=309369
http://hi.baidu.com/dos2004/blog/item/6bb39ad9539c612a11df9bdd.html
http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3378510
xingfuhaitun2011-10-27 17:56:15
如果同过串口调试, 需要执行如下的命令.
1、在板子上运行命令:
gdbserver hello /dev/ttyS0
2、然后在pc机上运行命令:
arm-linux-gdb hello
3、在arm-linux-gdb里敲入入下命令:
set remotedevice /dev/ttyS0(这里设置串口1)
set remote baud 9600 (这里设置串口波特率)
set debug remote 1(可选)
target remote /dev/ttyS0
操作到这儿,gdb就应该和gdbserver联系上了。