调试Q与GDB调试器

Debug Q With GDB Debugger

本文关键字:调试器 GDB 调试      更新时间:2023-10-16

这是一个很普遍的问题。我试着四处寻找帮助,但它是关于gdp调试器。我编译了一个程序,它接受两个字符串作为参数。

我用r和它后面的两个参数运行它,但是当我插入一个像' break 33 '这样的断行,并在第33行断行,然后再次运行它时,我不能进入它,它不会在我的断行处停止。我不能step break继续等等

gcc -g -o debugme debugme.c
Directory: /home/
Tue Oct  6 20:03:14 EDT 2015
[]$ debugme "hi there" "bye bye"
String '0' - 'debugme'
String '1' - 'hi there'
String '2' - 'bye bye'
Total number of command-line arguments: 2
(gdb)
Tue Oct  6 20:06:56 EDT 2015
[]$ cd cosc220
[]$ gdb debugme
GNU gdb (GDB; openSUSE 13.1) 7.6.50.20130731-cvs
Copyright (C) 2013 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-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
..                                                                                                            
Reading symbols from /home/...done.                                                
(gdb) break 33                                                                                                
Breakpoint 1 at 0x4005c7: file debugme.c, line 33.                                                            
(gdb) delete 1
(gdb)
(gdb) break 33
Breakpoint 2 at 0x4005c7: file debugme.c, line 33.
(gdb)

我需要输入什么才能使它工作?它告诉我我的程序没有运行,我试着查看我的调用堆栈,它是空的我输入r以便稍后运行(我只是没有在这里包含它)

您需要在gdb中按r,以便您的程序再次开始运行。

我需要输入什么才能使它工作?

你应该读一篇介绍,比如这篇。

您正在寻找的命令是run,但是一旦您将程序运行到断点,可能会有更多的问题,因此从介绍开始可能仍然是一个好主意。

原来我们学校的服务器上没有安装…Face-palm,现在起作用了