15e53a4f9SPedro F. Giffuni /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni *
4ebbcec3aSOlivier Houchard * Copyright (c) 2007 Olivier Houchard
5ebbcec3aSOlivier Houchard * All rights reserved.
6ebbcec3aSOlivier Houchard *
7ebbcec3aSOlivier Houchard * Redistribution and use in source and binary forms, with or without
8ebbcec3aSOlivier Houchard * modification, are permitted provided that the following conditions
9ebbcec3aSOlivier Houchard * are met:
10ebbcec3aSOlivier Houchard * 1. Redistributions of source code must retain the above copyright
11ebbcec3aSOlivier Houchard * notice, this list of conditions and the following disclaimer.
12ebbcec3aSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright
13ebbcec3aSOlivier Houchard * notice, this list of conditions and the following disclaimer in the
14ebbcec3aSOlivier Houchard * documentation and/or other materials provided with the distribution.
15ebbcec3aSOlivier Houchard *
16ebbcec3aSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17ebbcec3aSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18ebbcec3aSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19ebbcec3aSOlivier Houchard * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20ebbcec3aSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ebbcec3aSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22ebbcec3aSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23ebbcec3aSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24ebbcec3aSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25ebbcec3aSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26ebbcec3aSOlivier Houchard * SUCH DAMAGE.
27ebbcec3aSOlivier Houchard */
28ebbcec3aSOlivier Houchard
29ebbcec3aSOlivier Houchard #include <sys/types.h>
30820c1c55SMarcel Moolenaar #include <string.h>
31ebbcec3aSOlivier Houchard #include <thread_db.h>
32ebbcec3aSOlivier Houchard
33ebbcec3aSOlivier Houchard #include "libpthread_db.h"
34ebbcec3aSOlivier Houchard
35ebbcec3aSOlivier Houchard void
pt_reg_to_ucontext(const struct reg * r,ucontext_t * uc)36ebbcec3aSOlivier Houchard pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
37ebbcec3aSOlivier Houchard {
38ebbcec3aSOlivier Houchard mcontext_t *mc = &uc->uc_mcontext;
39ebbcec3aSOlivier Houchard __greg_t *gr = mc->__gregs;
40ebbcec3aSOlivier Houchard
41ebbcec3aSOlivier Houchard gr[_REG_R0] = r->r[0];
42ebbcec3aSOlivier Houchard gr[_REG_R1] = r->r[1];
43ebbcec3aSOlivier Houchard gr[_REG_R2] = r->r[2];
44ebbcec3aSOlivier Houchard gr[_REG_R3] = r->r[3];
45ebbcec3aSOlivier Houchard gr[_REG_R4] = r->r[4];
46ebbcec3aSOlivier Houchard gr[_REG_R5] = r->r[5];
47ebbcec3aSOlivier Houchard gr[_REG_R6] = r->r[6];
48ebbcec3aSOlivier Houchard gr[_REG_R7] = r->r[7];
49ebbcec3aSOlivier Houchard gr[_REG_R8] = r->r[8];
50ebbcec3aSOlivier Houchard gr[_REG_R9] = r->r[9];
51ebbcec3aSOlivier Houchard gr[_REG_R10] = r->r[10];
52ebbcec3aSOlivier Houchard gr[_REG_R11] = r->r[11];
53ebbcec3aSOlivier Houchard gr[_REG_R12] = r->r[12];
54ebbcec3aSOlivier Houchard gr[_REG_SP] = r->r_sp;
55ebbcec3aSOlivier Houchard gr[_REG_LR] = r->r_lr;
56ebbcec3aSOlivier Houchard gr[_REG_PC] = r->r_pc;
57ebbcec3aSOlivier Houchard gr[_REG_CPSR] = r->r_cpsr;
58ebbcec3aSOlivier Houchard }
59ebbcec3aSOlivier Houchard
60ebbcec3aSOlivier Houchard void
pt_ucontext_to_reg(const ucontext_t * uc,struct reg * r)61ebbcec3aSOlivier Houchard pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
62ebbcec3aSOlivier Houchard {
63ebbcec3aSOlivier Houchard const mcontext_t *mc = &uc->uc_mcontext;
64ebbcec3aSOlivier Houchard
65ebbcec3aSOlivier Houchard const __greg_t *gr = mc->__gregs;
66ebbcec3aSOlivier Houchard
67ebbcec3aSOlivier Houchard r->r[0] = gr[_REG_R0];
68ebbcec3aSOlivier Houchard r->r[1] = gr[_REG_R1];
69ebbcec3aSOlivier Houchard r->r[2] = gr[_REG_R2];
70ebbcec3aSOlivier Houchard r->r[3] = gr[_REG_R3];
71ebbcec3aSOlivier Houchard r->r[4] = gr[_REG_R4];
72ebbcec3aSOlivier Houchard r->r[5] = gr[_REG_R5];
73ebbcec3aSOlivier Houchard r->r[6] = gr[_REG_R6];
74ebbcec3aSOlivier Houchard r->r[7] = gr[_REG_R7];
75ebbcec3aSOlivier Houchard r->r[8] = gr[_REG_R8];
76ebbcec3aSOlivier Houchard r->r[9] = gr[_REG_R9];
77ebbcec3aSOlivier Houchard r->r[10] = gr[_REG_R10];
78ebbcec3aSOlivier Houchard r->r[11] = gr[_REG_R11];
79ebbcec3aSOlivier Houchard r->r[12] = gr[_REG_R12];
80ebbcec3aSOlivier Houchard r->r_sp = gr[_REG_SP];
81ebbcec3aSOlivier Houchard r->r_lr = gr[_REG_LR];
82ebbcec3aSOlivier Houchard r->r_pc = gr[_REG_PC];
83ebbcec3aSOlivier Houchard r->r_cpsr = gr[_REG_CPSR];
84ebbcec3aSOlivier Houchard }
85ebbcec3aSOlivier Houchard
86ebbcec3aSOlivier Houchard void
pt_fpreg_to_ucontext(const struct fpreg * r,ucontext_t * uc)876926e269SKornel Dulęba pt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
88ebbcec3aSOlivier Houchard {
896926e269SKornel Dulęba mcontext_vfp_t *mc_vfp;
90ebbcec3aSOlivier Houchard
916926e269SKornel Dulęba mc_vfp = uc->uc_mcontext.mc_vfp_ptr;
926926e269SKornel Dulęba
936926e269SKornel Dulęba if (mc_vfp != NULL)
946926e269SKornel Dulęba memcpy(mc_vfp, r, sizeof(*r));
95ebbcec3aSOlivier Houchard }
96ebbcec3aSOlivier Houchard
97ebbcec3aSOlivier Houchard void
pt_ucontext_to_fpreg(const ucontext_t * uc,struct fpreg * r)986926e269SKornel Dulęba pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
99ebbcec3aSOlivier Houchard {
1006926e269SKornel Dulęba mcontext_vfp_t *mc_vfp;
101ebbcec3aSOlivier Houchard
1026926e269SKornel Dulęba mc_vfp = uc->uc_mcontext.mc_vfp_ptr;
1036926e269SKornel Dulęba
1046926e269SKornel Dulęba if (mc_vfp != NULL)
1056926e269SKornel Dulęba memcpy(r, &mc_vfp, sizeof(*r));
106ebbcec3aSOlivier Houchard }
107ebbcec3aSOlivier Houchard
108ebbcec3aSOlivier Houchard void
pt_md_init(void)109ebbcec3aSOlivier Houchard pt_md_init(void)
110ebbcec3aSOlivier Houchard {
111ebbcec3aSOlivier Houchard }
112ebbcec3aSOlivier Houchard
113ebbcec3aSOlivier Houchard int
pt_reg_sstep(struct reg * reg __unused,int step __unused)114f60a5b31SMarcel Moolenaar pt_reg_sstep(struct reg *reg __unused, int step __unused)
115ebbcec3aSOlivier Houchard {
116ebbcec3aSOlivier Houchard
117ebbcec3aSOlivier Houchard /* XXX */
1182f6a179eSMarcel Moolenaar return (0);
119ebbcec3aSOlivier Houchard }
120