Membuat dan analisis core dump

Suatu program gagal dijalankan. Eksekusi via terminal menunjukkan segmentation fault tanpa keterangan lainnya. Pada situasi inilah core dump diperlukan untuk debugging sehingga diketahui penyebabnya.

Contoh, geeqie apabila dijalankan di lingkungan wayland berbuah segmentation fault

$ geeqie
Segmentation fault

Saatnya membuat core dump

$ gcore /usr/bin/geeqie
Illegal process-id: /usr/bin/geeqie.
You can't do that without a process to debug.
The program is not being run.
gcore: failed to create core./usr/bin/geeqie

Kemudian eksekusi lagi

$ geeqie
Segmentation fault (core dumped)

Core dumped. Filenya core ada di current working directory. Apabila masih belum terbentuk, atur ulimit menjadi unlimited.

$ ulimit -c unlimited

Selanjutnya core tersebut dapat dianalisis menggunakan gdb.

$ gdb /usr/bin/geeqie core
GNU gdb (GDB) 11.1
Copyright (C) 2021 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-slackware-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/geeqie...
(No debugging symbols found in /usr/bin/geeqie)

warning: Can't open file /memfd:gdk-wayland (deleted) during file-backed mapping note processing

warning: Can't open file /memfd:wayland-cursor (deleted) during file-backed mapping note processing
[New LWP 6549]
[New LWP 6550]
[New LWP 6551]
[New LWP 6553]
[New LWP 6567]
[New LWP 6552]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
--Type <RET> for more, q to quit, c to continue without paging--
Core was generated by `geeqie'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f502b4142df in ?? () from /usr/lib64/libgdk-3.so.0
[Current thread is 1 (Thread 0x7f50221cbfc0 (LWP 6549))]
(gdb)

 Share!

 
comments powered by Disqus