2 * Copyright (c) 2004 Marcel Moolenaar
3 * Copyright (c) 2011 Marius Strobl <marius@FreeBSD.org>
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.
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/types.h>
33 #include <thread_db.h>
35 #include <machine/fsr.h>
37 #include "libpthread_db.h"
40 pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
43 memcpy(&uc->uc_mcontext, r, MIN(sizeof(uc->uc_mcontext), sizeof(*r)));
47 pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
50 memcpy(r, &uc->uc_mcontext, MIN(sizeof(uc->uc_mcontext), sizeof(*r)));
54 pt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc)
56 mcontext_t *mc = &uc->uc_mcontext;
58 memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp),
60 mc->mc_fsr = r->fr_fsr;
61 mc->mc_gsr = r->fr_gsr;
62 mc->mc_fprs |= FPRS_FEF;
66 pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
68 const mcontext_t *mc = &uc->uc_mcontext;
70 if ((mc->mc_fprs & FPRS_FEF) != 0) {
71 memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp),
73 r->fr_fsr = mc->mc_fsr;
74 r->fr_gsr = mc->mc_gsr;
76 memset(r, 0, sizeof(*r));
86 pt_reg_sstep(struct reg *reg __unused, int step __unused)