.gdbinit contains instructions that gdb will execute
at startup. Helpful for adding commonly used commands. Gdb first reads
in $HOME directory, then in current directory (if different than $HOME).
Gdb looks for source files in
$cdir (directory embedded in executable
recorded during compilation) and
$cwd (current working directory). You can
add to this list via
dir ..\..\WebCore\platform. See current
show dir. If you need this, it’s a perfect candidate for putting
run [<args>]- run the program with (optional) arguments
continue) - continue execution
bt- print a stack trace
frame <n>- switch to frame
info locals- show local variables
p <foo>- print the value of a variable
x /fmt addr- show data under a given addr using a given format
info breaks- display current breakpoints
break <line-no>- set breakpoint at a line number in current file e.g.
break *<addr>- set a breakpoint at a given addr e.g.
break *foo + 24(set a breakpoint 24 bytes after the beginning of function foo
enable <n>- delete/disable/enable breakpoint
Debugging at assembly level:
display /i $eipso that gdb prints the next assembly instruction
stepifor stepping by one instruction
set disassembly-flavor intelchanges assembly syntax from awful AT&T to less awful intel
info regs- show content of registers
Useful macros to define in
dpc [<count>] disassembles next (or 24 if not given) bytes starting from current location.
define dpc if $argc ==1 disass $pc $pc + $arg0 end if $argc == 0 disass $pc $pc+24 end end
pu <addr> print Unicode string under address
def pu set $uni = $arg0 set $i = 0 while (*$uni && $i++<100) if (*$uni < 0x80) print *(char*)$uni++ else print /x *(short*)$uni++ end end end