[英]Stop GDB from stepping through glibc functions
Sorry for the nondescript title, couldn't think of anything better. 抱歉,标题不完整,没想到有什么更好的了。
When I run my program through GDB to find a Segmentation Fault, I get thousands of lines of this garbage: 当我通过GDB运行程序以查找Segmentation Fault时,我得到了成千上万行这样的垃圾:
(gdb) step
_IO_new_file_xsputn (f=0x76fa0b40 <_IO_2_1_stdout_>, data=0x7efff284, n=7) at fileops.c
1279 fileops.c: No such file or directory.
(gdb) step
1273 in fileops.c
(gdb) step
1279 in fileops.c
(gdb) step
1286 in fileops.c
(gdb) step
1288 in fileops.c
(gdb) step
1289 in fileops.c
(gdb) step
1292 in fileops.c
(gdb) step
1294 in fileops.c
(gdb) step
1292 in fileops.c
...and on and on and on. ...并且不断地。 It makes debugging very difficult and tedious because:
这使调试非常困难且乏味,因为:
step
(or press Enter ) repeatedly. step
(或按Enter )。 How can I tell gdb to quit printing the lines like this? 我怎样才能告诉gdb退出打印这样的行?
1273 in fileops.c
Is there some config file or command-line option I can use? 我可以使用一些配置文件或命令行选项吗?
How can I tell gdb to quit printing the lines like this?
我怎样才能告诉gdb退出打印这样的行?
By using the step
command, you asked GDB to print exactly this info. 通过使用
step
命令,您要求 GDB准确打印此信息。
If you don't want that info, you should stop asking for it. 如果你不希望这样的信息,你应该停止自讨苦吃 。
I often miss the Seg Fault I'm looking for.
我经常想念我正在寻找的Seg Fault。
If you simply run
, GDB will automatically stop when you get a SIGSEGV
, you can't miss that. 如果只
run
,当您获得SIGSEGV
时,GDB会自动停止,您不能错过它。
What you probably want is to stop in your code some time before the SIGSEGV
, and step from there. 您可能想要的是在
SIGSEGV
之前的某个时间停止代码,然后从那里开始。 There are several techniques to achieve this, reverse debugging is one of them. 有几种技术可以实现此目的, 反向调试就是其中之一。 Using replay debugging is another.
使用重播调试是另一种方法。
It's hard to offer more advice, because you didn't show what you are actually trying to do. 很难提供更多建议,因为您没有显示自己实际上在尝试做什么。
Are you sure you need to step through glibc code in fileops.c
? 您确定需要逐步检查
fileops.c
glibc代码吗?
If you want only to debug your own code you should finish
current frame to go out of _IO_new_file_xsputn
function after you have stepped into it and continue debugging your code. 如果只想调试自己的代码,则应在进入并继续调试代码后
finish
当前帧以退出_IO_new_file_xsputn
函数。
That's how step
works - it step s through the code. 这是如何
step
的工作-它步骤通过代码。
What about a breakpoint? 断点呢? If you set one the debugger will stop there and let you step through the code manually.
如果您设置一个,调试器将在那里停止,并让您手动单步执行代码。
For something like a segmentation fault or similar signals, which abort execution, you can run
and backtrace
when the program has stopped to gain information about the location execution has stopped at. 对于诸如分段错误或类似信号之类的东西,它们会中止执行,您可以在程序停止时
run
并backtrace
以获取有关位置执行已停止的信息。 Then set a breakpoint there and the program will stop at the offending instruction. 然后在此处设置一个断点,程序将在有问题的指令处停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.