Home >Backend Development >C++ >How to debug core in C/C++?
#When a process is terminated by the operating system due to a program error, the process dumps core. The most typical reason this happens is that the program accesses an invalid pointer value, such as NULL or some value outside its memory area. As part of this process, the operating system attempts to write our information to a file so we can analyze what happened.
This core can be used as follows to diagnose and debug our programs -
By default, the core is dumped to the /proc/sys/kernel directory. To debug the kernel, 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 you can now continue 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/
The above is the detailed content of How to debug core in C/C++?. For more information, please follow other related articles on the PHP Chinese website!