Program debugging is a very important skill in software development.
In this tutorial, you will learn about GNU debugger (GDB) and how to installed gdb on your host machine.
You will learn basic commands of the GDB which help to debug your program. I explained the debugging process with a simple example code in this blog and also provide a tutorial on how to debug the segmentation fault using GDB.
Valgrind is a debugging tool used for memory debugging, memory leak detection, and profiling tools. It is a wrapper of various debugging tools and memcheck is the most popular tool of the Valgrind.
We compiled and run the C program but sometimes we get the segmentation fault and the core file generated this moment. Segmentation fault happens because of some memory violation in the code. later you can use the core file and debug the code using the GDB.
Segmentation fault is a type of error that occurs when a program trying to access an invalid memory or protected memory. Kernel gets notifying this access violation and then kernel sends the default signal handler SIGSEG to terminate the program.
GDB is a debugging to debug the C, C++ program. so in this tutorial, we will use GDB to debug the segmentation fault with some GDB commands.
GDB is a popular debugging tool and it helps the developer to find the bug in their code. this tutorial will help you to learn GDB (GNU debugger) and you will know to use GDB in your program with a simple example.