13c1e38eaSMarcel Moolenaar /*
23c1e38eaSMarcel Moolenaar  * Copyright (c) 2004 David Xu <[email protected]>
33c1e38eaSMarcel Moolenaar  * All rights reserved.
43c1e38eaSMarcel Moolenaar  *
53c1e38eaSMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
63c1e38eaSMarcel Moolenaar  * modification, are permitted provided that the following conditions
73c1e38eaSMarcel Moolenaar  * are met:
83c1e38eaSMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
93c1e38eaSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
103c1e38eaSMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
113c1e38eaSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
123c1e38eaSMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
133c1e38eaSMarcel Moolenaar  *
143c1e38eaSMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
153c1e38eaSMarcel Moolenaar  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
163c1e38eaSMarcel Moolenaar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
173c1e38eaSMarcel Moolenaar  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
183c1e38eaSMarcel Moolenaar  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
193c1e38eaSMarcel Moolenaar  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
203c1e38eaSMarcel Moolenaar  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
213c1e38eaSMarcel Moolenaar  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
223c1e38eaSMarcel Moolenaar  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
233c1e38eaSMarcel Moolenaar  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
243c1e38eaSMarcel Moolenaar  * SUCH DAMAGE.
253c1e38eaSMarcel Moolenaar  *
263c1e38eaSMarcel Moolenaar  * $FreeBSD$
273c1e38eaSMarcel Moolenaar  */
283c1e38eaSMarcel Moolenaar 
293c1e38eaSMarcel Moolenaar #ifndef _LIBPTHREAD_DB_H_
303c1e38eaSMarcel Moolenaar #define	_LIBPTHREAD_DB_H_
313c1e38eaSMarcel Moolenaar 
323c1e38eaSMarcel Moolenaar #include <sys/ucontext.h>
333c1e38eaSMarcel Moolenaar #include <machine/reg.h>
343c1e38eaSMarcel Moolenaar 
353c1e38eaSMarcel Moolenaar #include "thread_db_int.h"
363c1e38eaSMarcel Moolenaar 
373c1e38eaSMarcel Moolenaar struct pt_map {
383c1e38eaSMarcel Moolenaar 	enum {
393c1e38eaSMarcel Moolenaar 		PT_NONE,
403c1e38eaSMarcel Moolenaar 		PT_USER,
413c1e38eaSMarcel Moolenaar 		PT_LWP
423c1e38eaSMarcel Moolenaar 	} type;
433c1e38eaSMarcel Moolenaar 
443c1e38eaSMarcel Moolenaar 	union {
453c1e38eaSMarcel Moolenaar 		lwpid_t		lwp;
463c1e38eaSMarcel Moolenaar 		psaddr_t	thr;
473c1e38eaSMarcel Moolenaar 	};
483c1e38eaSMarcel Moolenaar };
493c1e38eaSMarcel Moolenaar 
503c1e38eaSMarcel Moolenaar struct td_thragent {
513c1e38eaSMarcel Moolenaar 	TD_THRAGENT_FIELDS;
523c1e38eaSMarcel Moolenaar 	psaddr_t	libkse_debug_addr;
533c1e38eaSMarcel Moolenaar 	psaddr_t	thread_list_addr;
543c1e38eaSMarcel Moolenaar 	psaddr_t	thread_listgen_addr;
553c1e38eaSMarcel Moolenaar 	psaddr_t	thread_activated_addr;
563c1e38eaSMarcel Moolenaar 	psaddr_t	thread_active_threads_addr;
573c1e38eaSMarcel Moolenaar 	psaddr_t	thread_keytable_addr;
583c1e38eaSMarcel Moolenaar 	int		thread_activated;
59cd980d46SDavid Xu 	int		thread_off_dtv;
60cd980d46SDavid Xu 	int		thread_off_kse_locklevel;
61cd980d46SDavid Xu 	int		thread_off_kse;
62cd980d46SDavid Xu 	int		thread_off_tlsindex;
63cd980d46SDavid Xu 	int		thread_off_attr_flags;
64cd980d46SDavid Xu 	int		thread_size_key;
65cd980d46SDavid Xu 	int		thread_off_tcb;
66cd980d46SDavid Xu 	int		thread_off_linkmap;
67cd980d46SDavid Xu 	int		thread_off_tmbx;
68cd980d46SDavid Xu 	int		thread_off_thr_locklevel;
69cd980d46SDavid Xu 	int		thread_off_next;
70cd980d46SDavid Xu 	int		thread_off_state;
71cd980d46SDavid Xu 	int		thread_max_keys;
72cd980d46SDavid Xu 	int		thread_off_key_allocated;
73cd980d46SDavid Xu 	int		thread_off_key_destructor;
74cd980d46SDavid Xu 	int		thread_state_zoombie;
75cd980d46SDavid Xu 	int		thread_state_running;
76*2ed66c93SDavid Xu 	int		thread_off_sigmask;
77*2ed66c93SDavid Xu 	int		thread_off_sigpend;
783c1e38eaSMarcel Moolenaar 	struct pt_map	*map;
793c1e38eaSMarcel Moolenaar 	int		map_len;
803c1e38eaSMarcel Moolenaar };
813c1e38eaSMarcel Moolenaar 
823c1e38eaSMarcel Moolenaar void pt_md_init(void);
833c1e38eaSMarcel Moolenaar void pt_reg_to_ucontext(const struct reg *, ucontext_t *);
843c1e38eaSMarcel Moolenaar void pt_ucontext_to_reg(const ucontext_t *, struct reg *);
853c1e38eaSMarcel Moolenaar void pt_fpreg_to_ucontext(const struct fpreg *, ucontext_t *);
863c1e38eaSMarcel Moolenaar void pt_ucontext_to_fpreg(const ucontext_t *, struct fpreg *);
878d7681bbSDoug Rabson #ifdef __i386__
888d7681bbSDoug Rabson void pt_fxsave_to_ucontext(const char *, ucontext_t *);
898d7681bbSDoug Rabson void pt_ucontext_to_fxsave(const ucontext_t *, char *);
908d7681bbSDoug Rabson #endif
913c1e38eaSMarcel Moolenaar int  pt_reg_sstep(struct reg *reg, int step);
923c1e38eaSMarcel Moolenaar 
933c1e38eaSMarcel Moolenaar #endif /* _LIBPTHREAD_DB_H_ */
94