Core dump in Linux

后端 未结 5 1277
深忆病人
深忆病人 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:31

    You will hardly get a decent stacktrace in human form if the code is a release mode/highly optimized version. Use the -g switch or forget about doing a stacktrace altogether...you cannot have both!! Which brings back to this point - it sounds like you are anticipating the code to crash even in production environment???

    Why don't you fix the code and ensure it works first...code smells .... sniff sniff

    Edit: Ok, I may have come across a bit harsh in my comment above, I did not intend to be harsh there...for the benefit of the readers, I have included a link to another question posted here, and in that answer I gave, uses signals to create a stack-trace and redirect to a file. It will be of help to the OP's question and aid him in troubleshooting...

提交回复
热议问题