[gdb][Core Dump] Keep the error state when exe file be executed
1. Check Core Dump Status
ulimit -c
if show 0 mean no open this function
Open it by using
ulimit -c unlimited
2. Create a C file (name test.c)
#include <stdio.h>
int main(void)
{
int *b=NULL;
*b = 0x22;
return 0;
}
3. gcc -g test.c
4. Execute ./a.out
Then produce a file was called core
5. Use gdb to see what happen when execute the ./a.out
gdb -c core ./a.out
Will show what happen
root@happy-laptop:/home/happy/test/test3# gdb -c core ./a.out
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/happy/test/test3/a.out...done.
[New Thread 3443]
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x080483c4 in main () at test.c:6
6 *b = 0x22;
0 意見:
張貼留言