gdbserver + gdb嵌入式远程调试教程

环境:UBUNTU 16.04 ;HI3531A;
交叉编译工具:arm-hisiv300v-linux
 

准备工作:
在UBUNTU上面写一个hello.c:
#include <stdio.h>

int main ()
{
int i = 408;
printf("hello world\n");
return 0;
}

步骤:
1、
$ ===> UBUNTU ;# ===> ARM
2、
$ arm-hisiv300-linux-gcc -g hello.c -o hello
# gdbserver YourIPAdr:234 hello 
3、
$ arm-hisiv300-linux-gdb hello
然后:
(gdb) target remote ArmIPAdr:234

//开始远程调试~

*虚拟机这边的操作*
(gdb) l
Cannot access memory at address 0x0
1    #include <stdio.h>
2    
3    int main ()
4    {
5    int i = 408;
6    printf("hello world\n");
7    return 0;
8    }
(gdb) b 5
Breakpoint 1 at 0x8494: file hello.c, line 5.
(gdb) b 6
Breakpoint 2 at 0x849c: file hello.c, line 6.
(gdb) b 7
Breakpoint 3 at 0x84a4: file hello.c, line 7.
(gdb) c
Continuing.
warning: Could not load shared library symbols for 2 libraries, e.g. /lib/libc.so.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?

Breakpoint 1, main () at hello.c:5
5    int i = 408;
(gdb) c
Continuing.

Breakpoint 2, main () at hello.c:6
6    printf("hello world\n");
(gdb) p i
$1 = 408
(gdb) c
Continuing.

Breakpoint 3, main () at hello.c:7
7    return 0;
(gdb)

*arm这边的显示*
/mnt/armFile/temp/test # gdbserver 192.168.1.123:234 hello
Process hello created; pid = 1402
Listening on port 234
Remote debugging from host 192.168.1.123
hello world

(记得执行结果是在arm这边生效的)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dream_Kite

你的鼓励,是我不断创作的动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值