Core Dump

Enable core dump

  1. Ensure that they are enabled. Run the following command. If the reply is not unlimited, the core dumps are disabled or limited.
     $ ulimit -c
    
  2. Run ulimit -c unlimited to enable creation of core dumps from the current shell session.
     $ ulimit -c unlimited
    

File location

  1. Location of core dump config file
     $ cat /proc/sys/kernel/core_pattern
     |/usr/share/apport/apport %p %s %c %d %P %E
    
  2. Rewrite contents of core_pattern file so that the core is dumped to the current working directory.
     $ sudo bash -c 'echo core.%e.%p.%t > /proc/sys/kernel/core_pattern'
    

Usage

  1. Simple usage of GDB, to debug coredump files
     $ gdb <executable_path> <coredump_file_path>
    
  2. After getting inside the GDB prompt (on execution of the above command), type
     $ (gdb) where
     $ (gdb) bt
     $ (gdb) thread apply all bt
    

    This will get the information, of the stack, where we can analayze the cause of the crash/fault.

Leave a comment