QTCreator + gdbserver 实现远程调试

时间:2024-04-02 06:59:05

QTCreator + gdbserver 实现远程调试调试完成后才整理的,可能会遗漏一些步骤,大家可留言,我看到了会及时回复。。QTCreator + gdbserver 实现远程调试

  1. 环境说明:
  • ubuntu16.4  x86_64
  • yocto交叉编译环境
  • IMX6UL嵌入式平台
  1. 编译gdbserver,现有的gdb都是基于X86平台下的,如果需要在IMX6UL平台下运行,则需要下载gdb源码并进行交叉编译后方可在IMX6UL平台下运行。操作如下:
  • 下载gdb源码:http://ftp.gnu.org/gnu/gdb/ ,我下载的是最新版本8.1
  • 拷贝源码到Linux平台下,解压 :tar -xvf gdb-8.1.tar.xz 
  • 进入gdb-8.1目录,配置gdb:./configure --host=arm-poky-linux-gnueabi,make开始编译,不太漫长的等待。。。QTCreator + gdbserver 实现远程调试QTCreator + gdbserver 实现远程调试QTCreator + gdbserver 实现远程调试(gdb编译失败了,不纠结。我不需要gdb,我只需要gdbserver),进入gdb/gdbserver编译gdbserver。就是make了。
  • 在gdb/gdbserver目录下得到gdbserver在将其拷贝到IMUX6UL环境下的/usr/bin/(FTP、TFTP随便了。。。)
  • 在IMUX6UL下输入gdbserver查看能否运行:

[email protected]:~# gdbserver --version
GNU gdbserver (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "arm-poky-linux-gnueabi"

2、安装gdb-multiarch:

这个简单了,sudo apt-get install gdb-multiarch安装完成,运行如下:

 gdb-multiarch --version
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (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 "x86_64-linux-gnu".
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".
支持gdb相关的准备工作完成了。

3、配置QT Creator

  • 配置交叉编译QT-Creator(网上一大堆,我就不说了。。。)
  • 添加远程设备:(TOOLS->Options),如下图所示:
  • QTCreator + gdbserver 实现远程调试
  • 选择Devices页,添加设备,并做如下配置:
  • QTCreator + gdbserver 实现远程调试
  • 进入Build&Run页面,选择debuggers属性页,添加gdb-multiarch调试器。如下所示:
  • QTCreator + gdbserver 实现远程调试
  • 打开现有的QT工程,选择Project配置,点击Manager Kits,弹出如下界面:
  • QTCreator + gdbserver 实现远程调试
  • 点击已添加的kits(我的是imx6-ulx),修改device为上述步骤中添加的设备,选择调试为gdb-multiarch。下图作为参考如下所示:
  • QTCreator + gdbserver 实现远程调试
  • 还有一点需要注意:需要在工程文件中添加如下代码指定远程设备中的可执行文件:
  • target.path=/home/root/
    INSTALLS += target

  • 重新编译工程,点击debug即可开始远程调试了