c - 为什么 GDB 不能按预期工作?

标签 c gdb breakpoints

我不确定为什么 GDB 在设置断点后无法正常工作:

[jalal@mumble-36] (2)$ gdb --args ./server 200000 img
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /afs/cs.wisc.edu/u/j/a/jalal/fall2013/p5-linux/server...(no debugging symbols found)...done.
(gdb) b server.c:256 
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (server.c:256) pending.
(gdb) c
The program is not being run.

这是 .gdbinit 中的内容

set auto-load safe-path /

知道我没有做什么或做错了什么吗?我以前做过同样的步骤!

最佳答案

基于消息:

(no debugging symbols found)

No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n])

看起来你的二进制文件是在没有调试符号的情况下编译的,所以在 server.c:256 处中断是行不通的(因为没有任何东西可以向 gdb 指示第 256 行在哪里! ).使用 -ggdb 重新编译,然后使用 run 重试。

关于c - 为什么 GDB 不能按预期工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20462084/

相关文章:

c - Qt Creator + GDB + MingW - 按位和问题

c - C 中的作用域守卫

c - 为什么 gdb 不会在 strcpy 上中断?

objective-c - Xcode 在调试时评估表达式

visual-c++ - 混合模式程序集未加载 native C++ pdb 的符号

Eclipse CDT 无法设置观察点(始终禁用 - 变灰)

debugging - 无法在 Chrome 开发工具中设置断点,版本 26.0.1410.64 m

c - 我如何在 C 中生成随机 double ?

c - 算法效率的好引用

c - If 语句和表达式质疑建议