Recently I've been trying to enable core dumps on Ubuntu. I made a simple program, that would crash (it writes some data out of array).
At first, core dumps weren't generated. This was because ulimit was set to zero, so I run command: ulimit -c unlimited
. This didn't help, because most of the core dumps land to apport
. I also disabled this by an another simple command: echo "core" > /proc/sys/kernel/core_pattern
.
As a result, the core is generated, but it stills cannot be read by gdb
. Here is the output of gdb
:
root@melon:/home/melon/test# gdb ./a.out ./core.3506
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/melon/test/a.out...done.
[New LWP 3506]
warning: Can't read pathname for load map: Input/output error.
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007fa2dc0f976d in ?? ()
(gdb) bt
#0 0x00007fa2dc0f976d in ?? ()
#1 0x0000000000000000 in ?? ()
And here is the output of file
command:
core.3506: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from './a.out'
And the beginning of ulimit -a
:
core file size (blocks, -c) unlimited
And echo of more important /proc/sys/kernel
output:
cat /proc/sys/kernel/core_pattern
core
cat /proc/sys/kernel/core_uses_pid
1
cat /proc/sys/kernel/core_pipe_limit
0
My question is what I am doing wrong? How can I generated a core file, that will be read by gdb
?