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

后端 未结 10 1250
悲&欢浪女
悲&欢浪女 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:13

    Another way of generating a core dump:

    $ bash
    $ kill -s SIGSEGV $$
    

    Just create a new instance of the bash and kill it with specified signal. The $$ is the PID of the shell. Otherwise you are killing your current bash and will be logged out, terminal closed or disconnected.

    $ bash 
    $ kill -s SIGABRT $$
    $ bash
    $ kill -s SIGFPE $$
    

提交回复
热议问题