GDB: GDB stands for GNU Project Debugger, which allows you to see what’s going ‘inside’ of another program. It is a powerful debugging tool for C that helps you to poke around inside your C programs. The main theory of GDB is to replace a program instruction with a trap.
You can run the program up to a certain point, then stop and print out the values of certain variables at that point. It supports languages including Ada, C, C++, Objective-C, Free Pascal, FORTRAN, etc.
In this article, you will learn Cheat Sheat for GDB. Use these commands to execute the program quickly.
Last Updated on Feb 23, 2022.
Program Control Commands:
In the below table, you will learn program control commands and their functions of GDB. Please follow the commands wisely.
Command | Function |
---|---|
start | This command is used to break the main and run the program. |
n | It is used to go to the next statement. |
s | If you want to step into the function, you can use this command. |
fin | Make use of this command to finish the function. |
Stack Commands:
In the below table, you will learn stack commands and their functions of GDB. Use these commands carefully.
Command | Function |
---|---|
bt | In order to backtrace the function, you can use this command. |
frame<N> | By using this command, you can switch to the frame. |
Breakpoints Commands:
The table will explain breakpoints commands and their functions of GDB.
Command | Function |
---|---|
b <fn |line> | If you want to set the breakpoint, you can use this command. |
info break | Use this command to list out the breakpoints. |
d <N> | This command is used to delete the breakpoint N. |
Threads Commands:
The table will explain threads commands and their functions of GDB.
Command | Function |
---|---|
info threads | It is used to show all the threads with their names. |
thread <N> | By using this command, you can switch to the thread. |
Inspecting Data Commands:
The table will explain inspecting data commands and their functions of GDB.
Command | Function |
---|---|
x ptr | This command is used to examine the memory at ptr. |
x/2g ptr | Use this command to examine the 2 qwords at ptr. |
x/20xb ptr | In order to examine the 20 bytes in hex at ptr, you can use this command. |
Text User Interface Commands:
You can learn text user interface commands and their functions of GDB. Please use these commands carefully.
Command | Function |
---|---|
C-x a | Make use of this command to enter or leave the TUI. |
C-x s | If you want to toggle the single-key mode, you can use this command. |
C-i | Use this command to refresh the screen. |
C-p, C-n | These commands are used to make the arrow key replacements. |
Verdict:
You can use these commands for both Windows 10 and Windows 11. Kindly make sure to use the shortcuts properly.
From this article, you will learn Cheat Sheat for GDB. Please feel free to state your query or feedback for the above article. Thank You!!