2 * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
3 * Copyright (c) 2004 Marcel Moolenaar
6 * Redistribution and use in source and binary forms, with or without
7 * 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 ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * $DragonFly: src/lib/libthread_db/thread_db.h,v 1.1 2005/05/07 09:25:44 davidxu Exp $
33 #include <sys/procfs.h>
37 TD_ERR = -1, /* Unspecified error. */
38 TD_OK = 0, /* No error. */
61 typedef struct td_thragent td_thragent_t;
62 typedef long thread_t; /* Must be an integral type. */
65 const td_thragent_t *th_ta;
68 } td_thrhandle_t; /* Used non-opaguely. */
77 TD_CONCURRENCY= 0x0002,
83 TD_PRI_INHERIT= 0x0080,
87 TD_SWITCHFROM = 0x0800,
93 /* Compatibility with Linux. */
94 #define td_event_e td_thr_events_e
97 td_thr_events_e event;
98 const td_thrhandle_t *th_p;
102 typedef unsigned int td_thr_events_t;
105 NOTIFY_BPT, /* User inserted breakpoint. */
106 NOTIFY_AUTOBPT, /* Automatic breakpoint. */
107 NOTIFY_SYSCALL /* Invocation of system call. */
119 td_event_addset(td_thr_events_t *es, td_thr_events_e e)
125 td_event_delset(td_thr_events_t *es, td_thr_events_e e)
131 td_event_emptyset(td_thr_events_t *es)
137 td_event_fillset(td_thr_events_t *es)
143 td_eventisempty(td_thr_events_t *es)
145 return ((*es == TD_EVENT_NONE) ? 1 : 0);
149 td_eventismember(td_thr_events_t *es, td_thr_events_e e)
151 return ((*es & e) ? 1 : 0);
160 TD_THR_ANY_STATE = 0,
165 TD_THR_STOPPED_ASLEEP,
175 typedef pthread_key_t thread_key_t;
178 const td_thragent_t *ti_ta_p;
181 td_thr_state_e ti_state;
182 td_thr_type_e ti_type;
183 td_thr_events_t ti_events;
186 char ti_db_suspended;
191 psaddr_t ti_startfunc;
200 typedef int td_key_iter_f(thread_key_t, void (*)(void *), void *);
201 typedef int td_thr_iter_f(const td_thrhandle_t *, void *);
203 /* Flags for `td_ta_thr_iter'. */
204 #define TD_THR_ANY_USER_FLAGS 0xffffffff
205 #define TD_THR_LOWEST_PRIORITY -20
206 #define TD_SIGNO_MASK NULL
209 td_err_e td_init(void);
210 td_err_e td_ta_clear_event(const td_thragent_t *, td_thr_events_t *);
211 td_err_e td_ta_delete(td_thragent_t *);
212 td_err_e td_ta_event_addr(const td_thragent_t *, td_thr_events_e,
214 td_err_e td_ta_event_getmsg(const td_thragent_t *, td_event_msg_t *);
215 td_err_e td_ta_map_id2thr(const td_thragent_t *, thread_t, td_thrhandle_t *);
216 td_err_e td_ta_map_lwp2thr(const td_thragent_t *, lwpid_t, td_thrhandle_t *);
217 td_err_e td_ta_new(struct ps_prochandle *, td_thragent_t **);
218 td_err_e td_ta_set_event(const td_thragent_t *, td_thr_events_t *);
219 td_err_e td_ta_thr_iter(const td_thragent_t *, td_thr_iter_f *, void *,
220 td_thr_state_e, int, sigset_t *, unsigned int);
221 td_err_e td_ta_tsd_iter(const td_thragent_t *, td_key_iter_f *, void *);
222 td_err_e td_thr_clear_event(const td_thrhandle_t *, td_thr_events_t *);
223 td_err_e td_thr_dbresume(const td_thrhandle_t *);
224 td_err_e td_thr_dbsuspend(const td_thrhandle_t *);
225 td_err_e td_thr_event_enable(const td_thrhandle_t *, int);
226 td_err_e td_thr_event_getmsg(const td_thrhandle_t *, td_event_msg_t *);
227 td_err_e td_thr_get_info(const td_thrhandle_t *, td_thrinfo_t *);
228 td_err_e td_thr_getfpregs(const td_thrhandle_t *, prfpregset_t *);
229 td_err_e td_thr_getgregs(const td_thrhandle_t *, prgregset_t);
230 td_err_e td_thr_set_event(const td_thrhandle_t *, td_thr_events_t *);
231 td_err_e td_thr_setfpregs(const td_thrhandle_t *, const prfpregset_t *);
232 td_err_e td_thr_setgregs(const td_thrhandle_t *, const prgregset_t);
233 td_err_e td_thr_validate(const td_thrhandle_t *);
234 td_err_e td_thr_tls_get_addr(const td_thrhandle_t *, void *, size_t, void **);
238 #endif /* _THREAD_DB_H_ */