Skip to content

Instantly share code, notes, and snippets.

@ananyo2012
Last active July 4, 2019 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ananyo2012/c88221755570e1ffb50820be5f22eeb3 to your computer and use it in GitHub Desktop.
Save ananyo2012/c88221755570e1ffb50820be5f22eeb3 to your computer and use it in GitHub Desktop.
gdb introduction

gcc -g -o hello hello.c - -g flag adds debugging information to the executable

gdb ./a.out - Attach debugger to the program

(gdb) help
(gdb) help <section>
(gdb) run or r // Run Program
(gdb) run arg1 arg2 .. // Command line arguments of the program
(gdb) list or l// list specified function or filw
(gdb) list main // list function main
(gdb) help breakpoint
(gdb) break or b // Sets breakpoint at specified line or function
(gdb) break main // Sets a Breakpoint at statrting of main function
(gdb) run // runs the program and stops at breakpoint
(gdb) next or n // step to the next line
(gdb) n // step to next line
(gdb) print (or p) var // prints the value stored in the variable
(gdb) continue or c // Continue execution till next breakpoint
(gdb) quit // Quit gdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment