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