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

时间:2022-05-19 16:39:23

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!

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

2 个解决方案

#1


5  

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!). Recompile with -ggdb and try again with run.

它看起来好像你的二进制文件已经编译而没有调试符号,所以打破server.c:256是行不通的(因为没有什么可以向gdb指示第256行的位置!)。使用-ggdb重新编译,然后使用run重试。

#2


0  

@duskwuuf answer is right, however it is not the only reason of the error The program is not being run. I had the same problem, but because of bad gdb running.

@duskwuuf回答是对的,但这不是错误的唯一原因程序没有运行。我有同样的问题,但由于糟糕的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

#1


5  

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!). Recompile with -ggdb and try again with run.

它看起来好像你的二进制文件已经编译而没有调试符号,所以打破server.c:256是行不通的(因为没有什么可以向gdb指示第256行的位置!)。使用-ggdb重新编译,然后使用run重试。

#2


0  

@duskwuuf answer is right, however it is not the only reason of the error The program is not being run. I had the same problem, but because of bad gdb running.

@duskwuuf回答是对的,但这不是错误的唯一原因程序没有运行。我有同样的问题,但由于糟糕的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