至尊逍遥权掌天下顶点:总结段错误
来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 13:33:11
falcon@falcon:~/temp$ gcc -g -o segerr segerr.c –加-g选项查看调试信息
falcon@falcon:~/temp$ gdb ./segerr
GNU gdb 6.4-debian
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i486-linux-gnu”…Using host libthread_db library “/ lib/tls/i686/cmov/libthread_db.so.1″.
(gdb) l –用l(list)显示我们的源代码
显示代码打印
01 #include 02 03 int 04 main() 05 { 06 int i = 0; 07 08 scanf (”%d”, i); /* should have used &i */ 09 printf (”%d\n”, i); 10 return 0;
(gdb) b 8 –用b(break)设置断点
Breakpoint 1 at 0×80483b7: file segerr.c, line 8.
(gdb) p i –用p(print)打印变量i的值[看到没,这里i的值是0哦]
$1 = 0
(gdb) r –用r(run)运行,直到断点处
Starting program: /home/falcon/temp/segerr
Breakpoint 1, main () at segerr.c:8
8 scanf (”%d”, i); /* should have used &i */ –[试图往地址0处写进一个值]
(gdb) n –用n(next)执行下一步
10
Program received signal SIGSEGV, Segmentation fault.
0xb7e9a1ca in _IO_vfscanf () from /lib/tls/i686/cmov/libc.so.6
(gdb) c –在上面我们接收到了SIGSEGV,然后用c(continue)继续执行
Continuing.
Program terminated with signal SIGSEGV, Segmentation 文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/6_system/linux/Linuxjs/200875/130421.html
falcon@falcon:~/temp$ gdb ./segerr
GNU gdb 6.4-debian
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i486-linux-gnu”…Using host libthread_db library “/ lib/tls/i686/cmov/libthread_db.so.1″.
(gdb) l –用l(list)显示我们的源代码
显示代码打印
01 #include
(gdb) b 8 –用b(break)设置断点
Breakpoint 1 at 0×80483b7: file segerr.c, line 8.
(gdb) p i –用p(print)打印变量i的值[看到没,这里i的值是0哦]
$1 = 0
(gdb) r –用r(run)运行,直到断点处
Starting program: /home/falcon/temp/segerr
Breakpoint 1, main () at segerr.c:8
8 scanf (”%d”, i); /* should have used &i */ –[试图往地址0处写进一个值]
(gdb) n –用n(next)执行下一步
10
Program received signal SIGSEGV, Segmentation fault.
0xb7e9a1ca in _IO_vfscanf () from /lib/tls/i686/cmov/libc.so.6
(gdb) c –在上面我们接收到了SIGSEGV,然后用c(continue)继续执行
Continuing.
Program terminated with signal SIGSEGV, Segmentation 文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/6_system/linux/Linuxjs/200875/130421.html
总结段错误
GDB 检查段错误
大总结,喝牛奶错误方式
如下是OSPF错误状态的总结:
企业家们总结的十大错误
家庭喝牛奶错误方式大总结
网友总结“职场攻略”:这些错误年底不能犯
要避免十大错误,众多企业家的总结
家庭喝牛奶错误方式大总结----人民网
企业家们总结的十大错误,要避免-
总结几大容易错误的Seo问题
建筑施工图审查中常犯的错误总结
错误!
女人床事错误10大总结,你真犯不起
总结,
初学民法者容易犯的18个错误——万国民刑先修班授课感受 - 日志 - 段波 - 学法家园 ...
新手养鱼两个月中的错误总结,供其他养鱼新手的参考和交流_金鱼吧_贴吧
10段
段德昌
段德昌
段 录
段*飞
段永平
李乔:错误就是错误