July 10, 2006

Capture Core Dump from a Unix/Linux Segfault

Filed under: Ideas, Job, Life, Musings — Benjamin Chodroff @ 9:46 am

This took me too long to findt/remember for such a simple task, so I’ll blog it. If you want to create a core dump file in Unix/Linux when your C/C++ program crashes, you need to set your environment to create it:

ulimit -c [max filesize in KB]

I usually set it to:

ulimit -c 10000

If you set the max too small, your file will be truncated and will be unreadable by gdb.

2 Comments »

  1. Hi,
    When i run the command below,
    ~/linuxC$gdb ch15-abort core.4142
    it tells:
    core.4142 is not a core dump: File format not recognized.
    (gdb)

    How can i create a core dump file with
    the correct format?
    Thanks!

    Jay

    Comment by jay — July 30, 2006 @ 2:27 am

  2. Jay -
    Usually that error is the result of a truncated core dump. Did you try setting the max filesize higher?

    Comment by Benjamin Chodroff — July 30, 2006 @ 3:01 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Copyright 2008, Benjamin Chodroff.
Site design by Flique Creative, Cleveland, OH