【发布时间】:2019-12-14 05:36:36
【问题描述】:
我正在使用此代码作为测试。
#include <sstream>
#include <iostream>
int main () {
std::stringstream ss;
ss << "This is a test\n";
std::cout << ss.str();
}
我编译
g++ -O0 -g test.cpp。当我在 gdb 中运行程序并在 cout 行的断点处停止时,尝试打印 ss 或 ss.str() 失败。
(gdb) p ss
$1 = <incomplete type>
(gdb) p ss.str()
Couldn't find method std::stringstream::str
gdb 还给了我大量关于 libstdc++ 和 libc 的调试信息与它们各自的库不匹配的警告,然后是一个额外的警告,建议我安装单独的 debuginfos。
warning: the debug information found in "/usr/lib/debug/usr/lib64/libc-2.17.so.debug" does not match "/lib64/libc.so.6" (CRC mismatch).
warning: the debug information found in "/usr/lib/debug/usr/lib64/libstdc++.so.6.0.19.debug" does not match "/lib64/libstdc++.so.6" (CRC mismatch).
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.6.x86_64 libstdc++-4.8.5-36.el7_6.2.x86_64
但是,这些软件包已经根据rpm -qa 安装。我无权尝试重新安装这些或尝试来自此 similar question 的其他建议。
我还找到了this question 并检查了gdb 正在使用的debug-file-directory。
(gdb) show debug-file-directory
The directory where separate debug symbols are searched for is "/usr/lib/debug".
我正在使用包含的 g++ 和 gdb 版本运行 RHEL7。
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
【问题讨论】:
-
"这些包已经根据 rpm -qa 安装了" -- 这些包的确切版本是:
glibc-2.17-260.el7_6.6.x86_64 libstdc++-4.8.5-36.el7_6.2.x86_64安装,还是其他版本? -
确切的。