How to programmatically cause a core dump in C/C++

后端 未结 10 1215
悲&欢浪女
悲&欢浪女 2020-11-28 01:24

I would like to force a core dump at a specific location in my C++ application.

I know I can do it by doing something like:

int * crash = NULL;
*cras         


        
10条回答
  •  庸人自扰
    2020-11-28 02:25

    As listed in the signal manpage, any signal with the action listed as 'core' will force a core dump. Some examples are:

    SIGQUIT       3       Core    Quit from keyboard
    SIGILL        4       Core    Illegal Instruction
    SIGABRT       6       Core    Abort signal from abort(3)
    SIGFPE        8       Core    Floating point exception
    SIGSEGV      11       Core    Invalid memory reference
    

    Make sure that you enable core dumps:

    ulimit -c unlimited
    

提交回复
热议问题