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

1) 编译arm-linux-gdb

指定交叉编译工具链的位置

export PATH=$PATH:/usr/local/arm/3.4.1/bin
    开始配置和编译

$cd gdb-6.6
    $./configure --target=arm-linux --prefix=/usr/local/arm/gdb -v
   $make
   

中间会出现一些地方编译过去,如

gdb declared with attribute warn_unused_result

检查了下,发现是由于检查太严格了,把 Makefile 里面 -Wall 类似的强制警告检查都去掉就可以过了

2) 编译gdbserver
    $cd gdb/gdbserver
    $./configure --target=arm-linux --host=arm-linux
      target含义同前,host指明编译生成的gdbserver运行在arm-linux上,前者没有设定host的原因是
      arm-linux-gdb是在pc linux上运行的,就像arm-linux-gcc (很好理解的:))
    $
make CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc

   #gdbserver 192.168.1.200:7777 test
     Process test created; pid                                                                                   
     Listening on port 7777

主机shell下
   $cd ~/tftpboot
   $arm-linux-gdb test
    GNU gdb 6.6 
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-linux"...
    (gdb)
    注意一下显示信息的最后--host=i686-pc-linux-gnu --target=arm-linux,明白了吧。。。
    target remote 192.168.1.168:7777   --连接gdbserver
    Remote debugging using 192.168.1.168:7777
    0x40000dd0 in _start () from /lib/ld-linux.so.2
    表示连接上了服务器,:),接下来就可以调试了。arm-linux-gdb和GDB的用法一样,只是没有r这个命   
   令,运行程序用c命令。
    (gdb) l
   1       #include<stdio.h>
   2
   3       int main()
   4       {
   5               char *ptr = "csdn";
   6               printf("%c/n",*(ptr++));
   7               return 0;
   8       }
    (gdb) b 3
   Breakpoint 1 at 0x83d0: file test.c, line 3.

另外由于程序是在目标板上运行,调试是在PC下,程序的结果还是会在目标板上显示的, 
   例如:minicom,lcd等。
   btw,附近一篇介绍GDB使用的文章:http://blog.csdn.net/haoel/archive/2003/07.aspx,这下全了吧。哈

最新文章

  1. 将Linux下的Android签名对pk8和pem转换为Eclipse下的签名(keystore)
  2. Maven发布web项目到tomcat
  3. 私人定制自己的linux小系统
  4. Activity的测量(Measure)、布局(Layout)和绘制(Draw)过程分析
  5. oc语言--语法
  6. prime算法求最小生成树(畅通工程再续)
  7. [SQL Server优化]善用系统监视器,确定系统瓶颈
  8. win7开启telnet客户端
  9. call和apply和bind区别
  10. Java 第一次作业
  11. 生鲜配送管理系统_升鲜宝V2.0 小标签打印功能【代配送商品打印小标签功能】说明_15382353715
  12. python 可视化界面
  13. Windows环境下IOS APP打包上传AppStore详细流程
  14. enum &amp; json 之间的转换
  15. python文档自动翻译
  16. Python paramiko 修改源码实现用户命令抓取
  17. java理论学时第七节。课后作业。
  18. [日常] Go语言圣经--作用域,基础数据类型,整型
  19. Problem A: 踢罐子 解题报告
  20. 为sharepoint的内部页面添加后台代码

热门文章

  1. OpenCV 3.0中IplImage* 转cv::Mat
  2. ETL(Extract-Transform-Load的缩写,即数据抽取、转换、装载的过程)
  3. synchronized 修饰static方法
  4. sqlalchemy源代码阅读随笔(2)
  5. Android xmlpull 方式解析xml文件
  6. Java写到.txt文件,如何实现换行
  7. [bzoj3218]a + b Problem 网络流+主席树优化建图
  8. [BZOJ2151] 种树 贪心
  9. android9.0请求异常
  10. 8、Flask实战第8天:add_url_rule和app.route原理