2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef _THREAD_DB_INT_H_
32 #define _THREAD_DB_INT_H_
34 #include <sys/types.h>
35 #include <sys/queue.h>
38 const td_thragent_t *ti_ta_p;
41 td_thr_state_e ti_state;
42 td_thr_type_e ti_type;
43 td_thr_events_t ti_events;
51 psaddr_t ti_startfunc;
56 #define TD_THRAGENT_FIELDS \
57 struct ta_ops *ta_ops; \
58 TAILQ_ENTRY(td_thragent) ta_next; \
59 struct ps_prochandle *ph
62 td_err_e (*to_init)(void);
64 td_err_e (*to_ta_clear_event)(const td_thragent_t *,
66 td_err_e (*to_ta_delete)(td_thragent_t *);
67 td_err_e (*to_ta_event_addr)(const td_thragent_t *, td_thr_events_e,
69 td_err_e (*to_ta_event_getmsg)(const td_thragent_t *,
71 td_err_e (*to_ta_map_id2thr)(const td_thragent_t *, thread_t,
73 td_err_e (*to_ta_map_lwp2thr)(const td_thragent_t *, lwpid_t,
75 td_err_e (*to_ta_new)(struct ps_prochandle *, td_thragent_t **);
76 td_err_e (*to_ta_set_event)(const td_thragent_t *, td_thr_events_t *);
77 td_err_e (*to_ta_thr_iter)(const td_thragent_t *, td_thr_iter_f *,
78 void *, td_thr_state_e, int, sigset_t *, unsigned int);
79 td_err_e (*to_ta_tsd_iter)(const td_thragent_t *, td_key_iter_f *,
82 td_err_e (*to_thr_clear_event)(const td_thrhandle_t *,
84 td_err_e (*to_thr_dbresume)(const td_thrhandle_t *);
85 td_err_e (*to_thr_dbsuspend)(const td_thrhandle_t *);
86 td_err_e (*to_thr_event_enable)(const td_thrhandle_t *, int);
87 td_err_e (*to_thr_event_getmsg)(const td_thrhandle_t *,
89 td_err_e (*to_thr_old_get_info)(const td_thrhandle_t *,
91 td_err_e (*to_thr_get_info)(const td_thrhandle_t *, td_thrinfo_t *);
92 td_err_e (*to_thr_getfpregs)(const td_thrhandle_t *, prfpregset_t *);
93 td_err_e (*to_thr_getgregs)(const td_thrhandle_t *, prgregset_t);
94 td_err_e (*to_thr_set_event)(const td_thrhandle_t *,
96 td_err_e (*to_thr_setfpregs)(const td_thrhandle_t *,
97 const prfpregset_t *);
98 td_err_e (*to_thr_setgregs)(const td_thrhandle_t *, const prgregset_t);
99 td_err_e (*to_thr_validate)(const td_thrhandle_t *);
100 td_err_e (*to_thr_tls_get_addr)(const td_thrhandle_t *, psaddr_t,
103 /* FreeBSD specific extensions. */
104 td_err_e (*to_thr_sstep)(const td_thrhandle_t *, int);
105 #if defined(__i386__)
106 td_err_e (*to_thr_getxmmregs)(const td_thrhandle_t *, char *);
107 td_err_e (*to_thr_setxmmregs)(const td_thrhandle_t *, const char *);
112 #define TDBG(...) ps_plog(__VA_ARGS__)
113 #define TDBG_FUNC() ps_plog("%s\n", __func__)
121 int thr_pread_int(const struct td_thragent *, psaddr_t, uint32_t *);
122 int thr_pread_long(const struct td_thragent *, psaddr_t, uint64_t *);
123 int thr_pread_ptr(const struct td_thragent *, psaddr_t, psaddr_t *);
125 int thr_pwrite_int(const struct td_thragent *, psaddr_t, uint32_t);
126 int thr_pwrite_long(const struct td_thragent *, psaddr_t, uint64_t);
127 int thr_pwrite_ptr(const struct td_thragent *, psaddr_t, psaddr_t);
129 td_err_e td_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info);
131 #endif /* _THREAD_DB_INT_H_ */