Reputation: 131525
I'm trying to reproduce the first and simplest example in the Boost Stacktrace documentation.
#define BOOST_STACKTRACE_USE_BACKTRACE
#include <boost/stacktrace.hpp>
#include <iostream>
void bar(int n) {
if (n <= 0) {
// ... somewhere inside the `bar(int)` function that is called recursively:
std::cout << boost::stacktrace::stacktrace();
return;
}
bar(n-1);
}
int main() {
bar(4);
}
And am only having partial success: I'm getting the function name, but not the line:
0# bar(int) in ./plain_vanilla
1# bar(int) in ./plain_vanilla
2# bar(int) in ./plain_vanilla
3# bar(int) in ./plain_vanilla
4# bar(int) in ./plain_vanilla
5# main in ./plain_vanilla
6# __libc_start_main at ../csu/libc-start.c:342
7# _start in ./plain_vanilla
(my source file is named plain_vanilla.cpp
and my executable is plain_vanilla
.) I'm using Boost 1.73.0, which I built, on a Devuan 3.0 GNU/Linux. libbacktrace is installed (it's part of glibc) and I'm linking against it.
Is this more likely something I've done wrong, or is it an actual bug in the library?
Upvotes: 2
Views: 2203
Reputation: 316
To get more information in the stack track uses a debug build.
For GCC compile a project with the flag -g
or -fno-omit-frame-pointer
.
Upvotes: 3