Home > Backend Development > C++ > body text

How to debug core in C/C++?

王林
Release: 2023-09-14 21:33:02
forward
985 people have browsed it

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
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!