Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6384087
  • 博文数量: 579
  • 博客积分: 1548
  • 博客等级: 上尉
  • 技术积分: 16634
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-12 15:29
个人简介

http://www.csdn.net/ http://www.arm.com/zh/ https://www.kernel.org/ http://www.linuxpk.com/ http://www.51develop.net/ http://linux.chinaitlab.com/ http://www.embeddedlinux.org.cn http://bbs.pediy.com/

文章分类

全部博文(579)

文章存档

2018年(18)

2015年(91)

2014年(159)

2013年(231)

2012年(80)

分类: 嵌入式

2014-07-10 14:56:49

操作系统:Ubuntu10.04

前言:
    在程序崩溃后,如何快速定位问题。
    以下方法适用于开发调试阶段,不太适用成品。
    本文着眼于嵌入式,PC方面更简单。
    核心:gdbserver + coredump

一,安装,配置,使用 gdbserver
    arm linux下安装gdb,gdbserver调试器


二,启动 coredump
    linux下ulimit命令下的coredump 

三,实例
    1,源码

点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>


  4. static    void    fun(char* a,char *b)
  5. {
  6.     strcpy(a,"hello world");
  7.     strcpy(b,"wo shi zhong guo ren");

  8.     printf("%s,%s\n",a,b);
  9. }


  10. int main(int argc,char *argv[])
  11. {
  12.     char temp[5] = {0};
  13.     char temp2[5] = {0};
  14.     fun(temp,temp2);
  15.     
  16.     return 0;
  17. }

    2,结果
    
    

    3,通过gdbserver来查看异常所在
        a,设备,启动gdbserver
        

        b,pc机,调试设备中的程序
        

        c,pc机上的gdb中输入where,定位异常
        


阅读(4765) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~