【问题标题】:Why GDB doesn't work as desired?为什么 GDB 不能按预期工作?
【发布时间】:2013-12-09 02:27:06
【问题描述】:

我不确定为什么设置断点后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 /

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

【问题讨论】:

  • 命令“r”在哪里?
  • r (run) 运行完整的程序,不是吗?我只想跑到检查站。我想我应该使用继续。因为当我使用 run 时,我遇到了 coredump。

标签: c gdb breakpoints


【解决方案1】:

根据消息:

(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 重试。

【讨论】:

  • 答案+1 @duskwuuf
【解决方案2】:

@duskwuuf 的答案是正确的,但这不是错误The program is not being run 的唯一原因。 我遇到了同样的问题,但由于 gdb 运行错误。

带有命令行参数的程序必须使用--args 选项运行,就像@Mona_Jalal 所做的那样:gdb --args ./server 200000 img

【讨论】:

    猜你喜欢
    • 2021-05-30
    • 2020-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多