1132332Smarcel/* 2132332Smarcel * Copyright (c) 2004 David Xu <davidxu@freebsd.org> 3132332Smarcel * All rights reserved. 4132332Smarcel * 5132332Smarcel * Redistribution and use in source and binary forms, with or without 6132332Smarcel * modification, are permitted provided that the following conditions 7132332Smarcel * are met: 8132332Smarcel * 1. Redistributions of source code must retain the above copyright 9132332Smarcel * notice, this list of conditions and the following disclaimer. 10132332Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11132332Smarcel * notice, this list of conditions and the following disclaimer in the 12132332Smarcel * documentation and/or other materials provided with the distribution. 13132332Smarcel * 14132332Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15132332Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16132332Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17132332Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18132332Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19132332Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20132332Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21132332Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22132332Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23132332Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24132332Smarcel * SUCH DAMAGE. 25132332Smarcel * 26132332Smarcel * $FreeBSD$ 27132332Smarcel */ 28132332Smarcel 29132332Smarcel#ifndef _THREAD_DB_INT_H_ 30132332Smarcel#define _THREAD_DB_INT_H_ 31132332Smarcel 32132332Smarcel#include <sys/types.h> 33132332Smarcel#include <sys/queue.h> 34132332Smarcel 35209689Skibtypedef struct { 36209689Skib const td_thragent_t *ti_ta_p; 37209689Skib thread_t ti_tid; 38209689Skib psaddr_t ti_thread; 39209689Skib td_thr_state_e ti_state; 40209689Skib td_thr_type_e ti_type; 41209689Skib td_thr_events_t ti_events; 42209689Skib int ti_pri; 43209689Skib lwpid_t ti_lid; 44209689Skib char ti_db_suspended; 45209689Skib char ti_traceme; 46209689Skib sigset_t ti_sigmask; 47209689Skib sigset_t ti_pending; 48209689Skib psaddr_t ti_tls; 49209689Skib psaddr_t ti_startfunc; 50209689Skib psaddr_t ti_stkbase; 51209689Skib size_t ti_stksize; 52209689Skib} td_old_thrinfo_t; 53209689Skib 54132332Smarcel#define TD_THRAGENT_FIELDS \ 55132332Smarcel struct ta_ops *ta_ops; \ 56132332Smarcel TAILQ_ENTRY(td_thragent) ta_next; \ 57132332Smarcel struct ps_prochandle *ph 58132332Smarcel 59132332Smarcelstruct ta_ops { 60132332Smarcel td_err_e (*to_init)(void); 61132332Smarcel 62132332Smarcel td_err_e (*to_ta_clear_event)(const td_thragent_t *, 63132332Smarcel td_thr_events_t *); 64132332Smarcel td_err_e (*to_ta_delete)(td_thragent_t *); 65132332Smarcel td_err_e (*to_ta_event_addr)(const td_thragent_t *, td_thr_events_e, 66132332Smarcel td_notify_t *); 67132332Smarcel td_err_e (*to_ta_event_getmsg)(const td_thragent_t *, 68132332Smarcel td_event_msg_t *); 69132332Smarcel td_err_e (*to_ta_map_id2thr)(const td_thragent_t *, thread_t, 70132332Smarcel td_thrhandle_t *); 71132332Smarcel td_err_e (*to_ta_map_lwp2thr)(const td_thragent_t *, lwpid_t, 72132332Smarcel td_thrhandle_t *); 73132332Smarcel td_err_e (*to_ta_new)(struct ps_prochandle *, td_thragent_t **); 74132332Smarcel td_err_e (*to_ta_set_event)(const td_thragent_t *, td_thr_events_t *); 75132332Smarcel td_err_e (*to_ta_thr_iter)(const td_thragent_t *, td_thr_iter_f *, 76132332Smarcel void *, td_thr_state_e, int, sigset_t *, unsigned int); 77132332Smarcel td_err_e (*to_ta_tsd_iter)(const td_thragent_t *, td_key_iter_f *, 78132332Smarcel void *); 79132332Smarcel 80132332Smarcel td_err_e (*to_thr_clear_event)(const td_thrhandle_t *, 81132332Smarcel td_thr_events_t *); 82132332Smarcel td_err_e (*to_thr_dbresume)(const td_thrhandle_t *); 83132332Smarcel td_err_e (*to_thr_dbsuspend)(const td_thrhandle_t *); 84132332Smarcel td_err_e (*to_thr_event_enable)(const td_thrhandle_t *, int); 85132332Smarcel td_err_e (*to_thr_event_getmsg)(const td_thrhandle_t *, 86132332Smarcel td_event_msg_t *); 87209689Skib td_err_e (*to_thr_old_get_info)(const td_thrhandle_t *, 88209689Skib td_old_thrinfo_t *); 89132332Smarcel td_err_e (*to_thr_get_info)(const td_thrhandle_t *, td_thrinfo_t *); 90132332Smarcel td_err_e (*to_thr_getfpregs)(const td_thrhandle_t *, prfpregset_t *); 91132332Smarcel td_err_e (*to_thr_getgregs)(const td_thrhandle_t *, prgregset_t); 92132332Smarcel td_err_e (*to_thr_set_event)(const td_thrhandle_t *, 93132332Smarcel td_thr_events_t *); 94132332Smarcel td_err_e (*to_thr_setfpregs)(const td_thrhandle_t *, 95132332Smarcel const prfpregset_t *); 96132332Smarcel td_err_e (*to_thr_setgregs)(const td_thrhandle_t *, const prgregset_t); 97132332Smarcel td_err_e (*to_thr_validate)(const td_thrhandle_t *); 98180982Smarcel td_err_e (*to_thr_tls_get_addr)(const td_thrhandle_t *, psaddr_t, 99180982Smarcel size_t, psaddr_t *); 100132332Smarcel 101132332Smarcel /* FreeBSD specific extensions. */ 102132332Smarcel td_err_e (*to_thr_sstep)(const td_thrhandle_t *, int); 103146818Sdfr#if defined(__i386__) 104146818Sdfr td_err_e (*to_thr_getxmmregs)(const td_thrhandle_t *, char *); 105146818Sdfr td_err_e (*to_thr_setxmmregs)(const td_thrhandle_t *, const char *); 106146818Sdfr#endif 107132332Smarcel}; 108132332Smarcel 109132332Smarcel#ifdef TD_DEBUG 110132332Smarcel#define TDBG(...) ps_plog(__VA_ARGS__) 111132332Smarcel#define TDBG_FUNC() ps_plog("%s\n", __func__) 112132332Smarcel#else 113132332Smarcel#define TDBG(...) 114132332Smarcel#define TDBG_FUNC() 115132332Smarcel#endif 116132332Smarcel 117181065Smarcelstruct td_thragent; 118181065Smarcel 119183021Smarcelint thr_pread_int(const struct td_thragent *, psaddr_t, uint32_t *); 120183021Smarcelint thr_pread_long(const struct td_thragent *, psaddr_t, uint64_t *); 121183021Smarcelint thr_pread_ptr(const struct td_thragent *, psaddr_t, psaddr_t *); 122181065Smarcel 123183021Smarcelint thr_pwrite_int(const struct td_thragent *, psaddr_t, uint32_t); 124183021Smarcelint thr_pwrite_long(const struct td_thragent *, psaddr_t, uint64_t); 125183021Smarcelint thr_pwrite_ptr(const struct td_thragent *, psaddr_t, psaddr_t); 126181065Smarcel 127209689Skibtd_err_e td_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info); 128209689Skib 129132332Smarcel#endif /* _THREAD_DB_INT_H_ */ 130