Blog

Very basic GDB commands

GDB is a very powerful debugger that comes with most linux distrubutions. You will want to study it for a while if you are going to write assembly code on the linux platform.

It takes some time to study the first GDB commands, however don't be intimidated by the black console. Invest the time to study the basic commands. It really worth it.

If you are just starting out with gdb, the following basic commands might be useful for you.

Getting information about the entry point (And some more): This is very useful if you want to put a breakpoint in the beginning of the program:

info files

Viewing the registers:

info registers

Or for specific register:

info registers regname

If you want to view the disassembly of the current location, you may use the following command to get a cool assembly window:

layout asm

It happens to me sometimes that the view is messed up after some stepping around the code. If that happens to you, you could use the

refresh

command to refresh the view.

Another way to view the current instruction (And a few more following instructions) is to use:

x/10i $pc

This one will show the next 10 instructions from the current program counter. Pretty useful.

Setting a breakpoint:

break *0x800000

View list of breakpoints:

info breakpoints

Deleting a breakpoint:

delete (breakpoint_number)

or the shortcut:

d (breakpoint number)

Running:

run

Continuing the program:

continue

Stepping into: (This one will get into functions)

stepi
si

Stepping over: (This one will skip functions)

nexti
ni