Remove path name from test case
[binutils-gdb.git] / gdbserver / netbsd-aarch64-low.cc
1 /* Copyright (C) 2020-2023 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <sys/types.h>
19 #include <sys/ptrace.h>
20 #include <limits.h>
21
22 #include "server.h"
23 #include "netbsd-low.h"
24 #include "arch/aarch64.h"
25 #include "arch/aarch64-insn.h"
26 #include "tdesc.h"
27
28 /* The fill_function for the general-purpose register set. */
29
30 static void
31 netbsd_aarch64_fill_gregset (struct regcache *regcache, char *buf)
32 {
33 struct reg *r = (struct reg *) buf;
34
35 #define netbsd_aarch64_collect_gp(regnum, fld) do { \
36 collect_register (regcache, regnum, &r->fld); \
37 } while (0)
38
39 for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
40 netbsd_aarch64_collect_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
41
42 netbsd_aarch64_collect_gp (AARCH64_SP_REGNUM, r_sp);
43 netbsd_aarch64_collect_gp (AARCH64_PC_REGNUM, r_pc);
44 }
45
46 /* The store_function for the general-purpose register set. */
47
48 static void
49 netbsd_aarch64_store_gregset (struct regcache *regcache, const char *buf)
50 {
51 struct reg *r = (struct reg *) buf;
52
53 #define netbsd_aarch64_supply_gp(regnum, fld) do { \
54 supply_register (regcache, regnum, &r->fld); \
55 } while(0)
56
57 for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
58 netbsd_aarch64_supply_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
59
60 netbsd_aarch64_supply_gp (AARCH64_SP_REGNUM, r_sp);
61 netbsd_aarch64_supply_gp (AARCH64_PC_REGNUM, r_pc);
62 }
63
64 /* Description of all the aarch64-netbsd register sets. */
65
66 static const struct netbsd_regset_info netbsd_target_regsets[] =
67 {
68 /* General Purpose Registers. */
69 {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
70 netbsd_aarch64_fill_gregset, netbsd_aarch64_store_gregset},
71 /* End of list marker. */
72 {0, 0, -1, NULL, NULL }
73 };
74
75 /* NetBSD target op definitions for the aarch64 architecture. */
76
77 class netbsd_aarch64_target : public netbsd_process_target
78 {
79 protected:
80 const netbsd_regset_info *get_regs_info () override;
81
82 void low_arch_setup () override;
83 };
84
85 /* Return the information to access registers. */
86
87 const netbsd_regset_info *
88 netbsd_aarch64_target::get_regs_info ()
89 {
90 return netbsd_target_regsets;
91 }
92
93 /* Architecture-specific setup for the current process. */
94
95 void
96 netbsd_aarch64_target::low_arch_setup ()
97 {
98 target_desc *tdesc
99 = aarch64_create_target_description ({});
100
101 static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
102 init_target_desc (tdesc, expedite_regs_aarch64);
103
104 current_process ()->tdesc = tdesc;
105 }
106
107 /* The singleton target ops object. */
108
109 static netbsd_aarch64_target the_netbsd_aarch64_target;
110
111 /* The NetBSD target ops object. */
112
113 netbsd_process_target *the_netbsd_target = &the_netbsd_aarch64_target;