Assembly using gdb

  • Start the debugger:

    gdb [executable_name]


  • Display assembly code:

    layout asm


  • Display registers:

    layout regs


  • Set a breakpoint:

    b [function_name]


  • Run the code:

    run [name]


  • Reload screen:

    ctrl + l


  • Move to the next instruction:

    ni (pressing ENTER repeats the previous command).


  • Continue:

    c


  • Display the function:

    disas [function_name]


  • Print value in register in:

    hex: x/x $[register]

    decimal: x/d $[register]

    string: x/s $[register]


  • Print the value in array in decimal:

    x/[size]wd $[register]


Updated: