How to look at corefiles using gdb – Part 1

The Linux Operating System dumps the exception generated in a program as a core-file.

Before we run the sample program to analyze the dump generated by the linux system – we need to check whether the Linux system settings for core files is set properly. On Ubuntu – Core file size is set to Zero. Hence, a program that generates a core file may not be saved.

The core-file size can be known by running  – “ulimit” command

As can be seen above – the core file size is set to 0. To change this setting run the command –

ulimit -c  unlimited  –  this sets unlimited space (total memory) for saving core files

The Below command will provide inputs on where the core file is generated on an Ubuntu system

As seen above, on an Ubuntu system – A generated core file is redirected to Ubuntu’s crash management  system – Apport.

The Apport crash management system runs a script to identify which crash-dumps it needs to log into the crash location identified by the script. generally it is “/var/crash/” folder. However, Apport only logs the crash report for the  applications installed from the  ubuntu repositories. The crash report for the other programs are logged into current working directory. The interested reader can view the apport script 

/usr/share/apport/apport 

The Core file can also be re-directed to a location that is preferable for the developer by making changes to the core_pattern file. In the below example, the core file would be saved in  /tmp/ folder in the format – core_<program_name>.pid

The core file after running the above command will be saved in /tmp folder. To understand more about the core file generated by Linux – refer the man page – man core

How to look at corefiles using gdb – Part 2

Comments

  1. Pingback: How to look at corefiles using gdb – Part 2 | Hitch Hiker's Guide to Learning

  2. Pingback: How to debug a Program with gdb – Part 2 | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *