Skip to content
Pavel I. Kryukov edited this page Oct 8, 2018 · 21 revisions

This page is maintained by Ivan ...


Definitions.

Debugging is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system.

Two tactics of debugging exists:

  1. By using debugging programs which includes user interface for step-by-step program running e.g. GNU Debugger.
  2. Output of the current state of the program using output statements located at critical points of the program on the monitor.

The GNU Project Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Go, Java and partially others.

How to build a program to be used by GDB?

If you are using Linux, you probably already have gdb. You only have to follow the guide below.

1. Open console. (Ctrl + Alt + T)

2. Open directory with your program file. (Use command "ls -al" to view your directory list. Use "cd 'path'" to change directory)

3. Now you must compile your file with GDB. Write in console "gcc -g 'NameOfFile.c' -o 'NameOfRunFile'". Key "-g" is connected with GNU Debugger.

// GNU Debugger is usually used to debug C or C++ files.

4. Well, now you must run your file with GDB. Write in console "gdb 'NameOfRunFile'". If it works you will instantly appear in (gdb) console.

But if you are using Windows, you will need to install it. Use the guide below.

1. MinGW distributes a Windows version of gdb. You can get the latest mingw installer here which can immediately install gdb.

2. After installing MinGW, run the "MinGW Installation Manager" (which for me was located in C:\MinGW\libexec\mingw-get\guimain.exe ) and then make sure that the mingw32-gdb bin package is installed.

// These instructions are for mingw32, not the mingw-w64 fork. But gdb from mingw-w64 should work too.

If you already installed it you have to do similar actions.

1. Open console.

2. Open directory with your program file.

3. The third step is to compile your program with "-g" key in order to include information about debugging into your running file. Type "g++ -g -o 'NameOfRunFile.exe' 'NameOfFile.c'"

4. And then you can upload your program into gdb.

Clone this wiki locally