General GDB notes and commands reference
Last Updated: December 31, 2018 by Pepe Sandoval
If you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me create more stuff and fix the existent content...
-DDEBUG and -ggdb options when compiling your codegdb <app_name_here>(gdb) break <file_name_here>:<line_number_here>b <function_name>(gdb) runr <app command-line arguments>gdb --command <gdb_commands_file_here.in># You can add commends to the filelike this
file ./<bin_executable_app_here>
break main
directory ./.
set print pretty on
set print union on
set print array on
set print array-indexes on
set args -t 60
All these commands ca be executed once gdb is already running
run or r: Run the currently opened executablestep or s: Execute next code line entering function callsnext or n: Execute next code line skipping function callsfinish: Continue running until the function that is currently being executed returnsuntil <line_number>: Run until a line number in the current contextuntil <file_name>:<line_number>: Run until a line number in the given filecontinue: Continue program executionquit or q: quits/exits GDBbreak <file_name>:<line_number>: Set breakpoint in a certain line number of a certain filebreak MyClass.cpp:50info breakpoints : Shows status and info of current breaks/breakpoints.enable/disable <break_number>: Enables or disables a breakpointdelete <break_number>: Removes a breakpointprint <variable_name> or p: Prints variable contents, the variable can be of any typeprint MyVariablep/x MyVariable : print in hexset var <variable_name>=<value>: Set variable to the given value.set var MyVariable=0x10backtrace or bt: Prints function backtrace/callstackdisplay <variable_name/expression>: Adds variable/expression to the items that are displayed every time execution stopsdisplay iinfo display: Shows list and status of display itemsinfo locals: Shows list of local variablesdelete display <display_num>: Removes variable/expression from the items that are displayed every time execution stopsIf you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me create more stuff and fix the existent content...