How to debug a core in C/C++?

CC++Server Side ProgrammingProgramming

A process dumps core when it is terminated by the operating system due to a fault in the program. The most typical reason this occurs is that the program accessed an invalid pointer value like NULL or some value out of its memory area. As part of that process, the operating system tries to write our information to a file to allow us to analyze what happened.

This core can be used as follows to diagnose and debug our program −

The core is dumped to the /proc/sys/kernel directory by default. To debug a core, the program must be compiled with the -g option. Once you have the core run gdb −

$ gdb  nameOfExecutable core

This will open the core in gdb and now you can proceed with your debugging. If you don't know how to use gdb, you can use this link to learn more: https://www.ibm.com/developerworks/library/l-gdb/

raja
Published on 28-Feb-2018 15:34:32
Advertisements