]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libthread_db/arch/sparc64/libpthread_md.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libthread_db / arch / sparc64 / libpthread_md.c
1 /*
2  * Copyright (c) 2004 Marcel Moolenaar
3  * Copyright (c) 2011 Marius Strobl <marius@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
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.
15  *
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.
26  */
27
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30
31 #include <sys/types.h>
32 #include <string.h>
33 #include <thread_db.h>
34 #include <ucontext.h>
35 #include <machine/fsr.h>
36
37 #include "libpthread_db.h"
38
39 void
40 pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
41 {
42
43         memcpy(&uc->uc_mcontext, r, MIN(sizeof(uc->uc_mcontext), sizeof(*r)));
44 }
45
46 void
47 pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
48 {
49
50         memcpy(r, &uc->uc_mcontext, MIN(sizeof(uc->uc_mcontext), sizeof(*r)));
51 }
52
53 void
54 pt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc)
55 {
56         mcontext_t *mc = &uc->uc_mcontext;
57
58         memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp),
59             sizeof(r->fr_regs)));
60         mc->_mc_fsr = r->fr_fsr;
61         mc->_mc_gsr = r->fr_gsr;
62         mc->_mc_fprs |= FPRS_FEF;
63 }
64
65 void
66 pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
67 {
68         const mcontext_t *mc = &uc->uc_mcontext;
69
70         if ((mc->_mc_fprs & FPRS_FEF) != 0) {
71                 memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp),
72                     sizeof(r->fr_regs)));
73                 r->fr_fsr = mc->_mc_fsr;
74                 r->fr_gsr = mc->_mc_gsr;
75         } else
76                 memset(r, 0, sizeof(*r));
77 }
78
79 void
80 pt_md_init(void)
81 {
82
83 }
84
85 int
86 pt_reg_sstep(struct reg *reg __unused, int step __unused)
87 {
88
89         return (0);
90 }