mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-09 07:09:35 +00:00
e240be5495
These is a collection of functions I'm occasionally using to navigate in core dumps. Only working ones were extracted. Those requiring knowledge of global variables (e.g. pools, proxy list) use the one extracted from the post_mortem struct. That one is defined in post-mortem.gdb and needs to be initialized using "pm_init post_mortem" or "pm_init <pointer>". From this point a number of global variables are accessible even if symbols are missing; those ones are then used by other functions to dump streams, threads, pools, proxies etc. The files can be sourced or copy-pasted into a gdb session. It's worth trying to keep them up-to-date, as the old ones used to navigate through tasks are no longer usable due to massive changes.
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
# This script will set the post_mortem struct pointer ($pm) from the one found
|
|
# in the "post_mortem" symbol. If not found or if not correct, it's the same
|
|
# address as the "_post_mortem" section, which can be found using "info files"
|
|
# or "objdump -h" on the executable. The guessed value is the by a first call
|
|
# to pm_init, but if not correct, you just need to call pm_init again with the
|
|
# correct pointer, e.g:
|
|
# pm_init 0xcfd400
|
|
|
|
define pm_init
|
|
set $pm = (struct post_mortem*)$arg0
|
|
set $g = $pm.global
|
|
set $ti = $pm.thread_info
|
|
set $tc = $pm.thread_ctx
|
|
set $tgi = $pm.tgroup_info
|
|
set $tgc = $pm.tgroup_ctx
|
|
set $fd = $pm.fdtab
|
|
set $pxh = *$pm.proxies
|
|
set $po = $pm.pools
|
|
set $ac = $pm.activity
|
|
end
|
|
|
|
# show basic info on the running process (OS, uid, etc)
|
|
define pm_show_info
|
|
print $pm->platform
|
|
print $pm->process
|
|
end
|
|
|
|
# show thread IDs to easily map between gdb threads and tid
|
|
define pm_show_threads
|
|
set $t = 0
|
|
while $t < $g.nbthread
|
|
printf "Tid %4d: pthread_id=%#lx stack_top=%#lx\n", $t, $ti[$t].pth_id, $ti[$t].stack_top
|
|
set $t = $t + 1
|
|
end
|
|
end
|
|
|
|
# dump all threads' dump buffers
|
|
define pm_show_thread_dump
|
|
set $t = 0
|
|
while $t < $g.nbthread
|
|
printf "%s\n", $tc[$t].thread_dump_buffer->area
|
|
set $t = $t + 1
|
|
end
|
|
end
|
|
|
|
# initialize the various pointers
|
|
pm_init &post_mortem
|