3106d73cc3ae7c958886a28d09ac75d176827dd0
[binutils-gdb.git] / gdb / arm-fbsd-nat.c
1 /* Native-dependent code for FreeBSD/arm.
2
3 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "target.h"
22
23 #include <sys/types.h>
24 #include <sys/ptrace.h>
25 #include <machine/reg.h>
26
27 #include "fbsd-nat.h"
28 #include "arm-fbsd-tdep.h"
29 #include "inf-ptrace.h"
30
31 struct arm_fbsd_nat_target : public fbsd_nat_target
32 {
33 void fetch_registers (struct regcache *, int) override;
34 void store_registers (struct regcache *, int) override;
35 const struct target_desc *read_description () override;
36 };
37
38 static arm_fbsd_nat_target the_arm_fbsd_nat_target;
39
40 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
41 for all registers. */
42
43 void
44 arm_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
45 {
46 fetch_register_set<struct reg> (regcache, regnum, PT_GETREGS,
47 &arm_fbsd_gregset);
48 #ifdef PT_GETVFPREGS
49 fetch_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
50 &arm_fbsd_vfpregset);
51 #endif
52 }
53
54 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
55 this for all registers. */
56
57 void
58 arm_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
59 {
60 store_register_set<struct reg> (regcache, regnum, PT_GETREGS, PT_SETREGS,
61 &arm_fbsd_gregset);
62 #ifdef PT_GETVFPREGS
63 store_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
64 PT_SETVFPREGS, &arm_fbsd_vfpregset);
65 #endif
66 }
67
68 /* Implement the to_read_description method. */
69
70 const struct target_desc *
71 arm_fbsd_nat_target::read_description ()
72 {
73 const struct target_desc *desc;
74
75 desc = arm_fbsd_read_description_auxv (this);
76 if (desc == NULL)
77 desc = this->beneath ()->read_description ();
78 return desc;
79 }
80
81 void _initialize_arm_fbsd_nat ();
82 void
83 _initialize_arm_fbsd_nat ()
84 {
85 add_inf_child_target (&the_arm_fbsd_nat_target);
86 }