AArch64: View the pseudo V registers as vectors
[deliverable/binutils-gdb.git] / gdb / aarch64-linux-tdep.c
CommitLineData
1ae3db19
MS
1/* Target-dependent code for GNU/Linux AArch64.
2
42a4f53d 3 Copyright (C) 2009-2019 Free Software Foundation, Inc.
1ae3db19
MS
4 Contributed by ARM Ltd.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#include "defs.h"
22
23#include "gdbarch.h"
b6542f81 24#include "arch-utils.h"
1ae3db19
MS
25#include "glibc-tdep.h"
26#include "linux-tdep.h"
27#include "aarch64-tdep.h"
28#include "aarch64-linux-tdep.h"
29#include "osabi.h"
30#include "solib-svr4.h"
31#include "symtab.h"
32#include "tramp-frame.h"
33#include "trad-frame.h"
34
35#include "inferior.h"
36#include "regcache.h"
37#include "regset.h"
38
08248ca9
SDJ
39#include "cli/cli-utils.h"
40#include "stap-probe.h"
41#include "parser-defs.h"
42#include "user-regs.h"
f68f11b7 43#include "xml-syscall.h"
08248ca9
SDJ
44#include <ctype.h>
45
99afc88b
OJ
46#include "record-full.h"
47#include "linux-record.h"
cd3af38d
JW
48#include "auxv.h"
49#include "elf/common.h"
99afc88b 50
1ae3db19
MS
51/* Signal frame handling.
52
f2205de0
HZ
53 +------------+ ^
54 | saved lr | |
55 +->| saved fp |--+
56 | | |
57 | | |
58 | +------------+
59 | | saved lr |
60 +--| saved fp |
61 ^ | |
62 | | |
63 | +------------+
64 ^ | |
65 | | signal |
66 | | | SIGTRAMP_FRAME (struct rt_sigframe)
67 | | saved regs |
68 +--| saved sp |--> interrupted_sp
69 | | saved pc |--> interrupted_pc
70 | | |
71 | +------------+
72 | | saved lr |--> default_restorer (movz x8, NR_sys_rt_sigreturn; svc 0)
73 +--| saved fp |<- FP
74 | | NORMAL_FRAME
75 | |<- SP
76 +------------+
1ae3db19
MS
77
78 On signal delivery, the kernel will create a signal handler stack
79 frame and setup the return address in LR to point at restorer stub.
80 The signal stack frame is defined by:
81
82 struct rt_sigframe
83 {
84 siginfo_t info;
85 struct ucontext uc;
86 };
87
1ae3db19
MS
88 The ucontext has the following form:
89 struct ucontext
90 {
91 unsigned long uc_flags;
92 struct ucontext *uc_link;
93 stack_t uc_stack;
94 sigset_t uc_sigmask;
95 struct sigcontext uc_mcontext;
96 };
97
1ae3db19
MS
98 struct sigcontext
99 {
100 unsigned long fault_address;
101 unsigned long regs[31];
102 unsigned long sp; / * 31 * /
103 unsigned long pc; / * 32 * /
104 unsigned long pstate; / * 33 * /
105 __u8 __reserved[4096]
106 };
107
05c71722
AH
108 The reserved space in sigcontext contains additional structures, each starting
109 with a aarch64_ctx, which specifies a unique identifier and the total size of
110 the structure. The final structure in reserved will start will a null
111 aarch64_ctx. The penultimate entry in reserved may be a extra_context which
112 then points to a further block of reserved space.
113
114 struct aarch64_ctx {
115 u32 magic;
116 u32 size;
117 };
118
1ae3db19
MS
119 The restorer stub will always have the form:
120
121 d28015a8 movz x8, #0xad
122 d4000001 svc #0x0
123
f2205de0
HZ
124 This is a system call sys_rt_sigreturn.
125
1ae3db19
MS
126 We detect signal frames by snooping the return code for the restorer
127 instruction sequence.
128
129 The handler then needs to recover the saved register set from
130 ucontext.uc_mcontext. */
131
132/* These magic numbers need to reflect the layout of the kernel
133 defined struct rt_sigframe and ucontext. */
134#define AARCH64_SIGCONTEXT_REG_SIZE 8
135#define AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET 128
136#define AARCH64_UCONTEXT_SIGCONTEXT_OFFSET 176
137#define AARCH64_SIGCONTEXT_XO_OFFSET 8
05c71722
AH
138#define AARCH64_SIGCONTEXT_RESERVED_OFFSET 288
139
74b3c713
AH
140#define AARCH64_SIGCONTEXT_RESERVED_SIZE 4096
141
05c71722
AH
142/* Unique identifiers that may be used for aarch64_ctx.magic. */
143#define AARCH64_EXTRA_MAGIC 0x45585401
144#define AARCH64_FPSIMD_MAGIC 0x46508001
145#define AARCH64_SVE_MAGIC 0x53564501
146
147/* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */
148#define AARCH64_EXTRA_DATAP_OFFSET 8
149
150/* Defines for the fpsimd that follows an AARCH64_FPSIMD_MAGIC. */
151#define AARCH64_FPSIMD_FPSR_OFFSET 8
152#define AARCH64_FPSIMD_FPCR_OFFSET 12
153#define AARCH64_FPSIMD_V0_OFFSET 16
154#define AARCH64_FPSIMD_VREG_SIZE 16
155
156/* Defines for the sve structure that follows an AARCH64_SVE_MAGIC. */
157#define AARCH64_SVE_CONTEXT_VL_OFFSET 8
158#define AARCH64_SVE_CONTEXT_REGS_OFFSET 16
159#define AARCH64_SVE_CONTEXT_P_REGS_OFFSET(vq) (32 * vq * 16)
160#define AARCH64_SVE_CONTEXT_FFR_OFFSET(vq) \
161 (AARCH64_SVE_CONTEXT_P_REGS_OFFSET (vq) + (16 * vq * 2))
162#define AARCH64_SVE_CONTEXT_SIZE(vq) \
163 (AARCH64_SVE_CONTEXT_FFR_OFFSET (vq) + (vq * 2))
164
165
166/* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the
167 size, or return 0 on error. */
168
169static uint32_t
170read_aarch64_ctx (CORE_ADDR ctx_addr, enum bfd_endian byte_order,
171 uint32_t *size)
172{
173 uint32_t magic = 0;
174 gdb_byte buf[4];
175
176 if (target_read_memory (ctx_addr, buf, 4) != 0)
177 return 0;
178 magic = extract_unsigned_integer (buf, 4, byte_order);
179
180 if (target_read_memory (ctx_addr + 4, buf, 4) != 0)
181 return 0;
182 *size = extract_unsigned_integer (buf, 4, byte_order);
183
184 return magic;
185}
1ae3db19
MS
186
187/* Implement the "init" method of struct tramp_frame. */
188
189static void
190aarch64_linux_sigframe_init (const struct tramp_frame *self,
191 struct frame_info *this_frame,
192 struct trad_frame_cache *this_cache,
193 CORE_ADDR func)
194{
05c71722
AH
195 struct gdbarch *gdbarch = get_frame_arch (this_frame);
196 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
197 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1ae3db19 198 CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
05c71722
AH
199 CORE_ADDR sigcontext_addr = (sp + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET
200 + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET );
201 CORE_ADDR section = sigcontext_addr + AARCH64_SIGCONTEXT_RESERVED_OFFSET;
74b3c713 202 CORE_ADDR section_end = section + AARCH64_SIGCONTEXT_RESERVED_SIZE;
05c71722
AH
203 CORE_ADDR fpsimd = 0;
204 CORE_ADDR sve_regs = 0;
205 uint32_t size, magic;
74b3c713 206 bool extra_found = false;
05c71722
AH
207 int num_regs = gdbarch_num_regs (gdbarch);
208
209 /* Read in the integer registers. */
1ae3db19 210
05c71722 211 for (int i = 0; i < 31; i++)
1ae3db19
MS
212 {
213 trad_frame_set_reg_addr (this_cache,
214 AARCH64_X0_REGNUM + i,
215 sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
05c71722 216 + i * AARCH64_SIGCONTEXT_REG_SIZE);
1ae3db19 217 }
f2205de0
HZ
218 trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
219 sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
220 + 31 * AARCH64_SIGCONTEXT_REG_SIZE);
221 trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
222 sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
223 + 32 * AARCH64_SIGCONTEXT_REG_SIZE);
224
74b3c713
AH
225 /* Search for the FP and SVE sections, stopping at null. */
226 while ((magic = read_aarch64_ctx (section, byte_order, &size)) != 0
227 && size != 0)
05c71722
AH
228 {
229 switch (magic)
230 {
231 case AARCH64_FPSIMD_MAGIC:
232 fpsimd = section;
233 section += size;
234 break;
235
236 case AARCH64_SVE_MAGIC:
237 {
238 /* Check if the section is followed by a full SVE dump, and set
239 sve_regs if it is. */
240 gdb_byte buf[4];
241 uint16_t vq;
242
243 if (!tdep->has_sve ())
244 break;
245
246 if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET,
247 buf, 2) != 0)
248 {
249 section += size;
250 break;
251 }
252 vq = sve_vq_from_vl (extract_unsigned_integer (buf, 2, byte_order));
253
254 if (vq != tdep->vq)
2398abf8
TT
255 error (_("Invalid vector length in signal frame %d vs %s."), vq,
256 pulongest (tdep->vq));
05c71722
AH
257
258 if (size >= AARCH64_SVE_CONTEXT_SIZE (vq))
259 sve_regs = section + AARCH64_SVE_CONTEXT_REGS_OFFSET;
260
261 section += size;
262 break;
263 }
264
265 case AARCH64_EXTRA_MAGIC:
266 {
267 /* Extra is always the last valid section in reserved and points to
268 an additional block of memory filled with more sections. Reset
269 the address to the extra section and continue looking for more
270 structures. */
271 gdb_byte buf[8];
272
273 if (target_read_memory (section + AARCH64_EXTRA_DATAP_OFFSET,
274 buf, 8) != 0)
275 {
276 section += size;
277 break;
278 }
279
280 section = extract_unsigned_integer (buf, 8, byte_order);
74b3c713 281 extra_found = true;
05c71722
AH
282 break;
283 }
284
285 default:
74b3c713 286 section += size;
05c71722
AH
287 break;
288 }
74b3c713
AH
289
290 /* Prevent searching past the end of the reserved section. The extra
291 section does not have a hard coded limit - we have to rely on it ending
292 with nulls. */
293 if (!extra_found && section > section_end)
294 break;
05c71722
AH
295 }
296
297 if (sve_regs != 0)
298 {
299 CORE_ADDR offset;
300
301 for (int i = 0; i < 32; i++)
302 {
303 offset = sve_regs + (i * tdep->vq * 16);
304 trad_frame_set_reg_addr (this_cache, AARCH64_SVE_Z0_REGNUM + i,
305 offset);
306 trad_frame_set_reg_addr (this_cache,
307 num_regs + AARCH64_SVE_V0_REGNUM + i,
308 offset);
309 trad_frame_set_reg_addr (this_cache, num_regs + AARCH64_Q0_REGNUM + i,
310 offset);
311 trad_frame_set_reg_addr (this_cache, num_regs + AARCH64_D0_REGNUM + i,
312 offset);
313 trad_frame_set_reg_addr (this_cache, num_regs + AARCH64_S0_REGNUM + i,
314 offset);
315 trad_frame_set_reg_addr (this_cache, num_regs + AARCH64_H0_REGNUM + i,
316 offset);
317 trad_frame_set_reg_addr (this_cache, num_regs + AARCH64_B0_REGNUM + i,
318 offset);
319 }
320
321 offset = sve_regs + AARCH64_SVE_CONTEXT_P_REGS_OFFSET (tdep->vq);
322 for (int i = 0; i < 16; i++)
323 trad_frame_set_reg_addr (this_cache, AARCH64_SVE_P0_REGNUM + i,
324 offset + (i * tdep->vq * 2));
325
326 offset = sve_regs + AARCH64_SVE_CONTEXT_FFR_OFFSET (tdep->vq);
327 trad_frame_set_reg_addr (this_cache, AARCH64_SVE_FFR_REGNUM, offset);
328 }
329
330 if (fpsimd != 0)
331 {
332 trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM,
333 fpsimd + AARCH64_FPSIMD_FPSR_OFFSET);
334 trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM,
335 fpsimd + AARCH64_FPSIMD_FPCR_OFFSET);
336
337 /* If there was no SVE section then set up the V registers. */
338 if (sve_regs == 0)
339 for (int i = 0; i < 32; i++)
340 {
341 CORE_ADDR offset = (fpsimd + AARCH64_FPSIMD_V0_OFFSET
342 + (i * AARCH64_FPSIMD_VREG_SIZE));
343
344 trad_frame_set_reg_addr (this_cache, AARCH64_V0_REGNUM + i, offset);
345 trad_frame_set_reg_addr (this_cache,
346 num_regs + AARCH64_Q0_REGNUM + i, offset);
347 trad_frame_set_reg_addr (this_cache,
348 num_regs + AARCH64_D0_REGNUM + i, offset);
349 trad_frame_set_reg_addr (this_cache,
350 num_regs + AARCH64_S0_REGNUM + i, offset);
351 trad_frame_set_reg_addr (this_cache,
352 num_regs + AARCH64_H0_REGNUM + i, offset);
353 trad_frame_set_reg_addr (this_cache,
354 num_regs + AARCH64_B0_REGNUM + i, offset);
355 if (tdep->has_sve ())
356 trad_frame_set_reg_addr (this_cache,
357 num_regs + AARCH64_SVE_V0_REGNUM + i,
358 offset);
359 }
360 }
361
f2205de0 362 trad_frame_set_id (this_cache, frame_id_build (sp, func));
1ae3db19
MS
363}
364
365static const struct tramp_frame aarch64_linux_rt_sigframe =
366{
367 SIGTRAMP_FRAME,
368 4,
369 {
370 /* movz x8, 0x8b (S=1,o=10,h=0,i=0x8b,r=8)
371 Soo1 0010 1hhi iiii iiii iiii iiir rrrr */
7bc02706 372 {0xd2801168, ULONGEST_MAX},
1ae3db19
MS
373
374 /* svc 0x0 (o=0, l=1)
375 1101 0100 oooi iiii iiii iiii iii0 00ll */
7bc02706
TT
376 {0xd4000001, ULONGEST_MAX},
377 {TRAMP_SENTINEL_INSN, ULONGEST_MAX}
1ae3db19
MS
378 },
379 aarch64_linux_sigframe_init
380};
381
d4d793bf 382/* Register maps. */
1ae3db19 383
d4d793bf
AA
384static const struct regcache_map_entry aarch64_linux_gregmap[] =
385 {
386 { 31, AARCH64_X0_REGNUM, 8 }, /* x0 ... x30 */
387 { 1, AARCH64_SP_REGNUM, 8 },
388 { 1, AARCH64_PC_REGNUM, 8 },
389 { 1, AARCH64_CPSR_REGNUM, 8 },
390 { 0 }
391 };
1ae3db19 392
d4d793bf
AA
393static const struct regcache_map_entry aarch64_linux_fpregmap[] =
394 {
395 { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
396 { 1, AARCH64_FPSR_REGNUM, 4 },
397 { 1, AARCH64_FPCR_REGNUM, 4 },
398 { 0 }
399 };
1ae3db19 400
d4d793bf 401/* Register set definitions. */
a069a2bd 402
d4d793bf 403const struct regset aarch64_linux_gregset =
a069a2bd 404 {
d4d793bf
AA
405 aarch64_linux_gregmap,
406 regcache_supply_regset, regcache_collect_regset
a069a2bd
AA
407 };
408
d4d793bf 409const struct regset aarch64_linux_fpregset =
a069a2bd 410 {
d4d793bf
AA
411 aarch64_linux_fpregmap,
412 regcache_supply_regset, regcache_collect_regset
a069a2bd
AA
413 };
414
b7fd65b9
AH
415/* The fields in an SVE header at the start of a SVE regset. */
416
417#define SVE_HEADER_SIZE_LENGTH 4
418#define SVE_HEADER_MAX_SIZE_LENGTH 4
419#define SVE_HEADER_VL_LENGTH 2
420#define SVE_HEADER_MAX_VL_LENGTH 2
421#define SVE_HEADER_FLAGS_LENGTH 2
422#define SVE_HEADER_RESERVED_LENGTH 2
423
424#define SVE_HEADER_SIZE_OFFSET 0
425#define SVE_HEADER_MAX_SIZE_OFFSET \
426 (SVE_HEADER_SIZE_OFFSET + SVE_HEADER_SIZE_LENGTH)
427#define SVE_HEADER_VL_OFFSET \
428 (SVE_HEADER_MAX_SIZE_OFFSET + SVE_HEADER_MAX_SIZE_LENGTH)
429#define SVE_HEADER_MAX_VL_OFFSET \
430 (SVE_HEADER_VL_OFFSET + SVE_HEADER_VL_LENGTH)
431#define SVE_HEADER_FLAGS_OFFSET \
432 (SVE_HEADER_MAX_VL_OFFSET + SVE_HEADER_MAX_VL_LENGTH)
433#define SVE_HEADER_RESERVED_OFFSET \
434 (SVE_HEADER_FLAGS_OFFSET + SVE_HEADER_FLAGS_LENGTH)
435#define SVE_HEADER_SIZE \
436 (SVE_HEADER_RESERVED_OFFSET + SVE_HEADER_RESERVED_LENGTH)
437
0c76e06d
AH
438#define SVE_HEADER_FLAG_SVE 1
439
b7fd65b9
AH
440/* Get VQ value from SVE section in the core dump. */
441
442static uint64_t
443aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd)
444{
445 gdb_byte header[SVE_HEADER_SIZE];
446 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
447 asection *sve_section = bfd_get_section_by_name (abfd, ".reg-aarch-sve");
448
449 if (sve_section == nullptr)
450 {
451 /* No SVE state. */
452 return 0;
453 }
454
455 size_t size = bfd_section_size (abfd, sve_section);
456
457 /* Check extended state size. */
458 if (size < SVE_HEADER_SIZE)
459 {
460 warning (_("'.reg-aarch-sve' section in core file too small."));
461 return 0;
462 }
463
464 if (!bfd_get_section_contents (abfd, sve_section, header, 0, SVE_HEADER_SIZE))
465 {
466 warning (_("Couldn't read sve header from "
467 "'.reg-aarch-sve' section in core file."));
468 return 0;
469 }
470
471 uint64_t vl = extract_unsigned_integer (header + SVE_HEADER_VL_OFFSET,
472 SVE_HEADER_VL_LENGTH, byte_order);
473 uint64_t vq = sve_vq_from_vl (vl);
474
475 if (vq > AARCH64_MAX_SVE_VQ)
476 {
477 warning (_("SVE Vector length in core file not supported by this version"
49514353 478 " of GDB. (VQ=%s)"), pulongest (vq));
b7fd65b9
AH
479 return 0;
480 }
481 else if (vq == 0)
482 {
49514353
TT
483 warning (_("SVE Vector length in core file is invalid. (VQ=%s"),
484 pulongest (vq));
b7fd65b9
AH
485 return 0;
486 }
487
488 return vq;
489}
490
0c76e06d
AH
491/* Supply register REGNUM from BUF to REGCACHE, using the register map
492 in REGSET. If REGNUM is -1, do this for all registers in REGSET.
493 If BUF is NULL, set the registers to "unavailable" status. */
494
495static void
496aarch64_linux_supply_sve_regset (const struct regset *regset,
497 struct regcache *regcache,
498 int regnum, const void *buf, size_t size)
499{
500 gdb_byte *header = (gdb_byte *) buf;
501 struct gdbarch *gdbarch = regcache->arch ();
502 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
503
504 if (buf == nullptr)
505 return regcache->supply_regset (regset, regnum, nullptr, size);
506 gdb_assert (size > SVE_HEADER_SIZE);
507
508 /* BUF contains an SVE header followed by a register dump of either the
509 passed in SVE regset or a NEON fpregset. */
510
511 /* Extract required fields from the header. */
0c0a40e0 512 ULONGEST vl = extract_unsigned_integer (header + SVE_HEADER_VL_OFFSET,
0c76e06d
AH
513 SVE_HEADER_VL_LENGTH, byte_order);
514 uint16_t flags = extract_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET,
515 SVE_HEADER_FLAGS_LENGTH,
516 byte_order);
517
518 if (regnum == -1 || regnum == AARCH64_SVE_VG_REGNUM)
519 {
520 gdb_byte vg_target[8];
521 store_integer ((gdb_byte *)&vg_target, sizeof (uint64_t), byte_order,
522 sve_vg_from_vl (vl));
523 regcache->raw_supply (AARCH64_SVE_VG_REGNUM, &vg_target);
524 }
525
526 if (flags & SVE_HEADER_FLAG_SVE)
527 {
528 /* Register dump is a SVE structure. */
529 regcache->supply_regset (regset, regnum,
530 (gdb_byte *) buf + SVE_HEADER_SIZE,
531 size - SVE_HEADER_SIZE);
532 }
533 else
534 {
535 /* Register dump is a fpsimd structure. First clear the SVE
536 registers. */
537 for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++)
538 regcache->raw_supply_zeroed (AARCH64_SVE_Z0_REGNUM + i);
539 for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++)
540 regcache->raw_supply_zeroed (AARCH64_SVE_P0_REGNUM + i);
541 regcache->raw_supply_zeroed (AARCH64_SVE_FFR_REGNUM);
542
543 /* Then supply the fpsimd registers. */
544 regcache->supply_regset (&aarch64_linux_fpregset, regnum,
545 (gdb_byte *) buf + SVE_HEADER_SIZE,
546 size - SVE_HEADER_SIZE);
547 }
548}
549
550/* Collect register REGNUM from REGCACHE to BUF, using the register
551 map in REGSET. If REGNUM is -1, do this for all registers in
552 REGSET. */
553
554static void
555aarch64_linux_collect_sve_regset (const struct regset *regset,
556 const struct regcache *regcache,
557 int regnum, void *buf, size_t size)
558{
559 gdb_byte *header = (gdb_byte *) buf;
560 struct gdbarch *gdbarch = regcache->arch ();
561 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
562 uint64_t vq = gdbarch_tdep (gdbarch)->vq;
563
564 gdb_assert (buf != NULL);
565 gdb_assert (size > SVE_HEADER_SIZE);
566
567 /* BUF starts with a SVE header prior to the register dump. */
568
569 store_unsigned_integer (header + SVE_HEADER_SIZE_OFFSET,
570 SVE_HEADER_SIZE_LENGTH, byte_order, size);
571 store_unsigned_integer (header + SVE_HEADER_MAX_SIZE_OFFSET,
572 SVE_HEADER_MAX_SIZE_LENGTH, byte_order, size);
573 store_unsigned_integer (header + SVE_HEADER_VL_OFFSET, SVE_HEADER_VL_LENGTH,
574 byte_order, sve_vl_from_vq (vq));
575 store_unsigned_integer (header + SVE_HEADER_MAX_VL_OFFSET,
576 SVE_HEADER_MAX_VL_LENGTH, byte_order,
577 sve_vl_from_vq (vq));
578 store_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET,
579 SVE_HEADER_FLAGS_LENGTH, byte_order,
580 SVE_HEADER_FLAG_SVE);
581 store_unsigned_integer (header + SVE_HEADER_RESERVED_OFFSET,
582 SVE_HEADER_RESERVED_LENGTH, byte_order, 0);
583
584 /* The SVE register dump follows. */
585 regcache->collect_regset (regset, regnum, (gdb_byte *) buf + SVE_HEADER_SIZE,
586 size - SVE_HEADER_SIZE);
587}
588
1ae3db19
MS
589/* Implement the "regset_from_core_section" gdbarch method. */
590
4108500a
AA
591static void
592aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
593 iterate_over_regset_sections_cb *cb,
594 void *cb_data,
595 const struct regcache *regcache)
1ae3db19 596{
0c76e06d
AH
597 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
598
a616bb94
AH
599 cb (".reg", AARCH64_LINUX_SIZEOF_GREGSET, AARCH64_LINUX_SIZEOF_GREGSET,
600 &aarch64_linux_gregset, NULL, cb_data);
0c76e06d
AH
601
602 if (tdep->has_sve ())
603 {
604 /* Create this on the fly in order to handle vector register sizes. */
605 const struct regcache_map_entry sve_regmap[] =
606 {
1885053b
TT
607 { 32, AARCH64_SVE_Z0_REGNUM, (int) (tdep->vq * 16) },
608 { 16, AARCH64_SVE_P0_REGNUM, (int) (tdep->vq * 16 / 8) },
0c76e06d
AH
609 { 1, AARCH64_SVE_FFR_REGNUM, 4 },
610 { 1, AARCH64_FPSR_REGNUM, 4 },
611 { 1, AARCH64_FPCR_REGNUM, 4 },
612 { 0 }
613 };
614
615 const struct regset aarch64_linux_sve_regset =
616 {
617 sve_regmap,
618 aarch64_linux_supply_sve_regset, aarch64_linux_collect_sve_regset,
619 REGSET_VARIABLE_SIZE
620 };
621
622 cb (".reg-aarch-sve",
623 SVE_HEADER_SIZE + regcache_map_entry_size (aarch64_linux_fpregmap),
624 SVE_HEADER_SIZE + regcache_map_entry_size (sve_regmap),
625 &aarch64_linux_sve_regset, "SVE registers", cb_data);
626 }
627 else
628 cb (".reg2", AARCH64_LINUX_SIZEOF_FPREGSET, AARCH64_LINUX_SIZEOF_FPREGSET,
629 &aarch64_linux_fpregset, NULL, cb_data);
59c28372
AH
630
631
632 if (tdep->has_pauth ())
633 {
634 /* Create this on the fly in order to handle the variable location. */
635 const struct regcache_map_entry pauth_regmap[] =
636 {
637 { 2, AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base), 8},
638 { 0 }
639 };
640
641 const struct regset aarch64_linux_pauth_regset =
642 {
643 pauth_regmap, regcache_supply_regset, regcache_collect_regset
644 };
645
646 cb (".reg-aarch-pauth", AARCH64_LINUX_SIZEOF_PAUTH,
647 AARCH64_LINUX_SIZEOF_PAUTH, &aarch64_linux_pauth_regset,
648 "pauth registers", cb_data);
649 }
1ae3db19
MS
650}
651
b7fd65b9 652/* Implement the "core_read_description" gdbarch method. */
cd3af38d
JW
653
654static const struct target_desc *
655aarch64_linux_core_read_description (struct gdbarch *gdbarch,
656 struct target_ops *target, bfd *abfd)
657{
0f83012e 658 CORE_ADDR hwcap = linux_get_hwcap (target);
cd3af38d 659
6dc0ebde 660 return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd),
0f83012e 661 hwcap & AARCH64_HWCAP_PACA);
cd3af38d
JW
662}
663
08248ca9
SDJ
664/* Implementation of `gdbarch_stap_is_single_operand', as defined in
665 gdbarch.h. */
666
667static int
668aarch64_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
669{
670 return (*s == '#' || isdigit (*s) /* Literal number. */
671 || *s == '[' /* Register indirection. */
672 || isalpha (*s)); /* Register value. */
673}
674
675/* This routine is used to parse a special token in AArch64's assembly.
676
677 The special tokens parsed by it are:
678
679 - Register displacement (e.g, [fp, #-8])
680
681 It returns one if the special token has been parsed successfully,
682 or zero if the current token is not considered special. */
683
684static int
685aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
686 struct stap_parse_info *p)
687{
688 if (*p->arg == '[')
689 {
690 /* Temporary holder for lookahead. */
691 const char *tmp = p->arg;
692 char *endp;
693 /* Used to save the register name. */
694 const char *start;
695 char *regname;
696 int len;
697 int got_minus = 0;
698 long displacement;
699 struct stoken str;
700
701 ++tmp;
702 start = tmp;
703
704 /* Register name. */
705 while (isalnum (*tmp))
706 ++tmp;
707
708 if (*tmp != ',')
709 return 0;
710
711 len = tmp - start;
224c3ddb 712 regname = (char *) alloca (len + 2);
08248ca9
SDJ
713
714 strncpy (regname, start, len);
715 regname[len] = '\0';
716
717 if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
718 error (_("Invalid register name `%s' on expression `%s'."),
719 regname, p->saved_arg);
720
721 ++tmp;
f1735a53 722 tmp = skip_spaces (tmp);
08248ca9
SDJ
723 /* Now we expect a number. It can begin with '#' or simply
724 a digit. */
725 if (*tmp == '#')
726 ++tmp;
727
728 if (*tmp == '-')
729 {
730 ++tmp;
731 got_minus = 1;
732 }
733 else if (*tmp == '+')
734 ++tmp;
735
736 if (!isdigit (*tmp))
737 return 0;
738
739 displacement = strtol (tmp, &endp, 10);
740 tmp = endp;
741
742 /* Skipping last `]'. */
743 if (*tmp++ != ']')
744 return 0;
745
746 /* The displacement. */
410a0ff2
SDJ
747 write_exp_elt_opcode (&p->pstate, OP_LONG);
748 write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
749 write_exp_elt_longcst (&p->pstate, displacement);
750 write_exp_elt_opcode (&p->pstate, OP_LONG);
08248ca9 751 if (got_minus)
410a0ff2 752 write_exp_elt_opcode (&p->pstate, UNOP_NEG);
08248ca9
SDJ
753
754 /* The register name. */
410a0ff2 755 write_exp_elt_opcode (&p->pstate, OP_REGISTER);
08248ca9
SDJ
756 str.ptr = regname;
757 str.length = len;
410a0ff2
SDJ
758 write_exp_string (&p->pstate, str);
759 write_exp_elt_opcode (&p->pstate, OP_REGISTER);
08248ca9 760
410a0ff2 761 write_exp_elt_opcode (&p->pstate, BINOP_ADD);
08248ca9
SDJ
762
763 /* Casting to the expected type. */
410a0ff2
SDJ
764 write_exp_elt_opcode (&p->pstate, UNOP_CAST);
765 write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
766 write_exp_elt_opcode (&p->pstate, UNOP_CAST);
08248ca9 767
410a0ff2 768 write_exp_elt_opcode (&p->pstate, UNOP_IND);
08248ca9
SDJ
769
770 p->arg = tmp;
771 }
772 else
773 return 0;
774
775 return 1;
776}
777
99afc88b
OJ
778/* AArch64 process record-replay constructs: syscall, signal etc. */
779
780struct linux_record_tdep aarch64_linux_record_tdep;
781
782/* Enum that defines the AArch64 linux specific syscall identifiers used for
783 process record/replay. */
784
785enum aarch64_syscall {
786 aarch64_sys_io_setup = 0,
787 aarch64_sys_io_destroy = 1,
788 aarch64_sys_io_submit = 2,
789 aarch64_sys_io_cancel = 3,
790 aarch64_sys_io_getevents = 4,
791 aarch64_sys_setxattr = 5,
792 aarch64_sys_lsetxattr = 6,
793 aarch64_sys_fsetxattr = 7,
794 aarch64_sys_getxattr = 8,
795 aarch64_sys_lgetxattr = 9,
796 aarch64_sys_fgetxattr = 10,
797 aarch64_sys_listxattr = 11,
798 aarch64_sys_llistxattr = 12,
799 aarch64_sys_flistxattr = 13,
800 aarch64_sys_removexattr = 14,
801 aarch64_sys_lremovexattr = 15,
802 aarch64_sys_fremovexattr = 16,
803 aarch64_sys_getcwd = 17,
804 aarch64_sys_lookup_dcookie = 18,
805 aarch64_sys_eventfd2 = 19,
806 aarch64_sys_epoll_create1 = 20,
807 aarch64_sys_epoll_ctl = 21,
808 aarch64_sys_epoll_pwait = 22,
809 aarch64_sys_dup = 23,
810 aarch64_sys_dup3 = 24,
811 aarch64_sys_fcntl = 25,
812 aarch64_sys_inotify_init1 = 26,
813 aarch64_sys_inotify_add_watch = 27,
814 aarch64_sys_inotify_rm_watch = 28,
815 aarch64_sys_ioctl = 29,
816 aarch64_sys_ioprio_set = 30,
817 aarch64_sys_ioprio_get = 31,
818 aarch64_sys_flock = 32,
c955ae73
YQ
819 aarch64_sys_mknodat = 33,
820 aarch64_sys_mkdirat = 34,
821 aarch64_sys_unlinkat = 35,
822 aarch64_sys_symlinkat = 36,
823 aarch64_sys_linkat = 37,
824 aarch64_sys_renameat = 38,
99afc88b
OJ
825 aarch64_sys_umount2 = 39,
826 aarch64_sys_mount = 40,
827 aarch64_sys_pivot_root = 41,
828 aarch64_sys_nfsservctl = 42,
829 aarch64_sys_statfs = 43,
830 aarch64_sys_fstatfs = 44,
831 aarch64_sys_truncate = 45,
832 aarch64_sys_ftruncate = 46,
833 aarch64_sys_fallocate = 47,
c955ae73 834 aarch64_sys_faccessat = 48,
99afc88b
OJ
835 aarch64_sys_chdir = 49,
836 aarch64_sys_fchdir = 50,
837 aarch64_sys_chroot = 51,
838 aarch64_sys_fchmod = 52,
839 aarch64_sys_fchmodat = 53,
840 aarch64_sys_fchownat = 54,
841 aarch64_sys_fchown = 55,
c955ae73 842 aarch64_sys_openat = 56,
99afc88b
OJ
843 aarch64_sys_close = 57,
844 aarch64_sys_vhangup = 58,
845 aarch64_sys_pipe2 = 59,
846 aarch64_sys_quotactl = 60,
847 aarch64_sys_getdents64 = 61,
848 aarch64_sys_lseek = 62,
849 aarch64_sys_read = 63,
850 aarch64_sys_write = 64,
851 aarch64_sys_readv = 65,
852 aarch64_sys_writev = 66,
853 aarch64_sys_pread64 = 67,
854 aarch64_sys_pwrite64 = 68,
855 aarch64_sys_preadv = 69,
856 aarch64_sys_pwritev = 70,
857 aarch64_sys_sendfile = 71,
858 aarch64_sys_pselect6 = 72,
859 aarch64_sys_ppoll = 73,
860 aarch64_sys_signalfd4 = 74,
861 aarch64_sys_vmsplice = 75,
862 aarch64_sys_splice = 76,
863 aarch64_sys_tee = 77,
c955ae73
YQ
864 aarch64_sys_readlinkat = 78,
865 aarch64_sys_newfstatat = 79,
99afc88b
OJ
866 aarch64_sys_fstat = 80,
867 aarch64_sys_sync = 81,
868 aarch64_sys_fsync = 82,
869 aarch64_sys_fdatasync = 83,
870 aarch64_sys_sync_file_range2 = 84,
871 aarch64_sys_sync_file_range = 84,
872 aarch64_sys_timerfd_create = 85,
873 aarch64_sys_timerfd_settime = 86,
874 aarch64_sys_timerfd_gettime = 87,
875 aarch64_sys_utimensat = 88,
876 aarch64_sys_acct = 89,
877 aarch64_sys_capget = 90,
878 aarch64_sys_capset = 91,
879 aarch64_sys_personality = 92,
880 aarch64_sys_exit = 93,
881 aarch64_sys_exit_group = 94,
882 aarch64_sys_waitid = 95,
883 aarch64_sys_set_tid_address = 96,
884 aarch64_sys_unshare = 97,
885 aarch64_sys_futex = 98,
886 aarch64_sys_set_robust_list = 99,
887 aarch64_sys_get_robust_list = 100,
888 aarch64_sys_nanosleep = 101,
889 aarch64_sys_getitimer = 102,
890 aarch64_sys_setitimer = 103,
891 aarch64_sys_kexec_load = 104,
892 aarch64_sys_init_module = 105,
893 aarch64_sys_delete_module = 106,
894 aarch64_sys_timer_create = 107,
895 aarch64_sys_timer_gettime = 108,
896 aarch64_sys_timer_getoverrun = 109,
897 aarch64_sys_timer_settime = 110,
898 aarch64_sys_timer_delete = 111,
899 aarch64_sys_clock_settime = 112,
900 aarch64_sys_clock_gettime = 113,
901 aarch64_sys_clock_getres = 114,
902 aarch64_sys_clock_nanosleep = 115,
903 aarch64_sys_syslog = 116,
904 aarch64_sys_ptrace = 117,
905 aarch64_sys_sched_setparam = 118,
906 aarch64_sys_sched_setscheduler = 119,
907 aarch64_sys_sched_getscheduler = 120,
908 aarch64_sys_sched_getparam = 121,
909 aarch64_sys_sched_setaffinity = 122,
910 aarch64_sys_sched_getaffinity = 123,
911 aarch64_sys_sched_yield = 124,
912 aarch64_sys_sched_get_priority_max = 125,
913 aarch64_sys_sched_get_priority_min = 126,
914 aarch64_sys_sched_rr_get_interval = 127,
915 aarch64_sys_kill = 129,
916 aarch64_sys_tkill = 130,
917 aarch64_sys_tgkill = 131,
918 aarch64_sys_sigaltstack = 132,
919 aarch64_sys_rt_sigsuspend = 133,
920 aarch64_sys_rt_sigaction = 134,
921 aarch64_sys_rt_sigprocmask = 135,
922 aarch64_sys_rt_sigpending = 136,
923 aarch64_sys_rt_sigtimedwait = 137,
924 aarch64_sys_rt_sigqueueinfo = 138,
925 aarch64_sys_rt_sigreturn = 139,
926 aarch64_sys_setpriority = 140,
927 aarch64_sys_getpriority = 141,
928 aarch64_sys_reboot = 142,
929 aarch64_sys_setregid = 143,
930 aarch64_sys_setgid = 144,
931 aarch64_sys_setreuid = 145,
932 aarch64_sys_setuid = 146,
933 aarch64_sys_setresuid = 147,
934 aarch64_sys_getresuid = 148,
935 aarch64_sys_setresgid = 149,
936 aarch64_sys_getresgid = 150,
937 aarch64_sys_setfsuid = 151,
938 aarch64_sys_setfsgid = 152,
939 aarch64_sys_times = 153,
940 aarch64_sys_setpgid = 154,
941 aarch64_sys_getpgid = 155,
942 aarch64_sys_getsid = 156,
943 aarch64_sys_setsid = 157,
944 aarch64_sys_getgroups = 158,
945 aarch64_sys_setgroups = 159,
946 aarch64_sys_uname = 160,
947 aarch64_sys_sethostname = 161,
948 aarch64_sys_setdomainname = 162,
949 aarch64_sys_getrlimit = 163,
950 aarch64_sys_setrlimit = 164,
951 aarch64_sys_getrusage = 165,
952 aarch64_sys_umask = 166,
953 aarch64_sys_prctl = 167,
954 aarch64_sys_getcpu = 168,
955 aarch64_sys_gettimeofday = 169,
956 aarch64_sys_settimeofday = 170,
957 aarch64_sys_adjtimex = 171,
958 aarch64_sys_getpid = 172,
959 aarch64_sys_getppid = 173,
960 aarch64_sys_getuid = 174,
961 aarch64_sys_geteuid = 175,
962 aarch64_sys_getgid = 176,
963 aarch64_sys_getegid = 177,
964 aarch64_sys_gettid = 178,
965 aarch64_sys_sysinfo = 179,
966 aarch64_sys_mq_open = 180,
967 aarch64_sys_mq_unlink = 181,
968 aarch64_sys_mq_timedsend = 182,
969 aarch64_sys_mq_timedreceive = 183,
970 aarch64_sys_mq_notify = 184,
971 aarch64_sys_mq_getsetattr = 185,
972 aarch64_sys_msgget = 186,
973 aarch64_sys_msgctl = 187,
974 aarch64_sys_msgrcv = 188,
975 aarch64_sys_msgsnd = 189,
976 aarch64_sys_semget = 190,
977 aarch64_sys_semctl = 191,
978 aarch64_sys_semtimedop = 192,
979 aarch64_sys_semop = 193,
980 aarch64_sys_shmget = 194,
981 aarch64_sys_shmctl = 195,
982 aarch64_sys_shmat = 196,
983 aarch64_sys_shmdt = 197,
984 aarch64_sys_socket = 198,
985 aarch64_sys_socketpair = 199,
986 aarch64_sys_bind = 200,
987 aarch64_sys_listen = 201,
988 aarch64_sys_accept = 202,
989 aarch64_sys_connect = 203,
990 aarch64_sys_getsockname = 204,
991 aarch64_sys_getpeername = 205,
992 aarch64_sys_sendto = 206,
993 aarch64_sys_recvfrom = 207,
994 aarch64_sys_setsockopt = 208,
995 aarch64_sys_getsockopt = 209,
996 aarch64_sys_shutdown = 210,
997 aarch64_sys_sendmsg = 211,
998 aarch64_sys_recvmsg = 212,
999 aarch64_sys_readahead = 213,
1000 aarch64_sys_brk = 214,
1001 aarch64_sys_munmap = 215,
1002 aarch64_sys_mremap = 216,
1003 aarch64_sys_add_key = 217,
1004 aarch64_sys_request_key = 218,
1005 aarch64_sys_keyctl = 219,
1006 aarch64_sys_clone = 220,
1007 aarch64_sys_execve = 221,
1008 aarch64_sys_mmap = 222,
1009 aarch64_sys_fadvise64 = 223,
1010 aarch64_sys_swapon = 224,
1011 aarch64_sys_swapoff = 225,
1012 aarch64_sys_mprotect = 226,
1013 aarch64_sys_msync = 227,
1014 aarch64_sys_mlock = 228,
1015 aarch64_sys_munlock = 229,
1016 aarch64_sys_mlockall = 230,
1017 aarch64_sys_munlockall = 231,
1018 aarch64_sys_mincore = 232,
1019 aarch64_sys_madvise = 233,
1020 aarch64_sys_remap_file_pages = 234,
1021 aarch64_sys_mbind = 235,
1022 aarch64_sys_get_mempolicy = 236,
1023 aarch64_sys_set_mempolicy = 237,
1024 aarch64_sys_migrate_pages = 238,
1025 aarch64_sys_move_pages = 239,
1026 aarch64_sys_rt_tgsigqueueinfo = 240,
1027 aarch64_sys_perf_event_open = 241,
1028 aarch64_sys_accept4 = 242,
1029 aarch64_sys_recvmmsg = 243,
1030 aarch64_sys_wait4 = 260,
1031 aarch64_sys_prlimit64 = 261,
1032 aarch64_sys_fanotify_init = 262,
1033 aarch64_sys_fanotify_mark = 263,
1034 aarch64_sys_name_to_handle_at = 264,
1035 aarch64_sys_open_by_handle_at = 265,
1036 aarch64_sys_clock_adjtime = 266,
1037 aarch64_sys_syncfs = 267,
1038 aarch64_sys_setns = 268,
1039 aarch64_sys_sendmmsg = 269,
1040 aarch64_sys_process_vm_readv = 270,
1041 aarch64_sys_process_vm_writev = 271,
1042 aarch64_sys_kcmp = 272,
1043 aarch64_sys_finit_module = 273,
1044 aarch64_sys_sched_setattr = 274,
1045 aarch64_sys_sched_getattr = 275,
1046};
1047
1048/* aarch64_canonicalize_syscall maps syscall ids from the native AArch64
1049 linux set of syscall ids into a canonical set of syscall ids used by
1050 process record. */
1051
1052static enum gdb_syscall
1053aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number)
1054{
1055#define SYSCALL_MAP(SYSCALL) case aarch64_sys_##SYSCALL: \
1056 return gdb_sys_##SYSCALL
1057
c955ae73
YQ
1058#define UNSUPPORTED_SYSCALL_MAP(SYSCALL) case aarch64_sys_##SYSCALL: \
1059 return gdb_sys_no_syscall
1060
99afc88b
OJ
1061 switch (syscall_number)
1062 {
1063 SYSCALL_MAP (io_setup);
1064 SYSCALL_MAP (io_destroy);
1065 SYSCALL_MAP (io_submit);
1066 SYSCALL_MAP (io_cancel);
1067 SYSCALL_MAP (io_getevents);
1068
1069 SYSCALL_MAP (setxattr);
1070 SYSCALL_MAP (lsetxattr);
1071 SYSCALL_MAP (fsetxattr);
1072 SYSCALL_MAP (getxattr);
1073 SYSCALL_MAP (lgetxattr);
1074 SYSCALL_MAP (fgetxattr);
1075 SYSCALL_MAP (listxattr);
1076 SYSCALL_MAP (llistxattr);
1077 SYSCALL_MAP (flistxattr);
1078 SYSCALL_MAP (removexattr);
1079 SYSCALL_MAP (lremovexattr);
1080 SYSCALL_MAP (fremovexattr);
1081 SYSCALL_MAP (getcwd);
1082 SYSCALL_MAP (lookup_dcookie);
d5219069
YQ
1083 SYSCALL_MAP (eventfd2);
1084 SYSCALL_MAP (epoll_create1);
99afc88b
OJ
1085 SYSCALL_MAP (epoll_ctl);
1086 SYSCALL_MAP (epoll_pwait);
1087 SYSCALL_MAP (dup);
d5219069 1088 SYSCALL_MAP (dup3);
99afc88b 1089 SYSCALL_MAP (fcntl);
d5219069 1090 SYSCALL_MAP (inotify_init1);
99afc88b
OJ
1091 SYSCALL_MAP (inotify_add_watch);
1092 SYSCALL_MAP (inotify_rm_watch);
1093 SYSCALL_MAP (ioctl);
1094 SYSCALL_MAP (ioprio_set);
1095 SYSCALL_MAP (ioprio_get);
1096 SYSCALL_MAP (flock);
c955ae73
YQ
1097 SYSCALL_MAP (mknodat);
1098 SYSCALL_MAP (mkdirat);
1099 SYSCALL_MAP (unlinkat);
1100 SYSCALL_MAP (symlinkat);
1101 SYSCALL_MAP (linkat);
1102 SYSCALL_MAP (renameat);
1103 UNSUPPORTED_SYSCALL_MAP (umount2);
99afc88b 1104 SYSCALL_MAP (mount);
c955ae73 1105 SYSCALL_MAP (pivot_root);
99afc88b
OJ
1106 SYSCALL_MAP (nfsservctl);
1107 SYSCALL_MAP (statfs);
1108 SYSCALL_MAP (truncate);
1109 SYSCALL_MAP (ftruncate);
d5219069 1110 SYSCALL_MAP (fallocate);
c955ae73 1111 SYSCALL_MAP (faccessat);
99afc88b
OJ
1112 SYSCALL_MAP (fchdir);
1113 SYSCALL_MAP (chroot);
1114 SYSCALL_MAP (fchmod);
1115 SYSCALL_MAP (fchmodat);
1116 SYSCALL_MAP (fchownat);
1117 SYSCALL_MAP (fchown);
c955ae73 1118 SYSCALL_MAP (openat);
99afc88b
OJ
1119 SYSCALL_MAP (close);
1120 SYSCALL_MAP (vhangup);
d5219069 1121 SYSCALL_MAP (pipe2);
99afc88b
OJ
1122 SYSCALL_MAP (quotactl);
1123 SYSCALL_MAP (getdents64);
1124 SYSCALL_MAP (lseek);
1125 SYSCALL_MAP (read);
1126 SYSCALL_MAP (write);
1127 SYSCALL_MAP (readv);
1128 SYSCALL_MAP (writev);
1129 SYSCALL_MAP (pread64);
1130 SYSCALL_MAP (pwrite64);
c955ae73
YQ
1131 UNSUPPORTED_SYSCALL_MAP (preadv);
1132 UNSUPPORTED_SYSCALL_MAP (pwritev);
99afc88b
OJ
1133 SYSCALL_MAP (sendfile);
1134 SYSCALL_MAP (pselect6);
1135 SYSCALL_MAP (ppoll);
c955ae73 1136 UNSUPPORTED_SYSCALL_MAP (signalfd4);
99afc88b
OJ
1137 SYSCALL_MAP (vmsplice);
1138 SYSCALL_MAP (splice);
1139 SYSCALL_MAP (tee);
c955ae73
YQ
1140 SYSCALL_MAP (readlinkat);
1141 SYSCALL_MAP (newfstatat);
1142
99afc88b
OJ
1143 SYSCALL_MAP (fstat);
1144 SYSCALL_MAP (sync);
1145 SYSCALL_MAP (fsync);
1146 SYSCALL_MAP (fdatasync);
1147 SYSCALL_MAP (sync_file_range);
c955ae73
YQ
1148 UNSUPPORTED_SYSCALL_MAP (timerfd_create);
1149 UNSUPPORTED_SYSCALL_MAP (timerfd_settime);
1150 UNSUPPORTED_SYSCALL_MAP (timerfd_gettime);
1151 UNSUPPORTED_SYSCALL_MAP (utimensat);
99afc88b
OJ
1152 SYSCALL_MAP (acct);
1153 SYSCALL_MAP (capget);
1154 SYSCALL_MAP (capset);
1155 SYSCALL_MAP (personality);
1156 SYSCALL_MAP (exit);
1157 SYSCALL_MAP (exit_group);
1158 SYSCALL_MAP (waitid);
1159 SYSCALL_MAP (set_tid_address);
1160 SYSCALL_MAP (unshare);
1161 SYSCALL_MAP (futex);
1162 SYSCALL_MAP (set_robust_list);
1163 SYSCALL_MAP (get_robust_list);
1164 SYSCALL_MAP (nanosleep);
1165
1166 SYSCALL_MAP (getitimer);
1167 SYSCALL_MAP (setitimer);
1168 SYSCALL_MAP (kexec_load);
1169 SYSCALL_MAP (init_module);
1170 SYSCALL_MAP (delete_module);
1171 SYSCALL_MAP (timer_create);
1172 SYSCALL_MAP (timer_settime);
1173 SYSCALL_MAP (timer_gettime);
1174 SYSCALL_MAP (timer_getoverrun);
1175 SYSCALL_MAP (timer_delete);
1176 SYSCALL_MAP (clock_settime);
1177 SYSCALL_MAP (clock_gettime);
1178 SYSCALL_MAP (clock_getres);
1179 SYSCALL_MAP (clock_nanosleep);
1180 SYSCALL_MAP (syslog);
1181 SYSCALL_MAP (ptrace);
1182 SYSCALL_MAP (sched_setparam);
1183 SYSCALL_MAP (sched_setscheduler);
1184 SYSCALL_MAP (sched_getscheduler);
1185 SYSCALL_MAP (sched_getparam);
1186 SYSCALL_MAP (sched_setaffinity);
1187 SYSCALL_MAP (sched_getaffinity);
1188 SYSCALL_MAP (sched_yield);
1189 SYSCALL_MAP (sched_get_priority_max);
1190 SYSCALL_MAP (sched_get_priority_min);
1191 SYSCALL_MAP (sched_rr_get_interval);
1192 SYSCALL_MAP (kill);
1193 SYSCALL_MAP (tkill);
1194 SYSCALL_MAP (tgkill);
1195 SYSCALL_MAP (sigaltstack);
1196 SYSCALL_MAP (rt_sigsuspend);
1197 SYSCALL_MAP (rt_sigaction);
1198 SYSCALL_MAP (rt_sigprocmask);
1199 SYSCALL_MAP (rt_sigpending);
1200 SYSCALL_MAP (rt_sigtimedwait);
1201 SYSCALL_MAP (rt_sigqueueinfo);
1202 SYSCALL_MAP (rt_sigreturn);
1203 SYSCALL_MAP (setpriority);
1204 SYSCALL_MAP (getpriority);
1205 SYSCALL_MAP (reboot);
1206 SYSCALL_MAP (setregid);
1207 SYSCALL_MAP (setgid);
1208 SYSCALL_MAP (setreuid);
1209 SYSCALL_MAP (setuid);
1210 SYSCALL_MAP (setresuid);
1211 SYSCALL_MAP (getresuid);
1212 SYSCALL_MAP (setresgid);
1213 SYSCALL_MAP (getresgid);
1214 SYSCALL_MAP (setfsuid);
1215 SYSCALL_MAP (setfsgid);
1216 SYSCALL_MAP (times);
1217 SYSCALL_MAP (setpgid);
1218 SYSCALL_MAP (getpgid);
1219 SYSCALL_MAP (getsid);
1220 SYSCALL_MAP (setsid);
1221 SYSCALL_MAP (getgroups);
1222 SYSCALL_MAP (setgroups);
1223 SYSCALL_MAP (uname);
1224 SYSCALL_MAP (sethostname);
1225 SYSCALL_MAP (setdomainname);
1226 SYSCALL_MAP (getrlimit);
1227 SYSCALL_MAP (setrlimit);
1228 SYSCALL_MAP (getrusage);
1229 SYSCALL_MAP (umask);
1230 SYSCALL_MAP (prctl);
c955ae73 1231 SYSCALL_MAP (getcpu);
99afc88b
OJ
1232 SYSCALL_MAP (gettimeofday);
1233 SYSCALL_MAP (settimeofday);
1234 SYSCALL_MAP (adjtimex);
1235 SYSCALL_MAP (getpid);
1236 SYSCALL_MAP (getppid);
1237 SYSCALL_MAP (getuid);
1238 SYSCALL_MAP (geteuid);
1239 SYSCALL_MAP (getgid);
1240 SYSCALL_MAP (getegid);
1241 SYSCALL_MAP (gettid);
1242 SYSCALL_MAP (sysinfo);
1243 SYSCALL_MAP (mq_open);
1244 SYSCALL_MAP (mq_unlink);
1245 SYSCALL_MAP (mq_timedsend);
1246 SYSCALL_MAP (mq_timedreceive);
1247 SYSCALL_MAP (mq_notify);
1248 SYSCALL_MAP (mq_getsetattr);
1249 SYSCALL_MAP (msgget);
1250 SYSCALL_MAP (msgctl);
1251 SYSCALL_MAP (msgrcv);
1252 SYSCALL_MAP (msgsnd);
1253 SYSCALL_MAP (semget);
1254 SYSCALL_MAP (semctl);
1255 SYSCALL_MAP (semtimedop);
1256 SYSCALL_MAP (semop);
1257 SYSCALL_MAP (shmget);
1258 SYSCALL_MAP (shmctl);
1259 SYSCALL_MAP (shmat);
1260 SYSCALL_MAP (shmdt);
1261 SYSCALL_MAP (socket);
1262 SYSCALL_MAP (socketpair);
1263 SYSCALL_MAP (bind);
1264 SYSCALL_MAP (listen);
1265 SYSCALL_MAP (accept);
1266 SYSCALL_MAP (connect);
1267 SYSCALL_MAP (getsockname);
1268 SYSCALL_MAP (getpeername);
1269 SYSCALL_MAP (sendto);
1270 SYSCALL_MAP (recvfrom);
1271 SYSCALL_MAP (setsockopt);
1272 SYSCALL_MAP (getsockopt);
1273 SYSCALL_MAP (shutdown);
1274 SYSCALL_MAP (sendmsg);
1275 SYSCALL_MAP (recvmsg);
1276 SYSCALL_MAP (readahead);
1277 SYSCALL_MAP (brk);
1278 SYSCALL_MAP (munmap);
1279 SYSCALL_MAP (mremap);
1280 SYSCALL_MAP (add_key);
1281 SYSCALL_MAP (request_key);
1282 SYSCALL_MAP (keyctl);
1283 SYSCALL_MAP (clone);
1284 SYSCALL_MAP (execve);
1285
1286 case aarch64_sys_mmap:
1287 return gdb_sys_mmap2;
1288
1289 SYSCALL_MAP (fadvise64);
1290 SYSCALL_MAP (swapon);
1291 SYSCALL_MAP (swapoff);
1292 SYSCALL_MAP (mprotect);
1293 SYSCALL_MAP (msync);
1294 SYSCALL_MAP (mlock);
1295 SYSCALL_MAP (munlock);
1296 SYSCALL_MAP (mlockall);
1297 SYSCALL_MAP (munlockall);
1298 SYSCALL_MAP (mincore);
1299 SYSCALL_MAP (madvise);
1300 SYSCALL_MAP (remap_file_pages);
1301 SYSCALL_MAP (mbind);
1302 SYSCALL_MAP (get_mempolicy);
1303 SYSCALL_MAP (set_mempolicy);
1304 SYSCALL_MAP (migrate_pages);
1305 SYSCALL_MAP (move_pages);
c955ae73
YQ
1306 UNSUPPORTED_SYSCALL_MAP (rt_tgsigqueueinfo);
1307 UNSUPPORTED_SYSCALL_MAP (perf_event_open);
1308 UNSUPPORTED_SYSCALL_MAP (accept4);
1309 UNSUPPORTED_SYSCALL_MAP (recvmmsg);
1310
1311 SYSCALL_MAP (wait4);
1312
1313 UNSUPPORTED_SYSCALL_MAP (prlimit64);
1314 UNSUPPORTED_SYSCALL_MAP (fanotify_init);
1315 UNSUPPORTED_SYSCALL_MAP (fanotify_mark);
1316 UNSUPPORTED_SYSCALL_MAP (name_to_handle_at);
1317 UNSUPPORTED_SYSCALL_MAP (open_by_handle_at);
1318 UNSUPPORTED_SYSCALL_MAP (clock_adjtime);
1319 UNSUPPORTED_SYSCALL_MAP (syncfs);
1320 UNSUPPORTED_SYSCALL_MAP (setns);
1321 UNSUPPORTED_SYSCALL_MAP (sendmmsg);
1322 UNSUPPORTED_SYSCALL_MAP (process_vm_readv);
1323 UNSUPPORTED_SYSCALL_MAP (process_vm_writev);
1324 UNSUPPORTED_SYSCALL_MAP (kcmp);
1325 UNSUPPORTED_SYSCALL_MAP (finit_module);
1326 UNSUPPORTED_SYSCALL_MAP (sched_setattr);
1327 UNSUPPORTED_SYSCALL_MAP (sched_getattr);
99afc88b 1328 default:
cb65d272 1329 return gdb_sys_no_syscall;
99afc88b
OJ
1330 }
1331}
1332
ea638c43
AH
1333/* Retrieve the syscall number at a ptrace syscall-stop, either on syscall entry
1334 or exit. Return -1 upon error. */
1335
1336static LONGEST
1337aarch64_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
1338{
1339 struct regcache *regs = get_thread_regcache (thread);
1340 LONGEST ret;
1341
1342 /* Get the system call number from register x8. */
1343 regs->cooked_read (AARCH64_X0_REGNUM + 8, &ret);
1344
1345 /* On exit from a successful execve, we will be in a new process and all the
1346 registers will be cleared - x0 to x30 will be 0, except for a 1 in x7.
1347 This function will only ever get called when stopped at the entry or exit
1348 of a syscall, so by checking for 0 in x0 (arg0/retval), x1 (arg1), x8
1349 (syscall), x29 (FP) and x30 (LR) we can infer:
1350 1) Either inferior is at exit from sucessful execve.
1351 2) Or inferior is at entry to a call to io_setup with invalid arguments and
1352 a corrupted FP and LR.
1353 It should be safe enough to assume case 1. */
1354 if (ret == 0)
1355 {
1356 LONGEST x1 = -1, fp = -1, lr = -1;
1357 regs->cooked_read (AARCH64_X0_REGNUM + 1, &x1);
1358 regs->cooked_read (AARCH64_FP_REGNUM, &fp);
1359 regs->cooked_read (AARCH64_LR_REGNUM, &lr);
1360 if (x1 == 0 && fp ==0 && lr == 0)
1361 return aarch64_sys_execve;
1362 }
1363
1364 return ret;
1365}
1366
99afc88b
OJ
1367/* Record all registers but PC register for process-record. */
1368
1369static int
1370aarch64_all_but_pc_registers_record (struct regcache *regcache)
1371{
1372 int i;
1373
1374 for (i = AARCH64_X0_REGNUM; i < AARCH64_PC_REGNUM; i++)
1375 if (record_full_arch_list_add_reg (regcache, i))
1376 return -1;
1377
1378 if (record_full_arch_list_add_reg (regcache, AARCH64_CPSR_REGNUM))
1379 return -1;
1380
1381 return 0;
1382}
1383
1384/* Handler for aarch64 system call instruction recording. */
1385
1386static int
1387aarch64_linux_syscall_record (struct regcache *regcache,
1388 unsigned long svc_number)
1389{
1390 int ret = 0;
1391 enum gdb_syscall syscall_gdb;
1392
1f713e48
SM
1393 syscall_gdb =
1394 aarch64_canonicalize_syscall ((enum aarch64_syscall) svc_number);
99afc88b
OJ
1395
1396 if (syscall_gdb < 0)
1397 {
1398 printf_unfiltered (_("Process record and replay target doesn't "
1399 "support syscall number %s\n"),
1400 plongest (svc_number));
1401 return -1;
1402 }
1403
1404 if (syscall_gdb == gdb_sys_sigreturn
1405 || syscall_gdb == gdb_sys_rt_sigreturn)
1406 {
1407 if (aarch64_all_but_pc_registers_record (regcache))
1408 return -1;
1409 return 0;
1410 }
1411
1412 ret = record_linux_system_call (syscall_gdb, regcache,
1413 &aarch64_linux_record_tdep);
1414 if (ret != 0)
1415 return ret;
1416
1417 /* Record the return value of the system call. */
1418 if (record_full_arch_list_add_reg (regcache, AARCH64_X0_REGNUM))
1419 return -1;
1420 /* Record LR. */
1421 if (record_full_arch_list_add_reg (regcache, AARCH64_LR_REGNUM))
1422 return -1;
1423 /* Record CPSR. */
1424 if (record_full_arch_list_add_reg (regcache, AARCH64_CPSR_REGNUM))
1425 return -1;
1426
1427 return 0;
1428}
1429
7045b1ca
YQ
1430/* Implement the "gcc_target_options" gdbarch method. */
1431
1432static char *
1433aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
1434{
1435 /* GCC doesn't know "-m64". */
1436 return NULL;
1437}
1438
1ae3db19
MS
1439static void
1440aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1441{
08248ca9
SDJ
1442 static const char *const stap_integer_prefixes[] = { "#", "", NULL };
1443 static const char *const stap_register_prefixes[] = { "", NULL };
1444 static const char *const stap_register_indirection_prefixes[] = { "[",
1445 NULL };
1446 static const char *const stap_register_indirection_suffixes[] = { "]",
1447 NULL };
1ae3db19
MS
1448 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1449
1450 tdep->lowest_pc = 0x8000;
1451
05feb193
WN
1452 linux_init_abi (info, gdbarch);
1453
1ae3db19
MS
1454 set_solib_svr4_fetch_link_map_offsets (gdbarch,
1455 svr4_lp64_fetch_link_map_offsets);
1456
45e25a36
MS
1457 /* Enable TLS support. */
1458 set_gdbarch_fetch_tls_load_module_address (gdbarch,
1459 svr4_fetch_objfile_link_map);
1460
1ae3db19
MS
1461 /* Shared library handling. */
1462 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
6dcaef99 1463 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
1ae3db19 1464
1ae3db19
MS
1465 tramp_frame_prepend_unwinder (gdbarch, &aarch64_linux_rt_sigframe);
1466
1467 /* Enable longjmp. */
1468 tdep->jb_pc = 11;
1469
4108500a
AA
1470 set_gdbarch_iterate_over_regset_sections
1471 (gdbarch, aarch64_linux_iterate_over_regset_sections);
cd3af38d
JW
1472 set_gdbarch_core_read_description
1473 (gdbarch, aarch64_linux_core_read_description);
08248ca9
SDJ
1474
1475 /* SystemTap related. */
1476 set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
1477 set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
1478 set_gdbarch_stap_register_indirection_prefixes (gdbarch,
1479 stap_register_indirection_prefixes);
1480 set_gdbarch_stap_register_indirection_suffixes (gdbarch,
1481 stap_register_indirection_suffixes);
1482 set_gdbarch_stap_is_single_operand (gdbarch, aarch64_stap_is_single_operand);
1483 set_gdbarch_stap_parse_special_token (gdbarch,
1484 aarch64_stap_parse_special_token);
f68f11b7 1485
99afc88b
OJ
1486 /* Reversible debugging, process record. */
1487 set_gdbarch_process_record (gdbarch, aarch64_process_record);
1488 /* Syscall record. */
1489 tdep->aarch64_syscall_record = aarch64_linux_syscall_record;
1490
8727de56
OJ
1491 /* The top byte of a user space address known as the "tag",
1492 is ignored by the kernel and can be regarded as additional
1493 data associated with the address. */
1494 set_gdbarch_significant_addr_bit (gdbarch, 56);
1495
99afc88b
OJ
1496 /* Initialize the aarch64_linux_record_tdep. */
1497 /* These values are the size of the type that will be used in a system
1498 call. They are obtained from Linux Kernel source. */
1499 aarch64_linux_record_tdep.size_pointer
1500 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
1501 aarch64_linux_record_tdep.size__old_kernel_stat = 32;
1502 aarch64_linux_record_tdep.size_tms = 32;
1503 aarch64_linux_record_tdep.size_loff_t = 8;
1504 aarch64_linux_record_tdep.size_flock = 32;
1505 aarch64_linux_record_tdep.size_oldold_utsname = 45;
1506 aarch64_linux_record_tdep.size_ustat = 32;
7571f7f2
MK
1507 aarch64_linux_record_tdep.size_old_sigaction = 32;
1508 aarch64_linux_record_tdep.size_old_sigset_t = 8;
99afc88b
OJ
1509 aarch64_linux_record_tdep.size_rlimit = 16;
1510 aarch64_linux_record_tdep.size_rusage = 144;
1511 aarch64_linux_record_tdep.size_timeval = 16;
1512 aarch64_linux_record_tdep.size_timezone = 8;
1513 aarch64_linux_record_tdep.size_old_gid_t = 2;
1514 aarch64_linux_record_tdep.size_old_uid_t = 2;
1515 aarch64_linux_record_tdep.size_fd_set = 128;
72aded86 1516 aarch64_linux_record_tdep.size_old_dirent = 280;
99afc88b
OJ
1517 aarch64_linux_record_tdep.size_statfs = 120;
1518 aarch64_linux_record_tdep.size_statfs64 = 120;
1519 aarch64_linux_record_tdep.size_sockaddr = 16;
1520 aarch64_linux_record_tdep.size_int
1521 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
1522 aarch64_linux_record_tdep.size_long
1523 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1524 aarch64_linux_record_tdep.size_ulong
1525 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1526 aarch64_linux_record_tdep.size_msghdr = 56;
1527 aarch64_linux_record_tdep.size_itimerval = 32;
1528 aarch64_linux_record_tdep.size_stat = 144;
1529 aarch64_linux_record_tdep.size_old_utsname = 325;
1530 aarch64_linux_record_tdep.size_sysinfo = 112;
1531 aarch64_linux_record_tdep.size_msqid_ds = 120;
1532 aarch64_linux_record_tdep.size_shmid_ds = 112;
1533 aarch64_linux_record_tdep.size_new_utsname = 390;
1534 aarch64_linux_record_tdep.size_timex = 208;
1535 aarch64_linux_record_tdep.size_mem_dqinfo = 24;
1536 aarch64_linux_record_tdep.size_if_dqblk = 72;
1537 aarch64_linux_record_tdep.size_fs_quota_stat = 80;
1538 aarch64_linux_record_tdep.size_timespec = 16;
1539 aarch64_linux_record_tdep.size_pollfd = 8;
1540 aarch64_linux_record_tdep.size_NFS_FHSIZE = 32;
1541 aarch64_linux_record_tdep.size_knfsd_fh = 132;
1542 aarch64_linux_record_tdep.size_TASK_COMM_LEN = 16;
7571f7f2
MK
1543 aarch64_linux_record_tdep.size_sigaction = 32;
1544 aarch64_linux_record_tdep.size_sigset_t = 8;
99afc88b
OJ
1545 aarch64_linux_record_tdep.size_siginfo_t = 128;
1546 aarch64_linux_record_tdep.size_cap_user_data_t = 8;
1547 aarch64_linux_record_tdep.size_stack_t = 24;
1548 aarch64_linux_record_tdep.size_off_t = 8;
1549 aarch64_linux_record_tdep.size_stat64 = 144;
1550 aarch64_linux_record_tdep.size_gid_t = 4;
1551 aarch64_linux_record_tdep.size_uid_t = 4;
1552 aarch64_linux_record_tdep.size_PAGE_SIZE = 4096;
1553 aarch64_linux_record_tdep.size_flock64 = 32;
1554 aarch64_linux_record_tdep.size_user_desc = 16;
1555 aarch64_linux_record_tdep.size_io_event = 32;
1556 aarch64_linux_record_tdep.size_iocb = 64;
1557 aarch64_linux_record_tdep.size_epoll_event = 12;
1558 aarch64_linux_record_tdep.size_itimerspec = 32;
1559 aarch64_linux_record_tdep.size_mq_attr = 64;
d9b19c49 1560 aarch64_linux_record_tdep.size_termios = 36;
99afc88b
OJ
1561 aarch64_linux_record_tdep.size_termios2 = 44;
1562 aarch64_linux_record_tdep.size_pid_t = 4;
1563 aarch64_linux_record_tdep.size_winsize = 8;
1564 aarch64_linux_record_tdep.size_serial_struct = 72;
1565 aarch64_linux_record_tdep.size_serial_icounter_struct = 80;
1566 aarch64_linux_record_tdep.size_hayes_esp_config = 12;
1567 aarch64_linux_record_tdep.size_size_t = 8;
1568 aarch64_linux_record_tdep.size_iovec = 16;
b80d067f 1569 aarch64_linux_record_tdep.size_time_t = 8;
99afc88b
OJ
1570
1571 /* These values are the second argument of system call "sys_ioctl".
1572 They are obtained from Linux Kernel source. */
1573 aarch64_linux_record_tdep.ioctl_TCGETS = 0x5401;
1574 aarch64_linux_record_tdep.ioctl_TCSETS = 0x5402;
1575 aarch64_linux_record_tdep.ioctl_TCSETSW = 0x5403;
1576 aarch64_linux_record_tdep.ioctl_TCSETSF = 0x5404;
1577 aarch64_linux_record_tdep.ioctl_TCGETA = 0x5405;
1578 aarch64_linux_record_tdep.ioctl_TCSETA = 0x5406;
1579 aarch64_linux_record_tdep.ioctl_TCSETAW = 0x5407;
1580 aarch64_linux_record_tdep.ioctl_TCSETAF = 0x5408;
1581 aarch64_linux_record_tdep.ioctl_TCSBRK = 0x5409;
1582 aarch64_linux_record_tdep.ioctl_TCXONC = 0x540a;
1583 aarch64_linux_record_tdep.ioctl_TCFLSH = 0x540b;
1584 aarch64_linux_record_tdep.ioctl_TIOCEXCL = 0x540c;
1585 aarch64_linux_record_tdep.ioctl_TIOCNXCL = 0x540d;
1586 aarch64_linux_record_tdep.ioctl_TIOCSCTTY = 0x540e;
1587 aarch64_linux_record_tdep.ioctl_TIOCGPGRP = 0x540f;
1588 aarch64_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
1589 aarch64_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
1590 aarch64_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
1591 aarch64_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
1592 aarch64_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
1593 aarch64_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
1594 aarch64_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
1595 aarch64_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
1596 aarch64_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
1597 aarch64_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
1598 aarch64_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541a;
1599 aarch64_linux_record_tdep.ioctl_FIONREAD = 0x541b;
1600 aarch64_linux_record_tdep.ioctl_TIOCINQ = 0x541b;
1601 aarch64_linux_record_tdep.ioctl_TIOCLINUX = 0x541c;
1602 aarch64_linux_record_tdep.ioctl_TIOCCONS = 0x541d;
1603 aarch64_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541e;
1604 aarch64_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541f;
1605 aarch64_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
1606 aarch64_linux_record_tdep.ioctl_FIONBIO = 0x5421;
1607 aarch64_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
1608 aarch64_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
1609 aarch64_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
1610 aarch64_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
1611 aarch64_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
1612 aarch64_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
1613 aarch64_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
1614 aarch64_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
1615 aarch64_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
1616 aarch64_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
1617 aarch64_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
1618 aarch64_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
1619 aarch64_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
1620 aarch64_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
1621 aarch64_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
1622 aarch64_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
1623 aarch64_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
1624 aarch64_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
1625 aarch64_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
1626 aarch64_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
1627 aarch64_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
1628 aarch64_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
1629 aarch64_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
1630 aarch64_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
1631 aarch64_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545a;
1632 aarch64_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545b;
1633 aarch64_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545c;
1634 aarch64_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545d;
1635 aarch64_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545e;
1636 aarch64_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545f;
1637 aarch64_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
1638
1639 /* These values are the second argument of system call "sys_fcntl"
1640 and "sys_fcntl64". They are obtained from Linux Kernel source. */
1641 aarch64_linux_record_tdep.fcntl_F_GETLK = 5;
1642 aarch64_linux_record_tdep.fcntl_F_GETLK64 = 12;
1643 aarch64_linux_record_tdep.fcntl_F_SETLK64 = 13;
1644 aarch64_linux_record_tdep.fcntl_F_SETLKW64 = 14;
1645
1646 /* The AArch64 syscall calling convention: reg x0-x6 for arguments,
1647 reg x8 for syscall number and return value in reg x0. */
1648 aarch64_linux_record_tdep.arg1 = AARCH64_X0_REGNUM + 0;
1649 aarch64_linux_record_tdep.arg2 = AARCH64_X0_REGNUM + 1;
1650 aarch64_linux_record_tdep.arg3 = AARCH64_X0_REGNUM + 2;
1651 aarch64_linux_record_tdep.arg4 = AARCH64_X0_REGNUM + 3;
1652 aarch64_linux_record_tdep.arg5 = AARCH64_X0_REGNUM + 4;
1653 aarch64_linux_record_tdep.arg6 = AARCH64_X0_REGNUM + 5;
1654 aarch64_linux_record_tdep.arg7 = AARCH64_X0_REGNUM + 6;
1655
f68f11b7
YQ
1656 /* `catch syscall' */
1657 set_xml_syscall_file_name (gdbarch, "syscalls/aarch64-linux.xml");
1658 set_gdbarch_get_syscall_number (gdbarch, aarch64_linux_get_syscall_number);
b6542f81
YQ
1659
1660 /* Displaced stepping. */
1661 set_gdbarch_max_insn_length (gdbarch, 4 * DISPLACED_MODIFIED_INSNS);
1662 set_gdbarch_displaced_step_copy_insn (gdbarch,
1663 aarch64_displaced_step_copy_insn);
1664 set_gdbarch_displaced_step_fixup (gdbarch, aarch64_displaced_step_fixup);
b6542f81
YQ
1665 set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);
1666 set_gdbarch_displaced_step_hw_singlestep (gdbarch,
1667 aarch64_displaced_step_hw_singlestep);
7045b1ca
YQ
1668
1669 set_gdbarch_gcc_target_options (gdbarch, aarch64_linux_gcc_target_options);
1ae3db19
MS
1670}
1671
1ae3db19
MS
1672void
1673_initialize_aarch64_linux_tdep (void)
1674{
1675 gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX,
1676 aarch64_linux_init_abi);
1677}
This page took 0.428785 seconds and 4 git commands to generate.