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

Gdb+Coredump learning

时间:2016-09-06 19:45:34      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

Sometimes running program in Unix will fail without any debugging info or warnings because of the laziness of programmer.. So if need to find the right place will the program stops and start debugging right from there, set the coredump file size to some desired size by first checking ..:

udump -a | grep core

[root@os-t1 ~]# ulimit -a | grep core

core file size          (blocks, -c) 0

[root@os-t1 ~]#

 

Use the following command to set the limit of coredump file size:

ulimit -c unlimited

[root@os-t1 ~]# ulimit -c unlimited

[root@os-t1 ~]# ulimit -a | grep core

core file size          (blocks, -c) unlimited

[root@os-t1 ~]#

 

       Make sure the program is generated by gcc/g++ using flags of -O0 and -g. After running the program that will fail will generate the Core.[0-9]+ file after exit, this file contains the stack/mem/register infos.

       use gdb to restore the environment when the bug appears and program exits:

gdb program core.[0-9]+

gdb will point to the line will the program exits, use bt to view the stack infos, use up to get to the upper entry of the stack. Easy to find the problem in the program we write.

Gdb+Coredump learning

标签:

原文地址:http://www.cnblogs.com/sansna/p/5846863.html

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