blob: b120c42b3aa1577a075f5eb596c0e0131150e9ea [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Private header for thread debug library. */
2#ifndef _THREAD_DBP_H
3#define _THREAD_DBP_H 1
4
5#define __FORCE_GLIBC
6#include <features.h>
7#include <string.h>
8#include <unistd.h>
9#include "proc_service.h"
10#include "thread_db.h"
11#include "internals.h"
12
13
14/* Indices for the symbol names. */
15enum
16 {
17 PTHREAD_THREADS_EVENTS = 0,
18 PTHREAD_LAST_EVENT,
19 PTHREAD_HANDLES_NUM,
20 PTHREAD_HANDLES,
21 PTHREAD_KEYS,
22 LINUXTHREADS_PTHREAD_THREADS_MAX,
23 LINUXTHREADS_PTHREAD_KEYS_MAX,
24 LINUXTHREADS_PTHREAD_SIZEOF_DESCR,
25 LINUXTHREADS_CREATE_EVENT,
26 LINUXTHREADS_DEATH_EVENT,
27 LINUXTHREADS_REAP_EVENT,
28 LINUXTHREADS_INITIAL_REPORT_EVENTS,
29 LINUXTHREADS_VERSION,
30 NUM_MESSAGES
31 };
32
33
34/* Comment out the following for less verbose output. */
35#ifndef NDEBUG
36# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n"))
37extern int __td_debug attribute_hidden;
38#else
39# define LOG(c)
40#endif
41
42
43/* Handle for a process. This type is opaque. */
44struct td_thragent
45{
46 /* Delivered by the debugger and we have to pass it back in the
47 proc callbacks. */
48 struct ps_prochandle *ph;
49
50 /* Some cached information. */
51
52 /* Address of the `__pthread_handles' array. */
53 struct pthread_handle_struct *handles;
54
55 /* Address of the `pthread_kyes' array. */
56 struct pthread_key_struct *keys;
57
58 /* Maximum number of threads. */
59 int pthread_threads_max;
60
61 /* Maximum number of thread-local data keys. */
62 int pthread_keys_max;
63
64 /* Size of 2nd level array for thread-local data keys. */
65 int pthread_key_2ndlevel_size;
66
67 /* Sizeof struct _pthread_descr_struct. */
68 int sizeof_descr;
69
70 /* Pointer to the `__pthread_threads_events' variable in the target. */
71 psaddr_t pthread_threads_eventsp;
72
73 /* Pointer to the `__pthread_last_event' variable in the target. */
74 psaddr_t pthread_last_event;
75
76 /* Pointer to the `__pthread_handles_num' variable. */
77 psaddr_t pthread_handles_num;
78};
79
80
81/* Type used internally to keep track of thread agent descriptors. */
82struct agent_list
83{
84 td_thragent_t *ta;
85 struct agent_list *next;
86};
87
88/* List of all known descriptors. */
89extern struct agent_list *__td_agent_list attribute_hidden;
90
91/* Function used to test for correct thread agent pointer. */
92static __inline__ int
93ta_ok (const td_thragent_t *ta)
94{
95 struct agent_list *runp = __td_agent_list;
96
97 if (ta == NULL)
98 return 0;
99
100 while (runp != NULL && runp->ta != ta)
101 runp = runp->next;
102
103 return runp != NULL;
104}
105
106
107/* Internal wrapper around ps_pglobal_lookup. */
108extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr) attribute_hidden;
109
110#endif /* thread_dbP.h */