GDB调试开发板上的应用程序的方法

来源:互联网 发布:钓鱼潮汐软件下载 编辑:程序博客网 时间:2024/05/29 17:20
采用gdb+gdbserver的方式进行调试
开发板包括gdbserver程序,PC上安装gdb程序。

1、下在gdb代码包,我用的是scratchbox集成工具链是下到的代码包。
gdb_6.4.90.dfsg.orig.tar.gz
  
  $  tar xvf gdb_6.4.90.dfsg.orig.tar.gz
 $ cd gdb-6.4.90.dfsg/
   $ mkdir obj
    $ cd obj
    .  ./configure  --target=armv-linux  --enable-shared --prefix=/tmp/gdb  --without-x --disable-gdbtk --disable-tui  --without-included-regex --without-included-gettext
$ make
$ make install
$ mkdir gdb/gdbserver

CC=/scratchbox/compilers/arm-linux-gcc-3.4.5-glibc-2.3.3/bin/arm-linux-gcc ../../../gdb/gdbserver/configure  --host=arm-linux --without-included-regex --without-included-gettext

$ make
$ cp -vf gdbreplay gdbserver /tmp/gdb/bin

2、 调试一个程序
    cp gdbserver 到 nfs文件系统下
    在开发板上
    /usr/gpephone/bin $ gdbserver 192.168.2.54:2345 ./helloworld
    出现
    Process hellowold created; pid = 948

 在PC机上
$ /tmp/gdb/bin/arm-linux-gdb ~/helloworld
  (gdb) b main
(gdb) target remote 192.168.2.181:2345
出现
Remote debugging using 192.168.2.181:2345
0x40000a60 in ?? ()

这是,开发板上将变成
/usr/gpephone/bin $ gdbserver 192.168.2.54:2345 ./helloworld
Process ./helloworld created; pid = 948
Listening on port 2345
Remote debugging from host 192.168.2.54

连接成功后,这时候就可以输入各种gdb命令如list、run、next、step、break等进行程序调试了。

目标机上的被调试程序hello, 与主机上的程序hello, 是相同的程序, 但位置不一样,并非是用网络共享的同一个位置的同一个文件, 一个在目标机上 ,一个在主机上, 没有关系

原创粉丝点击