码迷,mamicode.com
首页 > 数据库 > 详细

GDB调试

时间:2017-03-15 14:27:58      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:other   word   查看   with   where   source   strong   x86   instr   

一 GDB调试Core_dump

 1 设置core文件大小为无限制:

  ulimit -c unlimited

 2 运行程序 ./a.out,产生段错误,生成core文件。

   3 使用gdb查看core文件 :

  gdb ./a.out ./core

  输出如下:

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 it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
[New LWP 3115]
Core was generated by `./a.out.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000040051b in do_it () at ./test.c:11
11        *p = a;

  如果只想显示错误所在行,使用where:

(gdb) where
#0  0x000000000040051b in do_it () at ./test.c:11
#1  0x0000000000400504 in main () at ./test.c:4

二 GDB插入断点

  

GDB调试

标签:other   word   查看   with   where   source   strong   x86   instr   

原文地址:http://www.cnblogs.com/luntai/p/6553705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!