When my KDE programs crash (which is pretty often :( ), I can generate a post-facto backtrace (I imagine it's not really post-facto, just that the errors are caught and saved) and use it to submit a bug report if I have the debug symbols installed. How does that work and how can I add that feature to my own programs?
I now have a problem with a program that I have written (in C++) that crashes intermittently, apparently due to memory mismanagement. It is highly impractical for me to run the program under gdb
because it is a large-scale simulation which requires several hours to run and the crash only appears when the size of the system is very high. Being able to automatically dump backtraces into a file would save me many hours.
I assume it involves wrapping everything in some sort of try{}catch(){}
routine but how do I get useful backtraces out of that? Is there a better way? All of my programming is on Linux, if that affects the answer.