DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  4737 随笔 :: 2 文章 :: 542 评论 :: 1615万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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,这下全了吧。哈

posted on   DoubleLi  阅读(2474)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示