gdbserver/linux-low: start turning linux target ops into methods
[deliverable/binutils-gdb.git] / gdbserver / linux-sh-low.cc
1 /* GNU/Linux/SH specific low level interface, for the remote server for GDB.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #include "server.h"
20 #include "linux-low.h"
21
22 /* Linux target op definitions for the SH architecture. */
23
24 class sh_target : public linux_process_target
25 {
26 public:
27
28 };
29
30 /* The singleton target ops object. */
31
32 static sh_target the_sh_target;
33
34 /* Defined in auto-generated file reg-sh.c. */
35 void init_registers_sh (void);
36 extern const struct target_desc *tdesc_sh;
37
38 #ifdef HAVE_SYS_REG_H
39 #include <sys/reg.h>
40 #endif
41
42 #include <asm/ptrace.h>
43
44 #define sh_num_regs 41
45
46 /* Currently, don't check/send MQ. */
47 static int sh_regmap[] = {
48 0, 4, 8, 12, 16, 20, 24, 28,
49 32, 36, 40, 44, 48, 52, 56, 60,
50
51 REG_PC*4, REG_PR*4, REG_GBR*4, -1,
52 REG_MACH*4, REG_MACL*4, REG_SR*4,
53 REG_FPUL*4, REG_FPSCR*4,
54
55 REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12,
56 REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28,
57 REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44,
58 REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60,
59 };
60
61 static int
62 sh_cannot_store_register (int regno)
63 {
64 return 0;
65 }
66
67 static int
68 sh_cannot_fetch_register (int regno)
69 {
70 return 0;
71 }
72
73 /* Correct in either endianness, obviously. */
74 static const unsigned short sh_breakpoint = 0xc3c3;
75 #define sh_breakpoint_len 2
76
77 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
78
79 static const gdb_byte *
80 sh_sw_breakpoint_from_kind (int kind, int *size)
81 {
82 *size = sh_breakpoint_len;
83 return (const gdb_byte *) &sh_breakpoint;
84 }
85
86 static int
87 sh_breakpoint_at (CORE_ADDR where)
88 {
89 unsigned short insn;
90
91 the_target->read_memory (where, (unsigned char *) &insn, 2);
92 if (insn == sh_breakpoint)
93 return 1;
94
95 /* If necessary, recognize more trap instructions here. GDB only uses the
96 one. */
97 return 0;
98 }
99
100 /* Support for hardware single step. */
101
102 static int
103 sh_supports_hardware_single_step (void)
104 {
105 return 1;
106 }
107
108 /* Provide only a fill function for the general register set. ps_lgetregs
109 will use this for NPTL support. */
110
111 static void sh_fill_gregset (struct regcache *regcache, void *buf)
112 {
113 int i;
114
115 for (i = 0; i < 23; i++)
116 if (sh_regmap[i] != -1)
117 collect_register (regcache, i, (char *) buf + sh_regmap[i]);
118 }
119
120 static struct regset_info sh_regsets[] = {
121 { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
122 NULL_REGSET
123 };
124
125 static struct regsets_info sh_regsets_info =
126 {
127 sh_regsets, /* regsets */
128 0, /* num_regsets */
129 NULL, /* disabled_regsets */
130 };
131
132 static struct usrregs_info sh_usrregs_info =
133 {
134 sh_num_regs,
135 sh_regmap,
136 };
137
138 static struct regs_info regs_info =
139 {
140 NULL, /* regset_bitmap */
141 &sh_usrregs_info,
142 &sh_regsets_info
143 };
144
145 static const struct regs_info *
146 sh_regs_info (void)
147 {
148 return &regs_info;
149 }
150
151 static void
152 sh_arch_setup (void)
153 {
154 current_process ()->tdesc = tdesc_sh;
155 }
156
157 struct linux_target_ops the_low_target = {
158 sh_arch_setup,
159 sh_regs_info,
160 sh_cannot_fetch_register,
161 sh_cannot_store_register,
162 NULL, /* fetch_register */
163 linux_get_pc_32bit,
164 linux_set_pc_32bit,
165 NULL, /* breakpoint_kind_from_pc */
166 sh_sw_breakpoint_from_kind,
167 NULL,
168 0,
169 sh_breakpoint_at,
170 NULL, /* supports_z_point_type */
171 NULL, /* insert_point */
172 NULL, /* remove_point */
173 NULL, /* stopped_by_watchpoint */
174 NULL, /* stopped_data_address */
175 NULL, /* collect_ptrace_register */
176 NULL, /* supply_ptrace_register */
177 NULL, /* siginfo_fixup */
178 NULL, /* new_process */
179 NULL, /* delete_process */
180 NULL, /* new_thread */
181 NULL, /* delete_thread */
182 NULL, /* new_fork */
183 NULL, /* prepare_to_resume */
184 NULL, /* process_qsupported */
185 NULL, /* supports_tracepoints */
186 NULL, /* get_thread_area */
187 NULL, /* install_fast_tracepoint_jump_pad */
188 NULL, /* emit_ops */
189 NULL, /* get_min_fast_tracepoint_insn_len */
190 NULL, /* supports_range_stepping */
191 NULL, /* breakpoint_kind_from_current_state */
192 sh_supports_hardware_single_step,
193 };
194
195 /* The linux target ops object. */
196
197 linux_process_target *the_linux_target = &the_sh_target;
198
199 void
200 initialize_low_arch (void)
201 {
202 init_registers_sh ();
203
204 initialize_regsets_info (&sh_regsets_info);
205 }
This page took 0.044643 seconds and 5 git commands to generate.