行数分割故障 [英] Line number of segmentation fault

查看:120
本文介绍了行数分割故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我知道我可以:


  1. 逐行调试

  2. 将printfs放在代码中缩小。

编辑:


  1. bt / 其中在gdb上给没有堆栈。

  2. 有用的建议


解决方案

我不知道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:

  1. Debug line by line
  2. Put printfs in the code to narrow down.

Edits:

  1. bt / where on gdb give No stack.
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆