远程调试之gdb移植
来源:互联网 发布:淘宝上网教可靠吗 编辑:程序博客网 时间:2024/06/05 15:56
实验环境:Ubuntu14.04LTS+Qt5.8+arm-none-linux-gnueabi-gcc 4.4.3+exynos4412+linux最小系统
第一步:下载gdb源码。gdb源码链接
第二步:解压并配置gdb。一般浏览器下载的文件在下载目录下,进入gdb源码所在目录,解压并进入gdb源码目录下:
cd ~/下载tar -xf gdb*.gz && cd gdb*./configure --target=/arm-none-linux-gnueabi -prefix=/usr/local/arm/gdb
配置过程中会在终端打印信息,配置完可以翻看下配置的是什么,最重要的是配置信息里面有没有找到你系统的交叉编译器。我系统安装了arm-none-linux-gnueabi-gcc的,所以target下是这个。后面的参数就是gdb将要安装的目录,自己填写想要安装的地方就是了。第三步:编译:终端输入make命令;如下编译成功。
第四步:开始安装了。终端输入:sudo make install。就会安装到之前配置的目录。事情当然不会是想象的那么顺利,这不就有第一个错误了。
WARNING: 'makeinfo' is missing on your system.
You should only need it if you modified a '.texi' file, or
any other file indirectly affecting the aspect of the manual.
You might want to install the Texinfo package:
<http://www.gnu.org/software/texinfo/>
The spurious makeinfo call might also be the consequence of
using a buggy 'make' (AIX, DU, IRIX), in which case you might
want to install GNU make:
<http://www.gnu.org/software/make/>
make[5]: *** [gdb.info] 错误 127
make[5]:正在离开目录 `/home/fh/下载/gdb-7.12/gdb/doc'
make[4]: *** [subdir_do] 错误 1
make[4]:正在离开目录 `/home/fh/下载/gdb-7.12/gdb'
make[3]: *** [install-only] 错误 2
make[3]:正在离开目录 `/home/fh/下载/gdb-7.12/gdb'
make[2]: *** [install] 错误 2
make[2]:正在离开目录 `/home/fh/下载/gdb-7.12/gdb'
make[1]: *** [install-gdb] 错误 2
make[1]:正在离开目录 `/home/fh/下载/gdb-7.12'
make: *** [install] 错误 2
解决办法:sudo apt-get install texinfo.
安装完继续sudo make install .这样就顺利没有报错,成功安装了。
第五步:查看安装目录有没有相应的lib,share,include,bin目录。有就把gdb添加到环境变量上,然后更新新的环境变量。profile文件最后一行添加export PATH=$PATH:/usr/local/arm/gdb7.12/bin
fh@pc:~/下载/gdb-7.12$ ls /usr/local/arm/gdb7.12/bin include lib sharefh@pc:~/下载/gdb-7.12$ sudo vim /etc/profilefh@pc:~/下载/gdb-7.12$ source /etc/profile
第六步:编译gdb-server。在gdb源码目录下有个gdb目录,其目录下有gdbserver目录,进入到这个目录。先配置好交叉编译工具,然后make安装gdbserver。cd gdb/gdbserver./configure --target=arm-none-linux-gnueabimake
这不make的时候又出错了。提示:linux-arm-low.c: In function ‘CORE_ADDR arm_sigreturn_next_pc(regcache*, int, int*)’:
linux-arm-low.c:769:29: error: ‘__NR_sigreturn’ was not declared in this scope
gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
^
./../common/gdb_assert.h:34:13: note: in definition of macro ‘gdb_assert’
((void) ((expr) ? 0 : \
^
linux-arm-low.c: In function ‘CORE_ADDR get_next_pcs_syscall_next_pc(arm_get_next_pcs*)’:
linux-arm-low.c:823:21: error: ‘__NR_sigreturn’ was not declared in this scope
if (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn)
^
make: *** [linux-arm-low.o] 错误 1
这个错误可就坑了,在系统arm-none-linux-gnueabi编译器路径下sys-root/usr/include/asm/unistd.h里面有定义__NR_sigreturn,也有定义__NR_rt_sigreturn。但是为什么编译的时候就找到了__NR_rt_sigreturn的定义了而找不到__NR_sigreturn的定义呢。解决办法很简单,他不是说没定义吗,那就在这个linux-arm-low.c文件中加上几句包含头文件的不就行了吗。
#ifndef __NR_sigreturn#include <asm/unistd.h>#endif好了,现在清除下之前生成出错的编译文件,终端输入sudo make clean.然后再次sudo make.如果提示报错交叉编译器找不到,那就切换到root用户,然后更新下环境变量,然后make。这下就大功告成了。直接生成了gdbserver文件了。
root@pc:/home/fh/下载/gdb-7.12/gdb/gdbserver# ls gdb*gdb_proc_service.h gdbreplay.c gdbserver gdb_vecs.ogdbreplay gdbreplay.o gdbthread.h因为这gdbserver是要放在开发板上的,就不用make install了。等会儿用nfs,或者U盘也好,把gdbserver考到开发板上执行就可以了。多说无益,现在就拷贝到板子上运行看看。由于我已经配置好了nfs,所以直接用nfs传文件到板子上。运行gdbserver命令,其中IP地址是主机的IP。
[root@itop-4412:/mnt/nfs$]#./gdbserver 192.168.31.100:2345 helloworldProcess helloworld created; pid = 5200 Listening on port 2345然后在主机上运行之前编译好的gdb。这里的helloworld也是经过静态交叉编译得来的。
fh@pc:~/linux$ arm-none-linux-gnueabi-gdb helloworldGNU gdb (GDB) 7.12Copyright (C) 2016 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-none-linux-gnueabi".Type "show configuration" for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at:<http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from helloworld...done.(gdb) target remote 192.168.31.230:2345Remote debugging using 192.168.31.230:23450x00008170 in _start ()(gdb)更多的测试还等后续进行,先写到这里吧!需要说明的是,开发板的lib库都是从arm-none-linux-gnueabi里面的库文件拷贝过来的。
等等,这篇文章写的是为Qt调试做准备的啊!没有关于qt的文字怎么能就此结束呢。其实qt安装gdb调试器很简单。打开Qt5.8任意一个工程文件,选上“-->项目-->Manage Kits-->构建和运行-->Debuggers-->add添加之前编译好的arm版gdb”确定应用。然后选上“设备-->add-->开始向导”如下图。下一步,完成即可。
在下一步完成之前最好先在板子上开启sshd,不然它会提示找不到远程设备。开启板子上的sshd,删掉Qt的exynos4412远端设备,再次新建,它就连接到了远程设备了。还有gdbserver文件最好还是放在板子系统上的bin目录下吧,不然运行远程调试,可能会找不到gdbserver哦。等真正调试qt程序的时候,就要提前把板子上的sshd开启。关于openssh的移植,下回在说,我这里提前移植好了的
接下来就打开一个hello的QT程序看看,远程调试效果吧。我是把qt-arm版的编译程序的文件目录给nfs共享了最小系统,然后在板子上对应的目录下执行gdbserver 主机ip:10000 hello -qws ,然后打开qt调试器,开始调试,出错。如下图编译输出
先写到这吧。这个问题没有想到解决办法。
gdb参考文章:gdbserver移植
gdb移植到arm板
qt添加gdb调试器参考文章:Qt 远程调试
- 远程调试之gdb移植
- 移植gdb工具-远程调试qt程序
- 嵌入式开发远程调试arm-linux-gdb的移植
- 远程调试应用程序之gdb+gdbserver
- GDB远程调试(一)之DM8168下gdb远程调试环境的搭建
- GDB远程调试(一)之DM8168下gdb远程调试环境的搭建
- gdb远程调试
- GDB远程调试
- GDB远程调试技术
- GDB远程调试
- gdb远程调试
- mini2440 gdb远程调试
- GDB远程调试技术
- GDB远程调试
- gdb远程调试 arm
- gdb server 远程调试
- gdb远程调试
- gdb远程调试
- 智能一代云平台(三十六):项目中如何做到避免传递依赖
- Java集合类:AbstractCollection源码解析
- TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议
- CentOS 7 下 WEB 项目运行环境初始化
- mysql linux下mysql取消区分大小写
- 远程调试之gdb移植
- pyCharm简单的使用
- 一位面试官推荐要自己写写东西
- SSH框架整体理解和总结
- 扩增子分析QIIME2. 2分析实战Moving Pictures
- ArrayList<类型>名称 ——记事本
- busybox移植到ARM开发板
- OpenGL 学习之旅(一)
- SQLPlus中文乱码问题解决方法——Windows10