0106

January 6, 2021

org external links

gdb basic command

  • https://www.tutorialspoint.com/gnu_debugger/gdb_commands.htm

  • b main: Puts a break point at the begining of the program

  • b: Puts a breakpoint at the current line

  • b N: Puts a breakpoint at Line N

  • b +N: Puts a breakpoint N lines down from the current line

  • b fn: Puts a breakpoint at the begining of function “fn”

  • d N: Delete breakpoint number N

  • info break: List breakpoints

  • r: Runs the program until a breakpoint or error

  • c: Continus running the program until the next breakpoint or error

  • f: Runs until the current function is finished

  • s: Runs the next line of the program

  • s N: Runs the next N lines of the program

  • n: Like s, but it does not step into functions

  • u N: Runs until you get N lines in front of the current line

  • p var: Prints the current value of the variable “var”

  • bt: Prints a stack trace

  • u: Goes up a level in the stack

  • d: Goes down a level in the stack

  • q: Quit gdb

gdb basic command examples

  • r | r arg1 arg2 | r < file1

  • l | l 50 | l myfunction

  • next | step | finish

  • break 45 | break myfunction | continue

  • print x | set x = 3 | set x = y

  • call myfunction | call myotherfunction(x) | call strlen(mystring)

  • display x | undisplay x

  • handle [signalname][action]

  • handle SIGUSR1 nostop

  • handle SIGUSR1 noprint

  • handle SIGUSR1 ignore

  • more detailed example: https://www.tutorialspoint.com/gnu_debugger/gdb_debugging_examples.htm