把 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 參数,指定port为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?

最新文章

  1. crontab
  2. 网站通用登录模块代码 分类: ASP.NET 2014-12-06 10:49 615人阅读 评论(0) 收藏
  3. 二模 (10) day2
  4. HiveQ与传统SQL差异
  5. 十一、Android学习笔记_AsyncQueryHandler的应用
  6. eclipse 4 rcp: java.lang.RuntimeException: No application id has been found.
  7. Light OJ 1013 Love Calculator(DP)
  8. Android ViewFlow的一个例子
  9. 入我新美大的Java后台开发面试题总结
  10. Python_day1
  11. Redis入门必读,The Little Redis Book中文版
  12. CSS content换行实现字符点点点loading效果
  13. Python——python读取html实战,作业7(python programming)
  14. Hadoop生态圈-构建企业级平台安全方案
  15. Win10+Ubuntu 二三事
  16. 【洛谷P4113】采花 HH的项链+
  17. Pandas详解一
  18. GWAS | 全基因组关联分析 | Linkage disequilibrium (LD)连锁不平衡 | 曼哈顿图 Manhattan_plot | QQ_plot | haplotype phasing
  19. C#清理所有正在使用的资源
  20. 在手机上点击input框时会放大页面

热门文章

  1. 1104--DNA排序
  2. uva-11995 - I Can Guess the Data Structure!(栈,优先队列,队列,水题)
  3. 如何成为CSDN博客专家
  4. c/c++内存分配方式(转)
  5. 【转】 /etc/fstab功能详解
  6. BZOJ 1036: [ZJOI2008]树的统计Count( 树链剖分 )
  7. 仿爱乐透android客户端界面实现(附工程源码)
  8. HDU 3923 Invoker 【裸Polya 定理】
  9. 隐式意图-activity
  10. OC补充