gdb+gdbserver 使用

本文介绍如何从源码编译适用于MIPS架构的GDB及GDBServer,包括所需库文件的编译步骤,并演示了如何在PC端与目标板之间通过GDB进行远程调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


===========================================================================================
cross compile
============================================================================================

1.下载GDB源码
     ftp://ftp.gun.org/gun/gdb

2.编译需要的库termcap 和 gdb

 step 1:

compiling termcap-1.3.1.tar.gz

 $ tar zxvf termcap-1.3.1.tar.gz
 $ cd termcap-1.3.1
 $ mkdir -p /opt/termcap
 $ ./configure --host=mipsel-linux --prefix=/opt/termcap
 $ vi Makefile

   CC = mipsel-linux-gcc
   AR = mipsel-linux-ar
 $ make
 $ make install
 $ cp /opt/termcap/include/* /opt/mipseltools-clx-26/mipsel-linux/include/
 $ cp -a /opt/termcap/lib/* /opt/mipseltools-clx-26/mipsel-linux/lib/

 step 2:

    
     #cd /opt
     #tar zxvf gdb-6.6.tar.gz
     等待解压完毕,就会在/opt产生一个gdb-6.6的目录

 step 3:
      编译pc跑的mipsel-linux-gdb
     建立你的安装目录,比如/opt下面
     #mkdir -p /opt/gdb
     #../gdb-6.6/gdb/configure --host=i686-linux   --target=mipsel-linux   --prefix=/opt/gdb
     等待完毕........
     #make
     #make install
    
 step 4:
      编译开发板上跑的gdbserver
     接着编译我们的gdbserver,他最终会运行在我们的开发板
     同样我们在/opt下面建立我们的gdbserver安装目录
     #mkdir -p /opt/gdbserver
     #../gdb-6.6/gdb/gdbserver/configure --host=mips-linux --target=mipsel-linux --prefix=/opt/gdbserver
     #make
     #make install
     #cp -a /opt/gdbserver/bin/* /nfsroot/cq8401-mg3500/usr/bin/



3.接下来就是怎么使用gdb和gdbserver

 pc ip:192.168.4.200
 board ip: 192.168.4.100
 dir: /tmp/test.c
 code compile: mipsel-linux-gcc -g test.c -o test  
 cp test test.c /nfsroot/cq8401/tmp

 
  step 1:
  board 端:  
       # cd /tmp
       #gdbserver 192.168.4.200:2000 ./test
  step 2:
   pc 端:
    # export PATH=$PATH:/opt/gdb/bin
    # cd /lib
    # ln -s /opt/mipseltools-clx-26/lib/ld.so.1 ld.so.1   //库的匹配
       # ln -s /opt/mipseltools-clx-26/lib/ld.so.1 libc.so.6
  
    # cd /tmp
       # mips-linux-gdb ./test
            (gdb) target remote 192.168.4.100:2000

                接下来就是调试的具体过程了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值