首页 > 解决方案 > gdb 有问题

问题描述

它说它找不到某个文件或目录 (fxstat.c)。我已经尝试按照互联网上的一些帖子的建议安装 glibc,但它没有用。

这是版本:

GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".

和错误信息:

Reading symbols from a.out...done.
(gdb) start
Temporary breakpoint 1 at 0xda0: file ProbZC.cpp, line 10.
Starting program: /home/danielnyong66/Codeforces-And-LeetCode-Solutions/a.out 

Temporary breakpoint 1, main () at ProbZC.cpp:10
10          cin >> tests;
(gdb) n
__GI___fxstat (vers=<optimized out>, fd=<optimized out>, buf=0x7fffffef38) at ../sysdeps/unix/sysv/linux/wordsize-64/fxstat.c:35
35      ../sysdeps/unix/sysv/linux/wordsize-64/fxstat.c: No such file or directory.
(gdb) n
1
2
__GI___fxstat (vers=<optimized out>, fd=<optimized out>, buf=0x7fffffee68) at ../sysdeps/unix/sysv/linux/wordsize-64/fxstat.c:35
35      in ../sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
(gdb) n
15
__lseek64 (fd=<optimized out>, offset=-1, whence=1) at ../sysdeps/unix/sysv/linux/lseek64.c:36
36      ../sysdeps/unix/sysv/linux/lseek64.c: No such file or directory.
(gdb) n
[Inferior 1 (process 1212) exited normally]

我有一个运行wsl(debian)的相同版本gdb的桌面,我在那里编译了程序,从来没有遇到过这个问题,甚至之前也没有看到过这个错误。我正在使用支持 linux 的 arm64、chromeos pc。这可能是系统问题,但是我该如何解决呢?

编辑:根据 tink 的建议,我添加了丢失源的路径,但它只是内部文件,我仍然得到相同的结果,我的程序只是突然停止。

编辑二:正如 GM 建议的那样,这里是一个示例源,不管它是什么文件。

1   #include<iostream>
  1 
  2 int main() {
  3         std::cout << "hello world" << std::endl;
  4 }

现在有不同的消息:

(gdb) list
1       #include<iostream>
2
3       int main() {
4               std::cout << "hello world" << std::endl;
5       }
(gdb) b main
Breakpoint 1 at 0x9ec: file hello_word.cpp, line 4.
(gdb) r
Starting program: /home/danielnyong66/Codeforces-And-LeetCode-Solutions/hello 

Breakpoint 1, main () at hello_word.cpp:4
4               std::cout << "hello world" << std::endl;
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/aarch64/strlen.S:94
94      ../sysdeps/aarch64/strlen.S: No such file or directory.

它会查找不在我的程序中的文件,并在找不到它们时显示错误。这是我正在调试的原始文件:https ://repl.it/join/iyqwodtx-danyxng

编辑:回溯...

(gdb) b main
Breakpoint 1 at 0x9ec: file hello_word.cpp, line 4.
(gdb) r
Starting program: /home/danielnyong66/Codeforces-And-LeetCode-Solutions/hello 

Breakpoint 1, main () at hello_word.cpp:4
4               std::cout << "hello world" << std::endl;
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/aarch64/strlen.S:94
94      ../sysdeps/aarch64/strlen.S: No such file or directory.
(gdb) bt
#0  strlen () at ../sysdeps/aarch64/strlen.S:94
#1  0x0000007ff7f4ee58 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) () from /usr/lib/aarch64-linux-gnu/libstdc++.so.6
#2  0x0000005555555a00 in main () at hello_word.cpp:4

标签: c++clinuxunixgdb

解决方案


推荐阅读