15e53a4f9SPedro F. Giffuni /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 35e53a4f9SPedro F. Giffuni * 43c1e38eaSMarcel Moolenaar * Copyright (c) 2004 David Xu <davidxu@freebsd.org> 53c1e38eaSMarcel Moolenaar * All rights reserved. 63c1e38eaSMarcel Moolenaar * 73c1e38eaSMarcel Moolenaar * Redistribution and use in source and binary forms, with or without 83c1e38eaSMarcel Moolenaar * modification, are permitted provided that the following conditions 93c1e38eaSMarcel Moolenaar * are met: 103c1e38eaSMarcel Moolenaar * 1. Redistributions of source code must retain the above copyright 113c1e38eaSMarcel Moolenaar * notice, this list of conditions and the following disclaimer. 123c1e38eaSMarcel Moolenaar * 2. Redistributions in binary form must reproduce the above copyright 133c1e38eaSMarcel Moolenaar * notice, this list of conditions and the following disclaimer in the 143c1e38eaSMarcel Moolenaar * documentation and/or other materials provided with the distribution. 153c1e38eaSMarcel Moolenaar * 163c1e38eaSMarcel Moolenaar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 173c1e38eaSMarcel Moolenaar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 183c1e38eaSMarcel Moolenaar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 193c1e38eaSMarcel Moolenaar * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 203c1e38eaSMarcel Moolenaar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 213c1e38eaSMarcel Moolenaar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 223c1e38eaSMarcel Moolenaar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 233c1e38eaSMarcel Moolenaar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 243c1e38eaSMarcel Moolenaar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 253c1e38eaSMarcel Moolenaar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 263c1e38eaSMarcel Moolenaar * SUCH DAMAGE. 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 37820c1c55SMarcel Moolenaar enum pt_type { 383c1e38eaSMarcel Moolenaar PT_NONE, 393c1e38eaSMarcel Moolenaar PT_USER, 403c1e38eaSMarcel Moolenaar PT_LWP 41820c1c55SMarcel Moolenaar }; 423c1e38eaSMarcel Moolenaar 43820c1c55SMarcel Moolenaar struct pt_map { 44820c1c55SMarcel Moolenaar enum pt_type type; 453c1e38eaSMarcel Moolenaar union { 463c1e38eaSMarcel Moolenaar lwpid_t lwp; 473c1e38eaSMarcel Moolenaar psaddr_t thr; 483c1e38eaSMarcel Moolenaar }; 493c1e38eaSMarcel Moolenaar }; 503c1e38eaSMarcel Moolenaar 513c1e38eaSMarcel Moolenaar struct td_thragent { 523c1e38eaSMarcel Moolenaar TD_THRAGENT_FIELDS; 533c1e38eaSMarcel Moolenaar psaddr_t libkse_debug_addr; 543c1e38eaSMarcel Moolenaar psaddr_t thread_list_addr; 553c1e38eaSMarcel Moolenaar psaddr_t thread_listgen_addr; 563c1e38eaSMarcel Moolenaar psaddr_t thread_activated_addr; 573c1e38eaSMarcel Moolenaar psaddr_t thread_active_threads_addr; 583c1e38eaSMarcel Moolenaar psaddr_t thread_keytable_addr; 593c1e38eaSMarcel Moolenaar int thread_activated; 60cd980d46SDavid Xu int thread_off_dtv; 61cd980d46SDavid Xu int thread_off_kse_locklevel; 62cd980d46SDavid Xu int thread_off_kse; 63cd980d46SDavid Xu int thread_off_tlsindex; 64cd980d46SDavid Xu int thread_off_attr_flags; 65cd980d46SDavid Xu int thread_size_key; 66cd980d46SDavid Xu int thread_off_tcb; 67cd980d46SDavid Xu int thread_off_linkmap; 68cd980d46SDavid Xu int thread_off_tmbx; 69cd980d46SDavid Xu int thread_off_thr_locklevel; 70cd980d46SDavid Xu int thread_off_next; 71cd980d46SDavid Xu int thread_off_state; 72cd980d46SDavid Xu int thread_max_keys; 73cd980d46SDavid Xu int thread_off_key_allocated; 74cd980d46SDavid Xu int thread_off_key_destructor; 75cd980d46SDavid Xu int thread_state_zoombie; 76cd980d46SDavid Xu int thread_state_running; 772ed66c93SDavid Xu int thread_off_sigmask; 782ed66c93SDavid Xu int thread_off_sigpend; 793c1e38eaSMarcel Moolenaar struct pt_map *map; 801f2b051dSPedro F. Giffuni unsigned int map_len; 813c1e38eaSMarcel Moolenaar }; 823c1e38eaSMarcel Moolenaar 833c1e38eaSMarcel Moolenaar void pt_md_init(void); 843c1e38eaSMarcel Moolenaar void pt_reg_to_ucontext(const struct reg *, ucontext_t *); 853c1e38eaSMarcel Moolenaar void pt_ucontext_to_reg(const ucontext_t *, struct reg *); 863c1e38eaSMarcel Moolenaar void pt_fpreg_to_ucontext(const struct fpreg *, ucontext_t *); 873c1e38eaSMarcel Moolenaar void pt_ucontext_to_fpreg(const ucontext_t *, struct fpreg *); 888d7681bbSDoug Rabson #ifdef __i386__ 898d7681bbSDoug Rabson void pt_fxsave_to_ucontext(const char *, ucontext_t *); 908d7681bbSDoug Rabson void pt_ucontext_to_fxsave(const ucontext_t *, char *); 918d7681bbSDoug Rabson #endif 923c1e38eaSMarcel Moolenaar int pt_reg_sstep(struct reg *reg, int step); 933c1e38eaSMarcel Moolenaar 943c1e38eaSMarcel Moolenaar #endif /* _LIBPTHREAD_DB_H_ */ 95