Skip to content

Latest commit

 

History

History
115 lines (113 loc) · 2 KB

gdb.md

File metadata and controls

115 lines (113 loc) · 2 KB

GDB commands

General

  • Start GDB
    gdb [program]
  • Running
    run [args]
  • Kill the running;
    kill

Breakpoints

  • Set a breakpoint
    break [where (e.g., function, line)]
  • Remove a breakpoint
    delete [breakpoint#]
  • Remove all breakpoints
    clear
  • Enable a disabled breakpoint
    enable [breakpoint#]
  • Disable a breakpoint
    disable [breakpoint#]

Examining the stack

  • Show call stack
    backtrace
  • Show current line
    frame

Stepping

  • Go to the next instruction, but don't dive into functions
    next
  • Go to the next instruction, diving into function
    step
  • Continue norma execution
    continue
  • Continue until the current function returns
    finish

Variables and memory

  • Print content of variable/memory location/register
    print [something (e.g., variable)]

Threads

  • Chose thread to operate on
    thread [thread#]

Manipulating the program

  • Change the content of a variable to the given value
    set var [variable_name]=[value]
  • Force the current function to return immdiately, passing the given value
    return [expression]

Sources

  • Shows the current or given source context
    list
    list [filename]:[function]
    list [filename]:[line number]
    list [first line],[last line]

Informations

  • Print arguments to the function of the current stack frame
    info args
  • Print informations about the breakpoints
    info breakpoints
  • Print the local variables in the currently selected stack frame
    info locals
  • List loaded shared libraries
    info sharedlibrary
  • List all threads
    info threads
  • Print type of named variable
    whatis [variable_name]