xref: /freebsd/lib/libthread_db/thread_db_int.h (revision 2be1a816b9ff69588e55be0a84cbe2a31efc0f2f)
1 /*
2  * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 #ifndef _THREAD_DB_INT_H_
30 #define	_THREAD_DB_INT_H_
31 
32 #include <sys/types.h>
33 #include <sys/queue.h>
34 
35 #define	TD_THRAGENT_FIELDS			\
36 	struct ta_ops		*ta_ops;	\
37 	TAILQ_ENTRY(td_thragent) ta_next;	\
38 	struct ps_prochandle	*ph
39 
40 struct ta_ops {
41 	td_err_e (*to_init)(void);
42 
43 	td_err_e (*to_ta_clear_event)(const td_thragent_t *,
44 	    td_thr_events_t *);
45 	td_err_e (*to_ta_delete)(td_thragent_t *);
46 	td_err_e (*to_ta_event_addr)(const td_thragent_t *, td_thr_events_e,
47 	    td_notify_t *);
48 	td_err_e (*to_ta_event_getmsg)(const td_thragent_t *,
49 	    td_event_msg_t *);
50 	td_err_e (*to_ta_map_id2thr)(const td_thragent_t *, thread_t,
51 	    td_thrhandle_t *);
52 	td_err_e (*to_ta_map_lwp2thr)(const td_thragent_t *, lwpid_t,
53 	    td_thrhandle_t *);
54 	td_err_e (*to_ta_new)(struct ps_prochandle *, td_thragent_t **);
55 	td_err_e (*to_ta_set_event)(const td_thragent_t *, td_thr_events_t *);
56 	td_err_e (*to_ta_thr_iter)(const td_thragent_t *, td_thr_iter_f *,
57 	    void *, td_thr_state_e, int, sigset_t *, unsigned int);
58 	td_err_e (*to_ta_tsd_iter)(const td_thragent_t *, td_key_iter_f *,
59 	    void *);
60 
61 	td_err_e (*to_thr_clear_event)(const td_thrhandle_t *,
62 	    td_thr_events_t *);
63 	td_err_e (*to_thr_dbresume)(const td_thrhandle_t *);
64 	td_err_e (*to_thr_dbsuspend)(const td_thrhandle_t *);
65 	td_err_e (*to_thr_event_enable)(const td_thrhandle_t *, int);
66 	td_err_e (*to_thr_event_getmsg)(const td_thrhandle_t *,
67 	    td_event_msg_t *);
68 	td_err_e (*to_thr_get_info)(const td_thrhandle_t *, td_thrinfo_t *);
69 	td_err_e (*to_thr_getfpregs)(const td_thrhandle_t *, prfpregset_t *);
70 	td_err_e (*to_thr_getgregs)(const td_thrhandle_t *, prgregset_t);
71 	td_err_e (*to_thr_set_event)(const td_thrhandle_t *,
72 	    td_thr_events_t *);
73 	td_err_e (*to_thr_setfpregs)(const td_thrhandle_t *,
74 	    const prfpregset_t *);
75 	td_err_e (*to_thr_setgregs)(const td_thrhandle_t *, const prgregset_t);
76 	td_err_e (*to_thr_validate)(const td_thrhandle_t *);
77 	td_err_e (*to_thr_tls_get_addr)(const td_thrhandle_t *,
78                    void *, size_t, void **);
79 
80 	/* FreeBSD specific extensions. */
81 	td_err_e (*to_thr_sstep)(const td_thrhandle_t *, int);
82 #if defined(__i386__)
83 	td_err_e (*to_thr_getxmmregs)(const td_thrhandle_t *, char *);
84 	td_err_e (*to_thr_setxmmregs)(const td_thrhandle_t *, const char *);
85 #endif
86 };
87 
88 #ifdef TD_DEBUG
89 #define TDBG(...) ps_plog(__VA_ARGS__)
90 #define TDBG_FUNC() ps_plog("%s\n", __func__)
91 #else
92 #define TDBG(...)
93 #define TDBG_FUNC()
94 #endif
95 
96 #endif /* _THREAD_DB_INT_H_ */
97