-
Notifications
You must be signed in to change notification settings - Fork 141
GDB
This page is maintained by Ivan ...
Full gdb manual.
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:
- By using debugging programs which includes user interface for step-by-step program running e.g. GNU Debugger.
- 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.
If you are using Linux, you probably already have GDB. You only have to follow the guide below. But if you are using Windows, you will need to use this guide on YouTube to install and this one to build program to be used by GDB there.
1. Open console. (Ctrl + Alt + T for Linux)
2. Open directory with your program file. (Use command "ls -al" to view your directory list. Use "cd 'path'")
3. Compile your program with "-g" key in order to include information about debugging into your running file. Write in console "gcc -g 'NameOfFile.c' -o 'NameOfRunFile'".
// GNU Debugger is usually used to debug C or C++ files.
4. And then you can upload your program into GDB. Write in console "gdb 'NameOfRunFile'" for Linux. If it works you will instantly appear in (gdb) console.
Breakpoint is a point in your program where GNU Debugger stops the program and then you can receive all current variables at this stage.
Type in (gdb) console:
break 'NumberOfLine' to set up the breakpoint at any line in your code;
break 'NameOfFunction' to set up the breakpoint at any function in your code you want.
and
clear 'NumberOfLine' to delete the breakpoint at any line in your code;
clear 'NameOfFunction' to delete the breakpoint at any function in your code you want.
It means that command "break" sets up the breakpoint for permanent using.
MIPT-V / MIPT-MIPS — Cycle-accurate pre-silicon simulation.