zoukankan      html  css  js  c++  java
  • Ubuntu下arm-linux-gdb+gdbserver的编译及安装(转载)

    注:arm-linux-gdb的安装路径是/usr/local/arm/3.4.1
    1arm-linux-gdb的编译安装
    下载gdb-6.8.tar.bz2至工作目录

    gdb源码下载:http://ftp.gnu.org/gnu/gdb/

    命令如下:

    $tar -jxvf gdb-6.8.tar.bz2
    $cd gdb-6.8
    $./configure --target=arm-linux --enable-sim --prefix=/usr/local/arm/3.4.1
    --prefix用于指定安装路径

    $make

    make时遇到以下错误:

    configure: error: no termcap library found

    make[1]: *** [configure-gdb] Error 1

    make[1]: Leaving directory `/home/lining/gdb-6.8'

    make: *** [all] Error 2

    解决方法:主要是缺少termcap库文件,在终端里执行sudo apt-get install libncurses5-dev安装
    $sudo make install
    完成后可以在/usr/local/arm/3.4.1/bin下找到arm-linux-gdb文件
    2arm-linux-gdbserver的编译安装
    进入./gdb/gdbserver

    命令如下:

    $cd gdb/gdbserver./configure --target=arm-linux --host=arm-linux 
    $make CC=arm-linux-gcc
    (CC=arm-linux-gcc用于指定arm-linux编译器)
    编译时出现PATH_MAX undeclared错误的解决方法:
    hostio.c文件中增加
    #include <linux/limits.h>
    原因是宏PATH_MAX<limits.h>中没有定义,而是定义在<linux/limits.h>

    (红色表示我在编译时没有碰到这个错误,此错误是网友整理的,留在这里以供以后参考)
    编译成功后在当前目录下会生成gdbserver文件,拷贝至开发板上(可放入开发板/usr/bin/目录下,这样在任何目录下均可执行gdbserver命令)

    gdb+gdbserver nfs调试流程

    通过NFS启动系统后,在开发板终端输入  # mount -t nfs -oonolock192.168.50.72:/opt/FriendlyARM/mini2440/root_qtopia  /mnt/  hello程序放在root_qtopia  下面.hello为要调试的程序(必须-g加入调试信息)。 

    #gdbserver 192.168.50.72:2345 hello  192.168.50.72为宿主机IP,在目标系统的2345端口(你也可以设其他可用的值,当然必须跟主机的gdb一致)开启了一个调试进程,hello为要调试的程序(必须-g加入调试信息)。  出现提示:  Process /mnt/hello created: pid=80  Listening on port 2345  (另一个终端下)  #cd /opt/FriendlyARM/mini2440/root_qtopia   #arm-linux-gdb hello  最后一行显示:This GDB was configured as “--host=i686-pc-linux-gnu,--target=arm-linux”...,如果不一致说明arm-linux-gdb有问题  说明此gdb在X86的Host上运行,但是调试目标是ARM代码。  (gdb) target remote 192.168.50.168:2345  (192.168.50.168为开发板IP)  Remote debugging using 192.168.50.168:2345  [New thread 80]  [Switching to thread 80]  0x40002a90 in ??()  同时在minicom下提示:  Remote debugging from host 192.168.50.72(gdb)  注意:你的端口号必须与gdbserver开启的端口号一致,这样才能进行通信。建立链接后,就可以进行调试了。调试在Host端,跟gdb调试方法相同。注意的是要用“c”来执行命令,不能用“r”。因为程序已经在Target Board上面由gdbserver启动了。结果输出是在Target Board端,用超级终端查看。连接成功,这时候就可以输入各种GDB命令如list、run、next、step、break等进行程序调试了。 

    参考网址:

    1. http://kenter1643.javaeye.com/blog/346894

    2. http://blog.csdn.net/chinacodec/archive/2009/02/11/3877901.aspx

    3. http://www.5dlinux.com/article/1/2009/linux_31924.html

  • 相关阅读:
    LeetCode Merge Two Sorted Lists 归并排序
    LeetCode Add Binary 两个二进制数相加
    LeetCode Climbing Stairs 爬楼梯
    034 Search for a Range 搜索范围
    033 Search in Rotated Sorted Array 搜索旋转排序数组
    032 Longest Valid Parentheses 最长有效括号
    031 Next Permutation 下一个排列
    030 Substring with Concatenation of All Words 与所有单词相关联的字串
    029 Divide Two Integers 两数相除
    028 Implement strStr() 实现 strStr()
  • 原文地址:https://www.cnblogs.com/gjfhopeful/p/3902975.html
Copyright © 2011-2022 走看看