Obsah

GDB

Výpis paměti

x/nfu addr
x addr
x 

Příklady

Kdo zapísuje do proměné?

# gdb
(gdb) attach 2453
(gdb) bt
#0  0x00002b3f9dd525a5 in gcheckglo4k () from /usr/cachesys/bin/libcachet.so
#1  0x00002b3f9dd4f6ad in getloc () from /usr/cachesys/bin/libcachet.so
#2  0x00002b3f9dd90350 in gsetjrn () from /usr/cachesys/bin/libcachet.so
#3  0x00002b3f9dd8f7ce in gset () from /usr/cachesys/bin/libcachet.so
#4  0x00002b3f9e0f3af2 in Cgset () from /usr/cachesys/bin/libcachet.so
#5  0x00002b3f9da192ff in ZCdisp () from /usr/cachesys/bin/libcachet.so
#6  0x00002b3f9e961668 in ?? ()
#7  0x000000000afd5738 in ?? ()
#8  0x00007fff00000000 in ?? ()
#9  0x00002b3f9e142e77 in ?? () from /usr/cachesys/bin/libcachet.so
#10 0x0000000000000000 in ?? ()
(gdb) info locals
(gdb) info variables LogF
All variables matching regular expression "LogF":

Non-debugging symbols:
0x000000376a951120  LogFile
0x000000376a951124  LogFacility
(gdb) print LogFacility
$1 = 8
(gdb) set variable LogFacility = 24
(gdb) print LogFacility
$2 = 24
watch LogFacility
commands
bt
print LogFacility
continue
end
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       hw watchpoint  keep y                      LogFacility
        bt
        print LogFacility
        continue
[New Thread 0x7fe1aea75950 (LWP 26614)]
  Cannot get thread event message: debugger service failed
set print thread-events off
Program received signal SIGUSR1, User defined signal 1.
0x000000376a20fdd5 in __tls_get_addr () from /lib64/ld-linux-x86-64.so.2
(gdb) info signals
Signal        Stop      Print   Pass to program Description

SIGHUP        Yes       Yes     Yes             Hangup
SIGINT        Yes       Yes     No              Interrupt
SIGQUIT       Yes       Yes     Yes             Quit
SIGILL        Yes       Yes     Yes             Illegal instruction
SIGTRAP       Yes       Yes     No              Trace/breakpoint trap
...
SIGUSR1       Yes       Yes     Yes             User defined signal 1
...
(gdb) handle SIGUSR1 nostop
(gdb) delete
Delete all breakpoints? (y or n) y

rámce

coredump smazané binárky

# gcore 15659
core.YGsoec:4: Error in sourced command file:
/home/dev/bin/daemon/destinyd (deleted): No such file or directory.
gcore: failed to create core.15659

# ls -l /proc/15659/exe
lrwxrwxrwx. 1 root root 0 Mar 12 21:33 /proc/15659/exe -> /home/dev/bin/daemon/destinyd (deleted)
# gdb -p 15659 /proc/15659/exe
(gdb) generate-core-file
(gdb) detach

Zdroje