利用gdb定位段错误(Segmentation fault)
标签:gdb调试 段错误 定位
by 小威威
用linux编程时,我们不时会遇到Segmentation fault,其实这就是段错误。引发段错误通常是数组越界,出现野指针,在一些作业网上可能也会显示runtime error,遇到这种情况我们该怎么办?难道一行一行看代码?
显然要调试程序。这里我用的是gdb。
apple@ubuntu:~/Desktop$ gdb
GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
Copyright (C) 2015 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