Core dump in Linux

后端 未结 5 1298
深忆病人
深忆病人 2020-12-28 09:15

I want to create a core dump whenever my process crashes. Currently I am following this approach:

  1. Build a special \"debug\" version of the program using \"-g\"
5条回答
  •  独厮守ぢ
    2020-12-28 09:44

    • Regarding the core limit, you can do it yourself in C by calling setrlimit.
    • On a GNU (glibc) or BSD system, you can get a backtrace by calling backtrace and related system calls. You will then have to translate the function addresses into function names by running addr2line (or duplicating its functionality).
    • Just don't use -g, you can still get a backtrace (except that inlined functions will not appear).

提交回复
热议问题