GDB Info
Displaying stuff:
print displays the value in
x displays the value pointed at by
display displays after each command
undisplay removes display #
Any of these commands can have a format argument appended:
/d decimal
/u unsigned
/x hex
/t binary
/i instruction
/s string (displays ascii values until a nul is encountered)
/c char
display /i $eip
is a useful command. It displays the value pointed at by
$eip after each command and interprets it as an instruction. Basically it
shows the next instruction to be run.
Also, if a size and number are given, it will print that many of those
size items after the given thing.
I.E. x/20w $esp displays 20 words at and after $esp.
sizes are:
/b byte
/w word
Breakpoints:
Setting and removing single breakpoints:
break (some function) or
break (line number) or
break *(some memory address) or
delete (breakpoint number)
Removing all breakpoints:
clear (some functionr) or
(some line number) or
*(some memory address)
Running:
stepi steps one instruction, going into function calls
nexti steps one instruction, not going into function calls
run restarts the program at full speed
continue goes at full speed after a breakpoint
kill end the program running
Command Line:
set args (stuff) passes as command line arguments to the program
file loads as the program to be run
Lazy Typing:
enter at an empty command line repeats the last command
ambigious abreviations will resolve to the last command with that
abbreviation
Lazy Math:
print/d 0x(some hex number) will convert it to decimal
print/h (some decimal number) will convert it to hex
More complicated expressions will probably work too.
This is my short list of useful commands
- make – run make. It can take arguments just like
on the command line.
- enter – do the same command again.
- n (next) – move to the next source line in the file.
- s (step) – step into the function.
- finish – step out of the current function.
- break filename:line number
– set a breakpoint at a particular line.
- clear – clear the breakpoint you are stopped on.
- bt (backtrace) – show the current stack.
- frame n – go to the nth stack
frame.
- info threads – list the current threads.
- thread n – look at the nth thread.
- print something – print a variable's value,
or evaluate something (such as print sizeof(foo)
- info locals – print all local variables.
- info args – print all of the arguments to the
current function as they are now (as opposed to as they were at the top
of the function).
- call function – call a function.
- whatis something – print the type of a
thing.
- x – just look at help x. This does memory
dumps in many formats.
--
Mike Erlinger
Last Modified Thursday, 30-Jun-2011 12:44:45 PDT