15e53a4f9SPedro F. Giffuni /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni *
4e4e9813eSMarcel Moolenaar * Copyright (c) 2006 Marcel Moolenaar
5e4e9813eSMarcel Moolenaar * All rights reserved.
6e4e9813eSMarcel Moolenaar *
7e4e9813eSMarcel Moolenaar * Redistribution and use in source and binary forms, with or without
8e4e9813eSMarcel Moolenaar * modification, are permitted provided that the following conditions
9e4e9813eSMarcel Moolenaar * are met:
10e4e9813eSMarcel Moolenaar * 1. Redistributions of source code must retain the above copyright
11e4e9813eSMarcel Moolenaar * notice, this list of conditions and the following disclaimer.
12e4e9813eSMarcel Moolenaar * 2. Redistributions in binary form must reproduce the above copyright
13e4e9813eSMarcel Moolenaar * notice, this list of conditions and the following disclaimer in the
14e4e9813eSMarcel Moolenaar * documentation and/or other materials provided with the distribution.
15e4e9813eSMarcel Moolenaar *
16e4e9813eSMarcel Moolenaar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17e4e9813eSMarcel Moolenaar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18e4e9813eSMarcel Moolenaar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19e4e9813eSMarcel Moolenaar * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20e4e9813eSMarcel Moolenaar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21e4e9813eSMarcel Moolenaar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22e4e9813eSMarcel Moolenaar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e4e9813eSMarcel Moolenaar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24e4e9813eSMarcel Moolenaar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25e4e9813eSMarcel Moolenaar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26e4e9813eSMarcel Moolenaar * SUCH DAMAGE.
27e4e9813eSMarcel Moolenaar */
28e4e9813eSMarcel Moolenaar
29e4e9813eSMarcel Moolenaar #include <sys/types.h>
30820c1c55SMarcel Moolenaar #include <string.h>
31e4e9813eSMarcel Moolenaar #include <thread_db.h>
32e4e9813eSMarcel Moolenaar
33e4e9813eSMarcel Moolenaar #include "libpthread_db.h"
34e4e9813eSMarcel Moolenaar
35e4e9813eSMarcel Moolenaar void
pt_reg_to_ucontext(const struct reg * r,ucontext_t * uc)36e4e9813eSMarcel Moolenaar pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
37e4e9813eSMarcel Moolenaar {
3885999a01SMarcel Moolenaar mcontext_t *mc = &uc->uc_mcontext;
3985999a01SMarcel Moolenaar
4085999a01SMarcel Moolenaar memcpy(mc->mc_frame, r, MIN(sizeof(mc->mc_frame), sizeof(*r)));
41e4e9813eSMarcel Moolenaar }
42e4e9813eSMarcel Moolenaar
43e4e9813eSMarcel Moolenaar void
pt_ucontext_to_reg(const ucontext_t * uc,struct reg * r)44e4e9813eSMarcel Moolenaar pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
45e4e9813eSMarcel Moolenaar {
4685999a01SMarcel Moolenaar const mcontext_t *mc = &uc->uc_mcontext;
4785999a01SMarcel Moolenaar
4885999a01SMarcel Moolenaar memcpy(r, mc->mc_frame, MIN(sizeof(mc->mc_frame), sizeof(*r)));
49e4e9813eSMarcel Moolenaar }
50e4e9813eSMarcel Moolenaar
51e4e9813eSMarcel Moolenaar void
pt_fpreg_to_ucontext(const struct fpreg * r,ucontext_t * uc)52e4e9813eSMarcel Moolenaar pt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
53e4e9813eSMarcel Moolenaar {
5485999a01SMarcel Moolenaar mcontext_t *mc = &uc->uc_mcontext;
5585999a01SMarcel Moolenaar
5685999a01SMarcel Moolenaar memcpy(mc->mc_fpreg, r, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
5785999a01SMarcel Moolenaar mc->mc_flags |= _MC_FP_VALID;
58e4e9813eSMarcel Moolenaar }
59e4e9813eSMarcel Moolenaar
60e4e9813eSMarcel Moolenaar void
pt_ucontext_to_fpreg(const ucontext_t * uc,struct fpreg * r)61e4e9813eSMarcel Moolenaar pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
62e4e9813eSMarcel Moolenaar {
6385999a01SMarcel Moolenaar const mcontext_t *mc = &uc->uc_mcontext;
6485999a01SMarcel Moolenaar
6585999a01SMarcel Moolenaar if (mc->mc_flags & _MC_FP_VALID)
6685999a01SMarcel Moolenaar memcpy(r, mc->mc_fpreg, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
6785999a01SMarcel Moolenaar else
6885999a01SMarcel Moolenaar memset(r, 0, sizeof(*r));
69e4e9813eSMarcel Moolenaar }
70e4e9813eSMarcel Moolenaar
71e4e9813eSMarcel Moolenaar void
pt_md_init(void)72e4e9813eSMarcel Moolenaar pt_md_init(void)
73e4e9813eSMarcel Moolenaar {
74e4e9813eSMarcel Moolenaar }
75e4e9813eSMarcel Moolenaar
76e4e9813eSMarcel Moolenaar int
pt_reg_sstep(struct reg * reg __unused,int step __unused)77f60a5b31SMarcel Moolenaar pt_reg_sstep(struct reg *reg __unused, int step __unused)
78e4e9813eSMarcel Moolenaar {
7985999a01SMarcel Moolenaar
8085999a01SMarcel Moolenaar /* XXX */
812f6a179eSMarcel Moolenaar return (0);
82e4e9813eSMarcel Moolenaar }
83