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

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

     #include 
     #include 
     int main()
     {
       printf("\n");
       printf("Process is aborting\n");
       abort();
       printf("Control not reaching here\n");
       return 0;
     }
    

    use this approach wherever you want :)

提交回复
热议问题