gdbserver/linux-low: turn 'sw_breakpoint_from_kind' into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-ia64-low.cc
1 /* GNU/Linux/IA64 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 #ifdef HAVE_SYS_REG_H
23 #include <sys/reg.h>
24 #endif
25
26 /* Linux target op definitions for the IA64 architecture. */
27
28 class ia64_target : public linux_process_target
29 {
30 public:
31
32 const regs_info *get_regs_info () override;
33
34 const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
35
36 protected:
37
38 void low_arch_setup () override;
39
40 bool low_cannot_fetch_register (int regno) override;
41
42 bool low_cannot_store_register (int regno) override;
43
44 bool low_fetch_register (regcache *regcache, int regno) override;
45 };
46
47 /* The singleton target ops object. */
48
49 static ia64_target the_ia64_target;
50
51 const gdb_byte *
52 ia64_target::sw_breakpoint_from_kind (int kind, int *size)
53 {
54 gdb_assert_no_reached ("target op sw_breakpoint_from_kind is not "
55 "implemented by this target");
56 }
57
58 /* Defined in auto-generated file reg-ia64.c. */
59 void init_registers_ia64 (void);
60 extern const struct target_desc *tdesc_ia64;
61
62 #define ia64_num_regs 462
63
64 #include <asm/ptrace_offsets.h>
65
66 static int ia64_regmap[] =
67 {
68 /* general registers */
69 -1, /* gr0 not available; i.e, it's always zero */
70 PT_R1,
71 PT_R2,
72 PT_R3,
73 PT_R4,
74 PT_R5,
75 PT_R6,
76 PT_R7,
77 PT_R8,
78 PT_R9,
79 PT_R10,
80 PT_R11,
81 PT_R12,
82 PT_R13,
83 PT_R14,
84 PT_R15,
85 PT_R16,
86 PT_R17,
87 PT_R18,
88 PT_R19,
89 PT_R20,
90 PT_R21,
91 PT_R22,
92 PT_R23,
93 PT_R24,
94 PT_R25,
95 PT_R26,
96 PT_R27,
97 PT_R28,
98 PT_R29,
99 PT_R30,
100 PT_R31,
101 /* gr32 through gr127 not directly available via the ptrace interface */
102 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
103 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
104 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
105 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
106 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
107 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
108 /* Floating point registers */
109 -1, -1, /* f0 and f1 not available (f0 is +0.0 and f1 is +1.0) */
110 PT_F2,
111 PT_F3,
112 PT_F4,
113 PT_F5,
114 PT_F6,
115 PT_F7,
116 PT_F8,
117 PT_F9,
118 PT_F10,
119 PT_F11,
120 PT_F12,
121 PT_F13,
122 PT_F14,
123 PT_F15,
124 PT_F16,
125 PT_F17,
126 PT_F18,
127 PT_F19,
128 PT_F20,
129 PT_F21,
130 PT_F22,
131 PT_F23,
132 PT_F24,
133 PT_F25,
134 PT_F26,
135 PT_F27,
136 PT_F28,
137 PT_F29,
138 PT_F30,
139 PT_F31,
140 PT_F32,
141 PT_F33,
142 PT_F34,
143 PT_F35,
144 PT_F36,
145 PT_F37,
146 PT_F38,
147 PT_F39,
148 PT_F40,
149 PT_F41,
150 PT_F42,
151 PT_F43,
152 PT_F44,
153 PT_F45,
154 PT_F46,
155 PT_F47,
156 PT_F48,
157 PT_F49,
158 PT_F50,
159 PT_F51,
160 PT_F52,
161 PT_F53,
162 PT_F54,
163 PT_F55,
164 PT_F56,
165 PT_F57,
166 PT_F58,
167 PT_F59,
168 PT_F60,
169 PT_F61,
170 PT_F62,
171 PT_F63,
172 PT_F64,
173 PT_F65,
174 PT_F66,
175 PT_F67,
176 PT_F68,
177 PT_F69,
178 PT_F70,
179 PT_F71,
180 PT_F72,
181 PT_F73,
182 PT_F74,
183 PT_F75,
184 PT_F76,
185 PT_F77,
186 PT_F78,
187 PT_F79,
188 PT_F80,
189 PT_F81,
190 PT_F82,
191 PT_F83,
192 PT_F84,
193 PT_F85,
194 PT_F86,
195 PT_F87,
196 PT_F88,
197 PT_F89,
198 PT_F90,
199 PT_F91,
200 PT_F92,
201 PT_F93,
202 PT_F94,
203 PT_F95,
204 PT_F96,
205 PT_F97,
206 PT_F98,
207 PT_F99,
208 PT_F100,
209 PT_F101,
210 PT_F102,
211 PT_F103,
212 PT_F104,
213 PT_F105,
214 PT_F106,
215 PT_F107,
216 PT_F108,
217 PT_F109,
218 PT_F110,
219 PT_F111,
220 PT_F112,
221 PT_F113,
222 PT_F114,
223 PT_F115,
224 PT_F116,
225 PT_F117,
226 PT_F118,
227 PT_F119,
228 PT_F120,
229 PT_F121,
230 PT_F122,
231 PT_F123,
232 PT_F124,
233 PT_F125,
234 PT_F126,
235 PT_F127,
236 /* predicate registers - we don't fetch these individually */
237 -1, -1, -1, -1, -1, -1, -1, -1,
238 -1, -1, -1, -1, -1, -1, -1, -1,
239 -1, -1, -1, -1, -1, -1, -1, -1,
240 -1, -1, -1, -1, -1, -1, -1, -1,
241 -1, -1, -1, -1, -1, -1, -1, -1,
242 -1, -1, -1, -1, -1, -1, -1, -1,
243 -1, -1, -1, -1, -1, -1, -1, -1,
244 -1, -1, -1, -1, -1, -1, -1, -1,
245 /* branch registers */
246 PT_B0,
247 PT_B1,
248 PT_B2,
249 PT_B3,
250 PT_B4,
251 PT_B5,
252 PT_B6,
253 PT_B7,
254 /* virtual frame pointer and virtual return address pointer */
255 -1, -1,
256 /* other registers */
257 PT_PR,
258 PT_CR_IIP, /* ip */
259 PT_CR_IPSR, /* psr */
260 PT_CFM, /* cfm */
261 /* kernel registers not visible via ptrace interface (?) */
262 -1, -1, -1, -1, -1, -1, -1, -1,
263 /* hole */
264 -1, -1, -1, -1, -1, -1, -1, -1,
265 PT_AR_RSC,
266 PT_AR_BSP,
267 PT_AR_BSPSTORE,
268 PT_AR_RNAT,
269 -1,
270 -1, /* Not available: FCR, IA32 floating control register */
271 -1, -1,
272 -1, /* Not available: EFLAG */
273 -1, /* Not available: CSD */
274 -1, /* Not available: SSD */
275 -1, /* Not available: CFLG */
276 -1, /* Not available: FSR */
277 -1, /* Not available: FIR */
278 -1, /* Not available: FDR */
279 -1,
280 PT_AR_CCV,
281 -1, -1, -1,
282 PT_AR_UNAT,
283 -1, -1, -1,
284 PT_AR_FPSR,
285 -1, -1, -1,
286 -1, /* Not available: ITC */
287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
288 -1, -1, -1, -1, -1, -1, -1, -1, -1,
289 PT_AR_PFS,
290 PT_AR_LC,
291 PT_AR_EC,
292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
296 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
298 -1,
299 };
300
301 bool
302 ia64_target::low_cannot_store_register (int regno)
303 {
304 return false;
305 }
306
307 bool
308 ia64_target::low_cannot_fetch_register (int regno)
309 {
310 return false;
311 }
312
313 /* GDB register numbers. */
314 #define IA64_GR0_REGNUM 0
315 #define IA64_FR0_REGNUM 128
316 #define IA64_FR1_REGNUM 129
317
318 bool
319 ia64_target::low_fetch_register (regcache *regcache, int regnum)
320 {
321 /* r0 cannot be fetched but is always zero. */
322 if (regnum == IA64_GR0_REGNUM)
323 {
324 const gdb_byte zero[8] = { 0 };
325
326 gdb_assert (sizeof (zero) == register_size (regcache->tdesc, regnum));
327 supply_register (regcache, regnum, zero);
328 return true;
329 }
330
331 /* fr0 cannot be fetched but is always zero. */
332 if (regnum == IA64_FR0_REGNUM)
333 {
334 const gdb_byte f_zero[16] = { 0 };
335
336 gdb_assert (sizeof (f_zero) == register_size (regcache->tdesc, regnum));
337 supply_register (regcache, regnum, f_zero);
338 return true;
339 }
340
341 /* fr1 cannot be fetched but is always one (1.0). */
342 if (regnum == IA64_FR1_REGNUM)
343 {
344 const gdb_byte f_one[16] =
345 { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
346
347 gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum));
348 supply_register (regcache, regnum, f_one);
349 return true;
350 }
351
352 return false;
353 }
354
355 static struct usrregs_info ia64_usrregs_info =
356 {
357 ia64_num_regs,
358 ia64_regmap,
359 };
360
361 static struct regs_info myregs_info =
362 {
363 NULL, /* regset_bitmap */
364 &ia64_usrregs_info
365 };
366
367 const regs_info *
368 ia64_target::get_regs_info ()
369 {
370 return &myregs_info;
371 }
372
373 void
374 ia64_target::low_arch_setup ()
375 {
376 current_process ()->tdesc = tdesc_ia64;
377 }
378
379
380 struct linux_target_ops the_low_target = {
381 };
382
383 /* The linux target ops object. */
384
385 linux_process_target *the_linux_target = &the_ia64_target;
386
387 void
388 initialize_low_arch (void)
389 {
390 init_registers_ia64 ();
391 }
This page took 0.046811 seconds and 5 git commands to generate.