GDB tips&tricks

Common commands

# Breakpoint by symbol name
br ioctl

# Breakpoint on ARM by symbol name and first argument == DMA_HEAP_IOCTL_ALLOC
br ioctl
condition <breakpoint-num> $x1 == 3222816768

# Disabling breakpoint
disable breakpoint <num> [once] [range]

# Enabling breakpoint
enable breakpoint <num> [once] [range]


# Writing breakpoint backtraces and continuing
define continue-hook
silent
bt
continue
end


catch trow 
catch exec
catch fork
catch vfork
catch load
catch unload

# Run binary
run  -- args...
# Kill binary
kill 

# Log gdb output also to mylog.txt file
set logging file mylog.txt
set logging on

For ARM64

set $outside = 1
catch syscall dup
commands
  silent
  set $outside = ! $outside
  if ( ! $outside && $x0 == 83 )
     info registers
     bt
  end
  continue
end

Remote Debug

On machine serving port

gdbserver --attach  0.0.0.0:4444 2312450

To attach

gdb program
(gdb) target remote targethost:4444

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *