Thread: A simple question about Core Dump

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    A simple question about Core Dump

    Suppose you run a program called prog, it crashed and you got core.1234 file.

    My questions are:
    1) To me a core dump is nothing more than a series of records: where you made the function calls, what is the memory address, etc. So core.1234 is supposed to be a document rather than a binary file. It should be viewed by "less" or similar editor. But what I can see are garbage characters. Then what exactly is core dump?!

    2) I know 2 ways to use gdb:
    gdb prog
    (gdb) run
    ...
    (gdb) bt

    OR

    gdb prog core.1234
    (gdb) bt

    What are the differences ?

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by meili100 View Post
    1) To me a core dump is nothing more than a series of records:
    Then you are wrong.

    where you made the function calls, what is the memory address, etc.
    Nothing of the sort.

    Then what exactly is core dump?!
    A precise image of the memory of the process along with some data concerning its registers and other system resources.

    2) I know 2 ways to use gdb:
    gdb prog
    (gdb) run
    ...
    (gdb) bt

    OR

    gdb prog core.1234
    (gdb) bt

    What are the differences ?
    The second occurs after the fact.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you run in GDB until the application crashes, or load the core after the crash will make no difference, at least to the output of bt. The bt command lists the stack, which is just tracing what's in memory starting from where the stackpointer is.

    As brewbuck states, a core-dump is a binary file containing exactly what was in the memory when the application stopped - along with all the register contents. It has enough information that you can go back and look at variables in a function 5 or 20 steps back on the stack - as long as this works on the "live" application that is - sometimes the debug information and register contents don't quite work well on backtraces - but that's the same whether you have a core file or just running the executable.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > What are the differences ?
    The first is a corpse which has just flat-lined on the operating table.
    The second is a stone-cold stiff in the morgue.

    Or put it another way, you might ask your customer to email you a core file to look at.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. having a core dump
    By justins in forum C Programming
    Replies: 6
    Last Post: 05-21-2008, 12:00 PM
  2. STL vector core dump
    By creativeinspira in forum C++ Programming
    Replies: 9
    Last Post: 07-22-2007, 04:49 PM
  3. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  4. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  5. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM