S3C6410使用---3移植gdbserver并调试

1400阅读 0评论2014-12-07 644924073
分类:LINUX

  gdbserver进行调试时,需要编译出源码中的arm-linux-gdb和gdbserve,其中arm-linux-gdb运行在主机端,gdbserver运行在嵌入式开发板上。
一、移植gdbserver 7.4
1. gdbserver在gdb的源码包里,下载地址

2. 下载 gdb 7.4, 解压后进入gdb-7.4/gdb/gdbserver目录
root@ubuntu:~/gdb-7.4/gdb/gdbserver# ./configure --host=arm-linux --prefix=/tmp/gdbserver
修改Makefile中的交叉编译工具链:
CC =/opt/forlinux/4.3.2/bin/arm-none-linux-gnueabi-gcc

3. make 时会出错
linux-arm-low.c:120:21: error: sys/reg.h: No such file or directory
make: *** [linux-arm-low.o] Error 1
这时需要修改linux-arm-low.c
     119 #undef HAVE_SYS_REG_H //加入
     120 #ifdef HAVE_SYS_REG_H
     121 #include
     122 #endif
[参考文章]

二、进行调试
主机ip: 192.168.4.249
板子ip:  192.168.4.232
1. 板子
//gdbserver 连接到主机的1234端口
[root@FORLINX6410]# gdbserver 192.168.4.249:1234 ./hello
2. 主机
//进入gdb shell之后连接到板子的1234端口
root@ubuntu:~/# /opt/forlinux/4.3.2/bin/arm-none-linux-gnueabi-gdb ./hello
(gdb) target remote 192.168.4.232:1234
3.此时板子会打印
Listening on port 1234
Remote debugging from host 192.168.4.249
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the connection.
这个没有找到解决方法

三、改用gdb-6.6版本
 发现网上好多gdb-6.6版本调试的教程,试一下这个
3.1 gdb-6.6编译
    首先修改两个Makefile,将其中的 -Werror去掉,要不编译不通过
bfd/Makefile:185:WARN_CFLAGS = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror
opcodes/Makefile:175:WARN_CFLAGS = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror

3.2 
root@ubuntu:~/gdb/gdb-6.6# ./configure --target=arm-linux --prefix=/opt/gdb6.6

3.3 不去掉 -Werror报错如下:

点击(此处)折叠或打开

  1. elf32-arm.c: In function 'find_thumb_glue':
  2. elf32-arm.c:2452: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result
  3. elf32-arm.c: In function 'find_arm_glue':
  4. elf32-arm.c:2485: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result

  5. arm-dis.c: In function 'print_insn_thumb16':
  6. arm-dis.c:3101: error: format not a string literal and no format arguments
  7. arm-dis.c:3108: error: format not a string literal and no format arguments
  8. arm-dis.c: In function 'print_insn_thumb32':
  9. arm-dis.c:3651: error: format not a string literal and no format arguments
  10. arm-dis.c:3659: error: format not a string literal and no format arguments
  11. make[4]: *** [arm-dis.lo] Error 1
  12. make[4]: Leaving directory `/root/xeyez/gdb/gdb-6.6/opcodes'
  13. make[3]: *** [all-recursive] Error 1
四、进行调试
主机ip: 192.168.4.249
板子ip:  192.168.4.232
1. 板子
//gdbserver 连接到主机的1234端口
[root@FORLINX6410]# gdbserver 192.168.4.249:1234 ./hello
2. 主机
//进入gdb shell之后连接到板子的1234端口
root@ubuntu:~/# /opt/forlinux/4.3.2/bin/arm-none-linux-gnueabi-gdb ./hello
(gdb) target remote 192.168.4.232:1234
3.此时板子会打印
Listening on port 1234
Remote debugging from host 192.168.4.249
4.(gdb) b main
Breakpoint 1 at 0x14d978: file hello.c, line 14
(gdb) c
Continuing.
http://jesserei.blog.163.com/blog/static/121411689201082292342746/
上一篇:S3C6410使用---4移植gdb6.6
下一篇:uboot修改---tftp下载内核并启动内核