libpthread_md.c revision 330897
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2004 Marcel Moolenaar 5 * Copyright (c) 2011 Marius Strobl <marius@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31__FBSDID("$FreeBSD: stable/11/lib/libthread_db/arch/sparc64/libpthread_md.c 330897 2018-03-14 03:19:51Z eadler $"); 32 33#include <sys/types.h> 34#include <string.h> 35#include <thread_db.h> 36#include <ucontext.h> 37#include <machine/fsr.h> 38 39#include "libpthread_db.h" 40 41void 42pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc) 43{ 44 45 memcpy(&uc->uc_mcontext, r, MIN(sizeof(uc->uc_mcontext), sizeof(*r))); 46} 47 48void 49pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r) 50{ 51 52 memcpy(r, &uc->uc_mcontext, MIN(sizeof(uc->uc_mcontext), sizeof(*r))); 53} 54 55void 56pt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc) 57{ 58 mcontext_t *mc = &uc->uc_mcontext; 59 60 memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp), 61 sizeof(r->fr_regs))); 62 mc->_mc_fsr = r->fr_fsr; 63 mc->_mc_gsr = r->fr_gsr; 64 mc->_mc_fprs |= FPRS_FEF; 65} 66 67void 68pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r) 69{ 70 const mcontext_t *mc = &uc->uc_mcontext; 71 72 if ((mc->_mc_fprs & FPRS_FEF) != 0) { 73 memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp), 74 sizeof(r->fr_regs))); 75 r->fr_fsr = mc->_mc_fsr; 76 r->fr_gsr = mc->_mc_gsr; 77 } else 78 memset(r, 0, sizeof(*r)); 79} 80 81void 82pt_md_init(void) 83{ 84 85} 86 87int 88pt_reg_sstep(struct reg *reg __unused, int step __unused) 89{ 90 91 return (0); 92} 93