How can a C program produce a core dump of itself without terminating?

前端 未结 5 1150
悲哀的现实
悲哀的现实 2020-12-02 14:57

I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn\'t easily stopped and restarted to adj

5条回答
  •  感情败类
    2020-12-02 15:04

    Do you really want a core, or just a stacktrace ? If all you want is a stacktrace you could take a look at the opensource here and try and integrate the code from there, or maybe just calling it from the command line is enough.

    I believe some code in the gdb project might also be useful.

    Another think you might want to do is to use gdb to attach to a running process.

    $ gdb /path/to/exec 1234 # 1234 is the pid of the running process
    

提交回复
热议问题