gdb的helloworld

来源:岁月联盟 编辑:exp 时间:2011-09-17

想起东软的1个linux老师,就讲了两天基本就把这书讲完了,
刚买了本书,一定要一星期内看完
《debug hacks》
奶奶的幸好哥我练过,要不被你成那啥呀~
先 ulimit -c 内核转储文件的大小限制
ulimit -c 1073741842
或开机启动
vim /etc/profile
Java代码 
ulimit -S -c unlimited > /dev/null 2>&1 

再故意写个错代码
这个意思似乎是0是系统的,不能访问
test.c
Java代码 
#include <stdio.h> 
int main(){ 
    int *a=NULL; 
    *a=0*1; 
    return 0; 

gcc -p -g test.c
./a.out
生成core*
gdb -c core.1234 ./a.out
l 6
Quit

------------------
在固定位置/var/core/生成内核转储
cat /etc/sysctl.conf
Java代码 
kernel.core_pattern=/var/core/%t-%e-%p-%c.core 
kernel.core_uses_pid=0 

sysctl -p
cat /proc/sys/kernel/core_pattern

作者“走在左边”