This question was asked to me in an interview.
they asked me how to generate a core dump file with which i can debug. then i said that with -g flag in
-g
-g adds debugging information (variable names, line numbers etc) to the executable file. It's part of what you need to do to be able to make sense of the core file.
http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options