GDB 无法读取文件
我正在使用 GDB 调试一组 C 源文件。我已经使用 -g 标志编译了所有文件。我什至可以在有效位置设置断点。
$ cd /home/user/project/test
$ gdb ../src/exec
Reading symbols from /home/user/project/src/exec...done.
(gdb) b driver.c:196
Breakpoint 1 at 0x80698ac: file driver.c, line 196.
(gdb) r input.txt
Starting program: /home/user/project/src/exec input.txt
Breakpoint 1, handle_new_request (curriodriver=0x810b228, curr=0x8143ec0)
at driver.c:196
196 driver.c: No such file or directory.
in driver.c
为什么 GDB 无法读取 driver.c 中的行?
I'm debugging a set of C source files using GDB. I've compile all the files with the -g flag. I'm even able to set the breakpoint at a valid location.
$ cd /home/user/project/test
$ gdb ../src/exec
Reading symbols from /home/user/project/src/exec...done.
(gdb) b driver.c:196
Breakpoint 1 at 0x80698ac: file driver.c, line 196.
(gdb) r input.txt
Starting program: /home/user/project/src/exec input.txt
Breakpoint 1, handle_new_request (curriodriver=0x810b228, curr=0x8143ec0)
at driver.c:196
196 driver.c: No such file or directory.
in driver.c
Why is GDB unable to read the line from driver.c?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为
gdb
不知道去哪里寻找该文件。您可以设置断点,因为断点信息是攻击可执行文件的调试信息的一部分。但要真正显示源代码,需要找到实际的源代码。使用不同的工作目录运行 gdb 可能会解决该问题。It's because
gdb
doesn't know where to look for the file. You can set a breakpoint because the breakpoint information is part of the debug info attacked to the executable. But to actually display the source code, it needs to find the actual source code. Likely runninggdb
with a different working directory will solve the problem.