How to generate a core dump in Linux on a segmentation fault?

前端 未结 12 1231
余生分开走
余生分开走 2020-11-22 17:06

I have a process in Linux that\'s getting a segmentation fault. How can I tell it to generate a core dump when it fails?

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 17:42

    For Ubuntu 14.04

    1. Check core dump enabled:

      ulimit -a
      
    2. One of the lines should be :

      core file size          (blocks, -c) unlimited
      
    3. If not :

      gedit ~/.bashrc and add ulimit -c unlimited to end of file and save, re-run terminal.

    4. Build your application with debug information :

      In Makefile -O0 -g

    5. Run application that create core dump (core dump file with name ‘core’ should be created near application_name file):

      ./application_name
      
    6. Run under gdb:

      gdb application_name core
      

提交回复
热议问题