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这边生效的)

猜你喜欢

转载自blog.csdn.net/weixin_41501825/article/details/81703182
今日推荐