My function f throws an exception, and my program doesn't handle it. In gdb, I can get the backtrace as following
#0 0x00007ffff722ec59 in raise () from /lib64/libc.so.6
#1 0x00007ffff7230368 in abort () from /lib64/libc.so.6
#2 0x00007ffff7b35f85 in __gnu_cxx::__verbose_terminate_handler() () from /lib64/libstdc++.so.6
#3 0x00007ffff7b33ee6 in ?? () from /lib64/libstdc++.so.6
#4 0x00007ffff7b33f13 in std::terminate() () from /lib64/libstdc++.so.6
#5 0x00007ffff7b3413f in __cxa_throw () from /lib64/libstdc++.so.6
#6 0x00000000004006e6 in g () at x.cc:2
#7 0x00000000004006ef in f () at x.cc:6
#8 0x00000000004006fa in main () at x.cc:10
but if I change it to multithread,
std::thread t(f);
t.join();
Here is the backtrace.
#0 0x00007ffff7011c59 in raise () from /lib64/libc.so.6
#1 0x00007ffff7013368 in abort () from /lib64/libc.so.6
#2 0x00007ffff7b35f85 in __gnu_cxx::__verbose_terminate_handler() () from /lib64/libstdc++.so.6
#3 0x00007ffff7b33ee6 in ?? () from /lib64/libstdc++.so.6
#4 0x00007ffff7b33f13 in std::terminate() () from /lib64/libstdc++.so.6
#5 0x00007ffff7b8a345 in ?? () from /lib64/libstdc++.so.6
#6 0x00007ffff73a2f33 in start_thread () from /lib64/libpthread.so.0
#7 0x00007ffff70d0ead in clone () from /lib64/libc.so.6
Here is the test code:
void g() {
throw 1;
}
void f() {
g();
}
int main() {
f();
return 0;
}
My tools version are:
GNU gdb (GDB) Fedora 7.6.50.20130731-16.fc20
gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)
I compiled it with:
g++ x.cc -o x -ggdb -O0 -pthred -std=c++11
My question is How can I get the full backtrace for case 2?