Skip to content

Commit e5fccfe

Browse files
committed
MINOR: debug: store important pointers in post_mortem
Dealing with a core and a stripped executable is a pain when it comes to finding pools, proxies or thread contexts. Let's put a pointer to these heads and arrays in the post_mortem struct for easier location. Other critical lists like this could possibly benefit from being added later. Here we now have: - tgroup_info - thread_info - tgroup_ctx - thread_ctx - pools - proxies Example: $ objdump -h haproxy|grep post 34 _post_mortem 000014b0 0000000000cfd400 0000000000cfd400 008fc400 2**8 (gdb) set $pm=(struct post_mortem*)0x0000000000cfd400 (gdb) p $pm->tgroup_ctx[0] $8 = { threads_harmless = 254, threads_idle = 254, stopping_threads = 0, timers = { b = {0x0, 0x0} }, niced_tasks = 0, __pad = 0xf5662c <ha_tgroup_ctx+44> "", __end = 0xf56640 <ha_tgroup_ctx+64> "" } (gdb) info thr Id Target Id Frame * 1 Thread 0x7f9e7706a440 (LWP 21169) 0x00007f9e76a9c868 in raise () from /lib64/libc.so.6 2 Thread 0x7f9e76a60640 (LWP 21175) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 3 Thread 0x7f9e7613d640 (LWP 21176) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 4 Thread 0x7f9e7493a640 (LWP 21179) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 5 Thread 0x7f9e7593c640 (LWP 21177) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 6 Thread 0x7f9e7513b640 (LWP 21178) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 7 Thread 0x7f9e6ffff640 (LWP 21180) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 8 Thread 0x7f9e6f7fe640 (LWP 21181) 0x00007f9e76b343c7 in wait4 () from /lib64/libc.so.6 (gdb) p/x $pm->thread_info[0].pth_id $12 = 0x7f9e7706a440 (gdb) p/x $pm->thread_info[1].pth_id $13 = 0x7f9e76a60640 (gdb) set $px = *$pm->proxies while ($px != 0) printf "%#lx %s served=%u\n", $px, $px->id, $px->served set $px = ($px)->next end 0x125eda0 GLOBAL served=0 0x12645b0 stats served=0 0x1266940 comp served=0 0x1268e10 comp_bck served=0 0x1260cf0 <OCSP-UPDATE> served=0 0x12714c0 <HTTPCLIENT> served=0
1 parent 93c3f2a commit e5fccfe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/debug.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <haproxy/log.h>
4646
#include <haproxy/net_helper.h>
4747
#include <haproxy/sc_strm.h>
48+
#include <haproxy/proxy.h>
4849
#include <haproxy/stconn.h>
4950
#include <haproxy/task.h>
5051
#include <haproxy/thread.h>
@@ -149,6 +150,12 @@ struct post_mortem {
149150
/* information about dynamic shared libraries involved */
150151
char *libs; // dump of one addr / path per line, or NULL
151152
#endif
153+
struct tgroup_info *tgroup_info; // pointer to ha_tgroup_info
154+
struct thread_info *thread_info; // pointer to ha_thread_info
155+
struct tgroup_ctx *tgroup_ctx; // pointer to ha_tgroup_ctx
156+
struct thread_ctx *thread_ctx; // pointer to ha_thread_ctx
157+
struct list *pools; // pointer to the head of the pools list
158+
struct proxy **proxies; // pointer to the head of the proxies list
152159

153160
/* info about identified distinct components (executable, shared libs, etc).
154161
* These can be all listed at once in gdb using:
@@ -2543,6 +2550,13 @@ static int feed_post_mortem()
25432550
post_mortem.libs = strdup(trash.area);
25442551
#endif
25452552

2553+
post_mortem.tgroup_info = ha_tgroup_info;
2554+
post_mortem.thread_info = ha_thread_info;
2555+
post_mortem.tgroup_ctx = ha_tgroup_ctx;
2556+
post_mortem.thread_ctx = ha_thread_ctx;
2557+
post_mortem.pools = &pools;
2558+
post_mortem.proxies = &proxies_list;
2559+
25462560
return ERR_NONE;
25472561
}
25482562

0 commit comments

Comments
 (0)