linux GDB调试器-02

前文介绍了GDB的编译。我们经过编译之后得到两个文件:gdb和gdbserver

下面开始嵌入式中使用gdb进行调试的方法介绍:

1.编译代码

arm-linux-gnueabi-gcc test.c -o test -g

一定要加‘-g’参数

2.嵌入式设备端

gdbserver 10.11.2.33:1122 test

gdbserver [IP]:[端口]  测试程序

注:这里的IP是设备IP,不是主机IP

# ./gdbserver 10.11.22.36:1122 test
Process /mnt/test created; pid = 127
Listening on port 1122
Remote debugging from host 10.11.22.36, port 57984

3.服务器端

target remote 10.11.2.33:1122

进入gdb后,target remote [ip]:[port]

注:这里的IP是设备IP,不是主机IP

# ./gdb
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote 10.11.2.33:1122
Remote debugging using 10.11.2.33:1122
Reading /mnt/test from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /mnt/test from remote target...
Reading symbols from target:/mnt/test...
Reading /lib/ld-linux.so.3 from remote target...
Reading /lib/ld-linux.so.3 from remote target...
Reading symbols from target:/lib/ld-linux.so.3...
(No debugging symbols found in target:/lib/ld-linux.so.3)
0xb6fcfa80 in _start () from target:/lib/ld-linux.so.3
(gdb)

GDB调试命令

b:打断点

c:继续执行

 

 

转载于:https://my.oschina.net/u/3231839/blog/3061083

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值