home Gdb basics   

Customization: File .gdbinit contains instructions that gdb will execute at startup. Helpful for adding commonly used commands. Gdb first reads .gdbinit 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 e.g. dir ..\..\WebCore\platform. See current list via show dir. If you need this, it's a perfect candidate for putting inside .gdbinit file.

Basics:

Debugging at assembly level:

Useful macros to define in .gdbinit:

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

← newer • 204 of 636older →