#include <boost/stacktrace.hpp>
// ... somewhere inside the `bar(int)` function that is called recursively: std::cout << boost::stacktrace::stacktrace();
In that example:
boost::stacktrace::
is the namespace that has all the classes and functions to work with the stack trace.
stacktrace()
is the default constructor call; constructor stores the current function
call sequence inside the stack trace class.
Header:
#include <boost/stacktrace.hpp>
Syntax:
std::cout << boost::stacktrace::stacktrace();
Program:
#include <signal.h> // ::signal, ::raise #include <boost/stacktrace.hpp> #include<iostream> int main() { void my_signal_handler(void); } void my_signal_handler(int signum) { ::signal(signum, SIG_DFL); boost::stacktrace::safe_dump_to("./backtrace.dump"); ::raise(SIGABRT); }
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
Name | Views | Likes |
---|---|---|
System Process Call using Fork() in C/C++ | 744 | 0 |
C++ Boost::Boost::Boost.fiber | 1023 | 0 |
C++Boost::Boost.Context::callcc | 730 | 0 |
C++ Boost::Beast | 3865 | 0 |
Sleep::System Call | 728 | 0 |
Determination of Child Process and Parent Process using fork() | 511 | 0 |
C++ Boost::Boost::Stacktrace | 2395 | 1 |
Introduction to Django CMS | 748 | 0 |
C++Boost::Boost.Function | 329 | 0 |
C++Boost::Boost.Metaparse | 426 | 8 |
C++ program to print common nodes on path from root | 353 | 4 |
std::system() | 1584 | 0 |
C++ Boost::Boost::Compatibility | 438 | 0 |
C++ Boost::Boost::Corountine2 | 588 | 0 |
C++ Signal Handler | 315 | 0 |
GUI Based Calculator using C++ Qt Framework | 3001 | 0 |
C++ Boost::Boost::CRC | 421 | 0 |
C++ program to print common nodes on path from root | 328 | 8 |
C++Boost::Boost.Python | 495 | 0 |
C++ Boost::Boost::Metaparse | 420 | 0 |
C++ Boost::Boost::Boost.fibre | 1230 | 1 |
C++ Eigen | 813 | 1 |
Data Visualization in C++ | 1306 | 1 |
Comments