Antony, Thank you for your reply and patience. Much appreciated. Your description (below) of our deployment environment is 90% right on the money... the remaining 10% are merely minor details. Very impressive! You are not developing a MindReader library, are you? :-) You won't believe how much operators hate/shun binary files... anything non-textual that they can't read... it's irrational but ultimately they call the shots... if we want their business of course. :-) And your code snippet is very straightforward, makes sense and pretty much what I need. Many thanks. I already voted for the inclusion of your lib... Can I now vote again with my other hand please? :-) I hope all goes well for your library and you personally. Can't wait to see you lib in Boost. On 2016-12-24 06:08, Antony Polukhin wrote:
2016-12-22 23:06 GMT+03:00 Vladimir Batov
: On 12/22/2016 10:21 AM, Andrey Semashev wrote:
... to save the backtrace to a file.
... I might have missed that but dumping the textual stack-trace to the log is still on the cards, right?
Actually, I think that Stacktrace must perfectly fit your needs. Here's how I understand your situation: you've got a big application, that runs 24/7 and is automatically restarted after a crash; a support team of non-developers that monitor it and send logs. It would be a disaster if your application hangs, so you need an async-signal-safe code. Sending corefiles is hard - application is big and support team is not trained to do that. Log files with a stacktrace would significantly help you in debugging.
Here's how you can use the stacktrace:
dump_stacktrace("/staktrace.txt"); // in signal handler, async signal safe
... // in main() if (filesystem::exists("/staktrace.txt")) { std::ifstream ifs("/staktrace.txt"); ifs >> stacktrace_variable; // pseudo code, have not thought it fully through log << stacktrace; // outputting stacktrace of previous crash with all the function names and source lines ifs.close(); filesystem::remove("/staktrace.txt"); }
This will give you the stacktrace of the previous crash in 100% safe manner that avoids hangs without any manual work from the support team.