当我尝试单步执行程序时,gdb 会抛出此错误
std::ostream::operator<< (this=0x6013c0 <std::cout@@GLIBCXX_3.4>, __n=2)
at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:110
110 /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/ostream.tcc: No such file or directory.
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试调试的程序。
#include <iostream>
int printPrime(int, int);
int main()
{
int t, c;
std::cin >> t;
c = t;
int m[t], n[t];
while (t--) {
std::cin >> m[t] >> n[t];
}
while (c--) {
printPrime(m[c], n[c]);
std::cout << std::endl;
}
return 0;
}
int printPrime(int m, int n)
{
do {
int c = m;
int lim = c>>2;
if (c <= 1) continue;
while (c-- && c>lim) {
if (m%c == 0) {
if (c == 1) {
std::cout << m << std::endl;
break;
}
break;
}
}
} while(m++ && m<=n);
}
Run Code Online (Sandbox Code Playgroud)
程序代码没有问题,因为它运行正常。我想这是我在 Arch 上安装 GDB 的问题。遇到cin
或时显示错误cout
。
当我尝试在我的 Ubuntu VM 中运行它时未显示此错误
我已经针对这个问题填写了一个错误报告:https : //bugs.archlinux.org/task/47220
发生这种情况是因为找不到 ostream 源文件。
您可以剥离libstdc++ 库:
sudo strip /usr/lib/libstdc++.so.6
Run Code Online (Sandbox Code Playgroud)
然后 gdb 将不会尝试打开源文件,错误将不再出现。
您可以通过重新安装它来切换回未剥离的版本:
sudo pacman -S gcc-libs
Run Code Online (Sandbox Code Playgroud)
您可以在 gdb 中添加替换规则:
gdb tst
(gdb) set substitute-path /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include /usr/include/c++/5.2.0
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2111 次 |
最近记录: |