码迷,mamicode.com
首页 > 数据库 > 详细

gdb 远程qemu-arm调试

时间:2014-06-18 06:50:45      阅读:424      评论:0      收藏:0      [点我收藏+]

标签:gdb

把 c 编译成 arm 指令的可执行文件

 /usr/bin/arm-linux-gnueabi-g++ hello.cpp 

cat hello.cpp 
#include <stdio.h>

void crash(){
 
    char *a=0;
    *a=0;
}
int main()
 {
        printf("hello world\n");
        crash();
        printf("after crash\n");
 }


直接运行报错,因为 host 是 linux x86

$ ./a.out 
-bash: ./a.out: cannot execute binary file


需要用 qemu-arm 来运行, 结果是期望的

qemu-arm -L  /usr/arm-linux-gnueabi/  a.out 

hello world

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)


进行远程调试(关键是增加 -g 参数,指定端口为1235) 

qemu-arm -g 1235 -L  /usr/arm-linux-gnueabi/  a.out 

执行用 linux-x86 的 gdb 并不能打印 symbol

(gdb) target remote :1235
Remote debugging using :1235
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
Cannot access memory at address 0x0
(gdb) file /home/payne/hello/a.out
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/payne/hello/a.out...(no debugging symbols found)...done.
(gdb) bt
#0  0x00000000 in ?? ()
Cannot access memory at address 0x0
(gdb) 

怀疑要使用 arm 的 gdb 

参见 http://mazhijing.blog.51cto.com/215535/40759, 编译了 arm 的gdb, 执行后定位到 crash()

qemu-arm -L  /usr/arm-linux-gnueabi/  ./gdb 
(gdb) target remote :1235
Remote debugging using :1235
warning: Can not parse XML target description; XML support was disabled at compile time
0x40801c40 in ?? ()
(gdb) file /home/payne/hello/a.out
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/payne/hello/a.out...(no debugging symbols found)...done.
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000841e in crash() ()
(gdb)   

结论:

      难道说 arm 的 gdbserver, 就只能用 arm 的 gdb?






gdb 远程qemu-arm调试,布布扣,bubuko.com

gdb 远程qemu-arm调试

标签:gdb

原文地址:http://blog.csdn.net/span76/article/details/31781271

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!