arm-linux运行gdb,arm-linux-gdb+gdbserver环境搭建以及远程调试

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       #include2

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等。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译 `arm-linux-gnueabih-gdb` 和 `arm-linux-gnueabih-gdbserver` 的步骤如下: 1. 下载 GNU 工具链 - 从官网下载源代码:https://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.gz - 解压缩源代码:`tar -zxvf binutils-2.36.tar.gz` 2. 配置交叉编译环境变量 - `export CC=arm-linux-gnueabihf-gcc` - `export CXX=arm-linux-gnueabihf-g++` - `export AR=arm-linux-gnueabihf-ar` - `export AS=arm-linux-gnueabihf-as` - `export LD=arm-linux-gnueabihf-ld` - `export RANLIB=arm-linux-gnueabihf-ranlib` 3. 配置和编译 `binutils` - 进入源代码目录:`cd binutils-2.36` - 创建编译目录:`mkdir build && cd build` - 配置交叉编译环境:`../configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --prefix=/usr/local/arm-linux-gnueabihf` - 编译:`make` - 安装:`make install` 4. 配置和编译 `gdb` - 下载 GDB 源代码:https://ftp.gnu.org/gnu/gdb/gdb-10.1.tar.gz - 解压缩源代码:`tar -zxvf gdb-10.1.tar.gz` - 进入源代码目录:`cd gdb-10.1` - 创建编译目录:`mkdir build && cd build` - 配置交叉编译环境:`../configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --prefix=/usr/local/arm-linux-gnueabihf` - 编译:`make` - 安装:`make install` 5. 配置和编译 `gdbserver` - 下载 GDB 源代码:https://ftp.gnu.org/gnu/gdb/gdb-10.1.tar.gz - 解压缩源代码:`tar -zxvf gdb-10.1.tar.gz` - 进入源代码目录:`cd gdb-10.1/gdb/gdbserver` - 创建编译目录:`mkdir build && cd build` - 配置交叉编译环境:`export CC=arm-linux-gnueabihf-gcc` - 配置编译选项:`../configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --prefix=/usr/local/arm-linux-gnueabihf` - 编译:`make` - 安装:`make install` 注意:以上步骤仅供参考,实际操作时可能会因为环境和版本差异而有所不同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值