【发布时间】:2021-03-01 18:13:15
【问题描述】:
例如,采取以下最小示例:
#include <cstdio>
#include <stdexcept>
int main(int argc, char* argv[]){
#ifdef __GLIBCPP__
std::printf("GLIBCPP: %d\n",__GLIBCPP__);
#endif
#ifdef __GLIBCXX__
std::printf("GLIBCXX: %d\n",__GLIBCXX__);
#endif
throw std::runtime_error("Were are libstdc++.so.6 debug symbols?");
return 0;
}
在我的gdb 中运行它时,它不显示libstdc++.so.6 的调试符号:
$ g++ -o testmain test.cpp -ggdb --std=c++98 && gdb ./testmain
GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
...
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./testmain...
(gdb) r
Starting program: /home/user/Downloads/testmain
GLIBCXX: 20200408
terminate called after throwing an instance of 'std::runtime_error'
what(): Were are libstdc++.so.6 debug symbols?
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt f
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
set = {__val = {0, 0, 0, 0, 0, 0, 0, 0, 29295, 0, 0, 0, 0, 0, 0, 0}}
pid = <optimized out>
tid = <optimized out>
ret = <optimized out>
#1 0x00007ffff7be1859 in __GI_abort () at abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = ... <stderr>}
sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x00007ffff7e67951 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#3 0x00007ffff7e7347c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#4 0x00007ffff7e734e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#5 0x00007ffff7e73799 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#6 0x000055555555524a in main (argc=1, argv=0x7fffffffdef8) at test.cpp:11
No locals.
(gdb)
它只为libstdc++.so.6 帧显示No symbol table info available。
如何显示libstdc++.so.6 的符号?
在此列表中搜索https://packages.ubuntu.com/search?keywords=libstdc%2B%2B6,我已经尝试安装以下软件包,但都没有解决问题:
libgcc-10-dev:amd64 <none> 10.2.0-5ubuntu1~20.0libstdc++-10-dev:amd64 <none> 10.2.0-5ubuntu1~20.0libstdc++6-10-dbg:amd64 <none> 10.2.0-5ubuntu1~20.0libc6-amd64-cross:all <none> 2.31-0ubuntu7crosslinux-libc-dev-amd64-cross:all <none> 5.4.0-21.25crosslibc6-dev-amd64-cross:all <none> 2.31-0ubuntu7crosslibstdc++6-amd64-cross:all <none> 10.2.0-5ubuntu1~20.04crosslibgcc-10-dev-amd64-cross:all <none> 10.2.0-5ubuntu1~20.04crosslibstdc++-10-dev-amd64-cross:all <none> 10.2.0-5ubuntu1~20.04crosslibstdc++6-10-dbg-amd64-cross:all <none> 10.2.0-5ubuntu1~20.04crosslibx32stdc++6-10-dbg:amd64 <none> 10.2.0-5ubuntu1~20.0
相关问题:
- How do you find what version of libstdc++ library is installed on your linux machine?
- /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
更新 1
$ dpkg --list | grep libstdc++6
ii libstdc++6:amd64 10.2.0-5ubuntu1~20.04 amd64 GNU Standard C++ Library v3
ii libstdc++6-10-dbg-amd64-cross 10.2.0-5ubuntu1~20.04cross1 all GNU Standard C++ Library v3 (debug build) (amd64)
ii libstdc++6-7-dbg:amd64 7.5.0-6ubuntu2 amd64 GNU Standard C++ Library v3 (debug build)
ii libstdc++6-amd64-cross 10.2.0-5ubuntu1~20.04cross1 all GNU Standard C++ Library v3 (amd64)
更新 2
$ dpkg --list | grep libstdc++6
ii libstdc++6:amd64 10.2.0-5ubuntu1~20.04 amd64 GNU Standard C++ Library v3
ii libstdc++6-10-dbg:amd64 10.2.0-5ubuntu1~20.04 amd64 GNU Standard C++ Library v3 (debug build)
ii libstdc++6-10-dbg-amd64-cross 10.2.0-5ubuntu1~20.04cross1 all GNU Standard C++ Library v3 (debug build) (amd64)
ii libstdc++6-amd64-cross 10.2.0-5ubuntu1~20.04cross1 all GNU Standard C++ Library v3 (amd64)
【问题讨论】:
-
sudo apt-get install libstdc++6或许可以解决问题 -
检查什么包提供了你的 libstdc++6 并安装相应的“-dbg”包。对于 Ubuntu 20.04,它应该是 libstdc++6-7-dbg 或 libstdc++6-10-dbg
-
@Botje ,我如何检查哪个包提供了我的
libstdc++6?我已经安装了libstdc++6-7-dbg、libstdc++6-10-dbg和libstdc++6,但问题仍然存在。我用dpkg --list | grep libstdc++6的输出更新了问题 -
那个输出说你的 libstdc++ 是 10.2.0,所以逻辑上你必须安装 libstdc++6-10-dbg 包,根据你的 dpkg 输出还没有安装。您安装的那个 -amd64-cross 包用于交叉编译。
-
@Botje ,现在我运行
sudo apt-get install libstdc++6-10-dbg并更新了dpkg --list | grep libstdc++6关于问题的输出。但是当我运行我的程序时,它仍然没有在堆栈帧上显示符号。
标签: c++ linux ubuntu gdb libstdc++