I have done the following changes:
Edited the file /etc/security/limits.conf
, so that the core file size is 'unlimited'. Verified it using the command #ulimit -c
which shows as 'unlimited'.
Appended the file /etc/sysctl.conf
as per the following:
kernel.core_uses_pid = 1
kernel.core_pattern = /tmp/%e.core.%p
fs.suid_dumpable = 2
Saved the changes using sysctl -p
compiled the file as follows:
$gcc -g pointer.c -o pointeraccess
result-successfully compiled
Executed the file in GDB as follows:
$gdb pointeraccess
After getting an arithmetic exception, it outputs as follows:
(gdb) run
Starting program: /media/anand/d258641a-8cc6-4fcf-96e4-
ce7a147cb34e/Important/Debugging Workspace/pointeraccess
Program received signal SIGFPE, Arithmetic exception.
0x08048477 in main () at pointeraccess.c:13
13 i=i/0;
(gdb) gcore
Saved corefile core.1880
My question is: Why the filename is core.pid
instead of program_name.core.pid
?
Update the core-pattern:
echo "core.%e.%p" > /proc/sys/kernel/core_pattern
%e indicates the name of the binary
With the above pattern, I was able to have core dumped which contains executable name and pid.
Edit:
Running it outside of GDB results in filename in core file. Running it with GDB, I suppose gcore takes control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.