行数分割故障 [英] Line number of segmentation fault
本文介绍了行数分割故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以:
- 逐行调试
- 将printfs放在代码中缩小。
编辑:
-
bt
/其中
在gdb上给没有堆栈。 - 有用的建议
解决方案
我不知道gcc选项,但您应该能够使用gdb运行应用程序,然后在崩溃时键入其中
,以便在退出时查看该堆栈,这应该让您关闭。
$ gdb blah
(gdb)运行
(gdb)其中
编辑完整性:
您还应确保构建应用程序使用调试标志使用 -g
gcc选项在行号中包含行号
另一个选项是使用 bt
(backtrace)命令。
Is there any gcc option I can set that will give me the line number of the segmentation fault?
I know I can:
- Debug line by line
- Put printfs in the code to narrow down.
Edits:
bt
/where
on gdb give No stack.- Helpful suggestion
解决方案
I don't know of a gcc option, but you should be able to run the application with gdb and then when it crashes, type where
to take a look at the stack when it exited, which should get you close.
$ gdb blah
(gdb) run
(gdb) where
Edit for completeness:
You should also make sure to build the application with debug flags on using the -g
gcc option to include line numbers in the executable.
Another option is to use the bt
(backtrace) command.
这篇关于行数分割故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文