GDB没有显示来自带有调试符号的应用程序的回溯
GDB shows no backtrace from application with debug symbols
我用-g
和-O0
编译了我的可执行文件,当我用gdb运行它并得到std::bad_function_call
时,由于某些原因,gdb在我的应用程序中没有显示任何关于它起源的信息。顺便说一句,应用程序有两个线程,最有可能的异常不是来自主线程。
如此糟糕的回溯是什么原因?
terminate called after throwing an instance of 'std::bad_function_call'
what(): bad_function_call
[New Thread 0x7fffdd5dd700 (LWP 6955)]
[New Thread 0x7fffe6487700 (LWP 6953)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffdd5dd700 (LWP 6955)]
0x00007ffff3818267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
#0 0x00007ffff3818267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1 0x00007ffff3819eca in __GI_abort () at abort.c:89
#2 0x00007ffff412c06d in __gnu_cxx::__verbose_terminate_handler() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff4129ee6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff4129f31 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff4185ec1 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff4e716aa in start_thread (arg=0x7fffdd5dd700) at pthread_create.c:333
#7 0x00007ffff38e9eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) q
GCC版本为4.9.2
GDB版本为7.9
您的/usr/lib/x86_64-linux-gnu/libstdc++.so.6
副本可能被不适当地剥离或以其他方式损坏。
这里有一个测试程序:
#include <functional>
std::function<int()> foo;
void *thr(void *)
{
foo();
}
int main()
{
pthread_t tid;
pthread_create(&tid, nullptr, thr, nullptr);
pthread_join(tid, nullptr);
}
使用:g++ -g -std=c++11 t.cc
,然后:构建
gdb -q ./a.out
Reading symbols from ./a.out...done.
(gdb) run
Starting program: /tmp/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
terminate called after throwing an instance of 'std::bad_function_call'
what(): bad_function_call
[New Thread 0x7ffff6fd6700 (LWP 105567)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff6fd6700 (LWP 105567)]
0x00007ffff7529cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7529cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff752d0d8 in __GI_abort () at abort.c:89
#2 0x00007ffff7b36535 in __gnu_cxx::__verbose_terminate_handler () at ../../../../src/libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x00007ffff7b346d6 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:38
#4 0x00007ffff7b34703 in std::terminate () at ../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5 0x00007ffff7b34922 in __cxxabiv1::__cxa_throw (obj=0x7ffff0000940, tinfo=0x7ffff7dc16e0 <typeinfo for std::bad_function_call>, dest=0x7ffff7b86960 <std::bad_function_call::~bad_function_call()>) at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:87
#6 0x00007ffff7b868f2 in std::__throw_bad_function_call () at ../../../../../src/libstdc++-v3/src/c++11/functexcept.cc:113
#7 0x0000000000400917 in std::function<int ()>::operator()() const (this=0x601080 <foo>) at /usr/include/c++/4.8/functional:2470
#8 0x00000000004007d3 in thr () at t.cc:7
#9 0x00007ffff78c0182 in start_thread (arg=0x7ffff6fd6700) at pthread_create.c:312
#10 0x00007ffff75ed47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
如果您没有得到相同的结果(我想您不会),请尝试从libstdc++6
软件包重新安装libstdc++.so.6
。安装libstdc++6-dbg
也可能有所帮助。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 将无符号char*转换为std::istream*C++
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- vscode g++链路故障:体系结构x86_64的未定义符号
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 使用gcc从静态链接的文件中查找可选符号
- 回溯C++不打印函数,因此文件
- C++中无符号字符溢出
- 使用无符号字符数组有效存储内存
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- VC++本机单元测试,找不到调试符号
- 为什么我必须在C++中添加一个赋值符号来声明一个数组
- 检查TCHAR数组输入是否为带符号整数C++
- 在 C++/STL/MFC 应用程序启动早期发生的致命异常中,是否可以信任堆栈回溯符号名称?
- 如何从发布版本的回溯中恢复符号
- GDB没有显示来自带有调试符号的应用程序的回溯