In my code I have some runtime assert macro (let's call it runtime_assert). This should be in multi threaded application.
When condition passed evaluated to false, runtime_assert terminates program by dumping stack trace , followed by calling _exit().
As you probably know, dumping stack trace isn't a trivial task (How to get a stack trace for C++ using gcc with line number information?).
The idea is to invoke gdb with pid of the process by calling system().
- Is it good idea in general?
Or it's better to use process only tools to get backtrace? (e.g. gcc
backtrace()/backtrace_symbols()) - When ptrace() is invoked, will it somehow effect other threads?
- If system is out of resources (e.g. memory/disk space) may gdb fork fail?
- How to print stack trace of current thread only? (I can get address of current method from gcc backtrace())