]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: tinfo: store the pthread ID and the stack pointer in tinfo
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Nov 2023 17:01:25 +0000 (18:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Nov 2023 13:32:55 +0000 (14:32 +0100)
When debugging a core, it's difficult to match a given gdb thread number
against an internal thread. Let's just store the pthread ID and the stack
pointer in each tinfo. This could help in the future by allowing to just
glance over them and pick the right one depending what info is found
first.

include/haproxy/tinfo-t.h
src/haproxy.c

index 8a4ef994a59b8c153f156f1f82364bab473f09cf..fc8514305d818bf8f862b7532e5b10906c6a1a76 100644 (file)
@@ -110,6 +110,10 @@ struct thread_info {
        uint tid, ltid;                   /* process-wide and group-wide thread ID (start at 0) */
        ulong ltid_bit;                   /* bit masks for the tid/ltid */
        uint tgid;                        /* ID of the thread group this thread belongs to (starts at 1; 0=unset) */
+       /* 32-bit hole here */
+
+       ullong pth_id;                    /* the pthread_t cast to a ullong */
+       void *stack_top;                  /* the top of the stack when entering the thread */
 
        /* pad to cache line (64B) */
        char __pad[0];                    /* unused except to check remaining room */
index 935cb52e86f32d03a008a7fd4d749a32472631b6..b3d590e4a46bdfb5f1687496d94e9b991d33369b 100644 (file)
@@ -3056,6 +3056,12 @@ static void *run_thread_poll_loop(void *data)
        ha_set_thread(data);
        set_thread_cpu_affinity();
        clock_set_local_source();
+
+#ifdef USE_THREAD
+       ha_thread_info[tid].pth_id = ha_get_pthread_id(tid);
+#endif
+       ha_thread_info[tid].stack_top = __builtin_frame_address(0);
+
        /* thread is started, from now on it is not idle nor harmless */
        thread_harmless_end();
        thread_idle_end();