Is there a way of obtaining information about why program got stuck, when not being able to insert any logs and not having pstack and gdb, on some very tiny linux?
My suggestion is to do the following:
Now (2.) and (3.) and pretty simple. For (3.) it's kill -USR1 1234 (for a process with ID 1234). For (2.), it's:
#include <signal.h>
typedef void (*sighandler_t)(int);
sighandler_t sigset(int sig, sighandler_t disp);
(read man sigset for details).
As for (1.), this used to be quite difficult and tricky, but now it's been essentially resolved:
Boost StackTrace: Code | Documentation
It will do the best possible to get as much stack trace info as is possible. A simple example of use:
#include <iostream>
#include <boost/stacktrace.hpp>
// ... somewhere inside the `bar(int)` function that is called recursively:
std::cout << boost::stacktrace::stacktrace();
may result in the following output:
0# bar(int) at /path/to/source/file.cpp:70
1# bar(int) at /path/to/source/file.cpp:70
2# bar(int) at /path/to/source/file.cpp:70
3# bar(int) at /path/to/source/file.cpp:70
4# main at /path/to/main.cpp:93
5# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
6# _start
Note: StackTrace is a very recent addition to Boost (as of August 2017); you might consider getting it independently if your Boost version is not recent enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With