简体   繁体   English

为什么GDB无法按需工作?

[英]Why GDB doesn't work as desired?

I am not sure why GDB doesn't work as desired after setting a breakpoint: 我不确定为什么设置断点后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.

Here's what in .gdbinit 这是.gdbinit

set auto-load safe-path /

Any idea what I am not doing or what am I doing wrong? 知道我没有在做什么或我在做什么错吗? I used to do the same steps previously! 我以前曾经做过同样的步骤!

Based on the messages: 根据消息:

(no debugging symbols found)

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

it looks as though your binary has been compiled without debugging symbols, so breaking at server.c:256 isn't going to work (since there's nothing to indicate to gdb where line 256 is!). 看来您的二进制文件已经编译好了,没有调试符号,因此在server.c:256处中断将不起作用(因为没有任何东西可以指示gdb 256行在哪里!)。 Recompile with -ggdb and try again with run . 使用-ggdb重新编译,然后使用run再次尝试。

@duskwuuf answer is right, however it is not the only reason of the error The program is not being run . @duskwuuf的回答是正确的,但这不是错误的唯一原因The program is not being run I had the same problem, but because of bad gdb running. 我有同样的问题,但是由于gdb运行不良。

The program with commandline arguments must be run with --args option, like as @Mona_Jalal does: gdb --args ./server 200000 img 带有命令行参数的程序必须使用--args选项运行,就像@Mona_Jalal一样: gdb --args ./server 200000 img

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM