zoukankan      html  css  js  c++  java
  • Linux下程序崩溃,ulimit,coredump,gdbserver

    操作系统: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 ",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,定位异常
            

    from:http://blog.chinaunix.net/uid-28458801-id-4349219.html

  • 相关阅读:
    常见问题
    查询
    多对多关系
    prototype & __proto__
    new operator
    用户
    express.Router
    Express 应用生成器
    LeanCloud
    npm常用命令
  • 原文地址:https://www.cnblogs.com/lidabo/p/4497727.html
Copyright © 2011-2022 走看看