Automatic date update in version.in
[binutils-gdb.git] / gdb / amd64-linux-tdep.c
blob2c76a1de5a8f7a322f1d7e9fe7e0aba5d32e1e97
1 /* Target-dependent code for GNU/Linux x86-64.
3 Copyright (C) 2001-2024 Free Software Foundation, Inc.
4 Contributed by Jiri Smid, SuSE Labs.
6 This file is part of GDB.
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.
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.
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/>. */
21 #include "arch-utils.h"
22 #include "extract-store-integer.h"
23 #include "frame.h"
24 #include "gdbcore.h"
25 #include "regcache.h"
26 #include "osabi.h"
27 #include "symtab.h"
28 #include "gdbtypes.h"
29 #include "reggroups.h"
30 #include "regset.h"
31 #include "parser-defs.h"
32 #include "user-regs.h"
33 #include "amd64-linux-tdep.h"
34 #include "i386-linux-tdep.h"
35 #include "linux-tdep.h"
36 #include "gdbsupport/x86-xstate.h"
38 #include "amd64-tdep.h"
39 #include "solib-svr4.h"
40 #include "xml-syscall.h"
41 #include "glibc-tdep.h"
42 #include "arch/amd64.h"
43 #include "target-descriptions.h"
44 #include "expop.h"
45 #include "arch/amd64-linux-tdesc.h"
46 #include "inferior.h"
48 /* The syscall's XML filename for i386. */
49 #define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
51 #include "record-full.h"
52 #include "linux-record.h"
54 #include <string_view>
56 #define DEFAULT_TAG_MASK 0xffffffffffffffffULL
58 /* Mapping between the general-purpose registers in `struct user'
59 format and GDB's register cache layout. */
61 /* From <sys/reg.h>. */
62 int amd64_linux_gregset_reg_offset[] =
64 10 * 8, /* %rax */
65 5 * 8, /* %rbx */
66 11 * 8, /* %rcx */
67 12 * 8, /* %rdx */
68 13 * 8, /* %rsi */
69 14 * 8, /* %rdi */
70 4 * 8, /* %rbp */
71 19 * 8, /* %rsp */
72 9 * 8, /* %r8 ... */
73 8 * 8,
74 7 * 8,
75 6 * 8,
76 3 * 8,
77 2 * 8,
78 1 * 8,
79 0 * 8, /* ... %r15 */
80 16 * 8, /* %rip */
81 18 * 8, /* %eflags */
82 17 * 8, /* %cs */
83 20 * 8, /* %ss */
84 23 * 8, /* %ds */
85 24 * 8, /* %es */
86 25 * 8, /* %fs */
87 26 * 8, /* %gs */
88 -1, -1, -1, -1, -1, -1, -1, -1,
89 -1, -1, -1, -1, -1, -1, -1, -1,
90 -1, -1, -1, -1, -1, -1, -1, -1,
91 -1, -1, -1, -1, -1, -1, -1, -1, -1,
92 -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1,
94 /* MPX is deprecated. Yet we keep this to not give the registers below
95 a new number. That could break older gdbservers. */
96 -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
97 -1, -1, /* MPX registers BNDCFGU and BNDSTATUS. */
98 -1, -1, -1, -1, -1, -1, -1, -1, /* xmm16 ... xmm31 (AVX512) */
99 -1, -1, -1, -1, -1, -1, -1, -1,
100 -1, -1, -1, -1, -1, -1, -1, -1, /* ymm16 ... ymm31 (AVX512) */
101 -1, -1, -1, -1, -1, -1, -1, -1,
102 -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
103 -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm31 (AVX512) */
104 -1, -1, -1, -1, -1, -1, -1, -1,
105 -1, -1, -1, -1, -1, -1, -1, -1,
106 -1, -1, -1, -1, -1, -1, -1, -1,
107 -1, /* PKEYS register pkru */
109 /* End of hardware registers */
110 21 * 8, 22 * 8, /* fs_base and gs_base. */
111 15 * 8 /* "orig_rax" */
115 /* Support for signal handlers. */
117 #define LINUX_SIGTRAMP_INSN0 0x48 /* mov $NNNNNNNN, %rax */
118 #define LINUX_SIGTRAMP_OFFSET0 0
119 #define LINUX_SIGTRAMP_INSN1 0x0f /* syscall */
120 #define LINUX_SIGTRAMP_OFFSET1 7
122 static const gdb_byte amd64_linux_sigtramp_code[] =
124 /* mov $__NR_rt_sigreturn, %rax */
125 LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00,
126 /* syscall */
127 LINUX_SIGTRAMP_INSN1, 0x05
130 static const gdb_byte amd64_x32_linux_sigtramp_code[] =
132 /* mov $__NR_rt_sigreturn, %rax. */
133 LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x01, 0x02, 0x00, 0x40,
134 /* syscall */
135 LINUX_SIGTRAMP_INSN1, 0x05
138 #define LINUX_SIGTRAMP_LEN (sizeof amd64_linux_sigtramp_code)
140 /* If PC is in a sigtramp routine, return the address of the start of
141 the routine. Otherwise, return 0. */
143 static CORE_ADDR
144 amd64_linux_sigtramp_start (const frame_info_ptr &this_frame)
146 struct gdbarch *gdbarch;
147 const gdb_byte *sigtramp_code;
148 CORE_ADDR pc = get_frame_pc (this_frame);
149 gdb_byte buf[LINUX_SIGTRAMP_LEN];
151 /* We only recognize a signal trampoline if PC is at the start of
152 one of the two instructions. We optimize for finding the PC at
153 the start, as will be the case when the trampoline is not the
154 first frame on the stack. We assume that in the case where the
155 PC is not at the start of the instruction sequence, there will be
156 a few trailing readable bytes on the stack. */
158 if (!safe_frame_unwind_memory (this_frame, pc, buf))
159 return 0;
161 if (buf[0] != LINUX_SIGTRAMP_INSN0)
163 if (buf[0] != LINUX_SIGTRAMP_INSN1)
164 return 0;
166 pc -= LINUX_SIGTRAMP_OFFSET1;
167 if (!safe_frame_unwind_memory (this_frame, pc, buf))
168 return 0;
171 gdbarch = get_frame_arch (this_frame);
172 if (gdbarch_ptr_bit (gdbarch) == 32)
173 sigtramp_code = amd64_x32_linux_sigtramp_code;
174 else
175 sigtramp_code = amd64_linux_sigtramp_code;
176 if (memcmp (buf, sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
177 return 0;
179 return pc;
182 /* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
183 routine. */
185 static int
186 amd64_linux_sigtramp_p (const frame_info_ptr &this_frame)
188 CORE_ADDR pc = get_frame_pc (this_frame);
189 const char *name;
191 find_pc_partial_function (pc, &name, NULL, NULL);
193 /* If we have NAME, we can optimize the search. The trampoline is
194 named __restore_rt. However, it isn't dynamically exported from
195 the shared C library, so the trampoline may appear to be part of
196 the preceding function. This should always be sigaction,
197 __sigaction, or __libc_sigaction (all aliases to the same
198 function). */
199 if (name == NULL || strstr (name, "sigaction") != NULL)
200 return (amd64_linux_sigtramp_start (this_frame) != 0);
202 return (strcmp ("__restore_rt", name) == 0);
205 /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
206 #define AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 40
208 /* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
209 address of the associated sigcontext structure. */
211 static CORE_ADDR
212 amd64_linux_sigcontext_addr (const frame_info_ptr &this_frame)
214 struct gdbarch *gdbarch = get_frame_arch (this_frame);
215 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
216 CORE_ADDR sp;
217 gdb_byte buf[8];
219 get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
220 sp = extract_unsigned_integer (buf, 8, byte_order);
222 /* The sigcontext structure is part of the user context. A pointer
223 to the user context is passed as the third argument to the signal
224 handler, i.e. in %rdx. Unfortunately %rdx isn't preserved across
225 function calls so we can't use it. Fortunately the user context
226 is part of the signal frame and the unwound %rsp directly points
227 at it. */
228 return sp + AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
232 static LONGEST
233 amd64_linux_get_syscall_number (struct gdbarch *gdbarch,
234 thread_info *thread)
236 struct regcache *regcache = get_thread_regcache (thread);
237 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
238 /* The content of a register. */
239 gdb_byte buf[8];
240 /* The result. */
241 LONGEST ret;
243 /* Getting the system call number from the register.
244 When dealing with x86_64 architecture, this information
245 is stored at %rax register. */
246 regcache->cooked_read (AMD64_LINUX_ORIG_RAX_REGNUM, buf);
248 ret = extract_signed_integer (buf, byte_order);
250 return ret;
254 /* From <asm/sigcontext.h>. */
255 static int amd64_linux_sc_reg_offset[] =
257 13 * 8, /* %rax */
258 11 * 8, /* %rbx */
259 14 * 8, /* %rcx */
260 12 * 8, /* %rdx */
261 9 * 8, /* %rsi */
262 8 * 8, /* %rdi */
263 10 * 8, /* %rbp */
264 15 * 8, /* %rsp */
265 0 * 8, /* %r8 */
266 1 * 8, /* %r9 */
267 2 * 8, /* %r10 */
268 3 * 8, /* %r11 */
269 4 * 8, /* %r12 */
270 5 * 8, /* %r13 */
271 6 * 8, /* %r14 */
272 7 * 8, /* %r15 */
273 16 * 8, /* %rip */
274 17 * 8, /* %eflags */
276 /* FIXME: kettenis/2002030531: The registers %cs, %fs and %gs are
277 available in `struct sigcontext'. However, they only occupy two
278 bytes instead of four, which makes using them here rather
279 difficult. Leave them out for now. */
280 -1, /* %cs */
281 -1, /* %ss */
282 -1, /* %ds */
283 -1, /* %es */
284 -1, /* %fs */
285 -1 /* %gs */
288 static int
289 amd64_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
290 const struct reggroup *group)
292 if (regnum == AMD64_LINUX_ORIG_RAX_REGNUM)
293 return (group == system_reggroup
294 || group == save_reggroup
295 || group == restore_reggroup);
296 return i386_register_reggroup_p (gdbarch, regnum, group);
299 /* Set the program counter for process PTID to PC. */
301 static void
302 amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
304 regcache_cooked_write_unsigned (regcache, AMD64_RIP_REGNUM, pc);
306 /* We must be careful with modifying the program counter. If we
307 just interrupted a system call, the kernel might try to restart
308 it when we resume the inferior. On restarting the system call,
309 the kernel will try backing up the program counter even though it
310 no longer points at the system call. This typically results in a
311 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
312 "orig_rax" pseudo-register.
314 Note that "orig_rax" is saved when setting up a dummy call frame.
315 This means that it is properly restored when that frame is
316 popped, and that the interrupted system call will be restarted
317 when we resume the inferior on return from a function call from
318 within GDB. In all other cases the system call will not be
319 restarted. */
320 regcache_cooked_write_unsigned (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, -1);
323 /* Record all registers but IP register for process-record. */
325 static int
326 amd64_all_but_ip_registers_record (struct regcache *regcache)
328 if (record_full_arch_list_add_reg (regcache, AMD64_RAX_REGNUM))
329 return -1;
330 if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
331 return -1;
332 if (record_full_arch_list_add_reg (regcache, AMD64_RDX_REGNUM))
333 return -1;
334 if (record_full_arch_list_add_reg (regcache, AMD64_RBX_REGNUM))
335 return -1;
336 if (record_full_arch_list_add_reg (regcache, AMD64_RSP_REGNUM))
337 return -1;
338 if (record_full_arch_list_add_reg (regcache, AMD64_RBP_REGNUM))
339 return -1;
340 if (record_full_arch_list_add_reg (regcache, AMD64_RSI_REGNUM))
341 return -1;
342 if (record_full_arch_list_add_reg (regcache, AMD64_RDI_REGNUM))
343 return -1;
344 if (record_full_arch_list_add_reg (regcache, AMD64_R8_REGNUM))
345 return -1;
346 if (record_full_arch_list_add_reg (regcache, AMD64_R9_REGNUM))
347 return -1;
348 if (record_full_arch_list_add_reg (regcache, AMD64_R10_REGNUM))
349 return -1;
350 if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
351 return -1;
352 if (record_full_arch_list_add_reg (regcache, AMD64_R12_REGNUM))
353 return -1;
354 if (record_full_arch_list_add_reg (regcache, AMD64_R13_REGNUM))
355 return -1;
356 if (record_full_arch_list_add_reg (regcache, AMD64_R14_REGNUM))
357 return -1;
358 if (record_full_arch_list_add_reg (regcache, AMD64_R15_REGNUM))
359 return -1;
360 if (record_full_arch_list_add_reg (regcache, AMD64_EFLAGS_REGNUM))
361 return -1;
363 return 0;
366 /* amd64_canonicalize_syscall maps from the native amd64 Linux set
367 of syscall ids into a canonical set of syscall ids used by
368 process record. */
370 static enum gdb_syscall
371 amd64_canonicalize_syscall (enum amd64_syscall syscall_number)
373 DIAGNOSTIC_PUSH
374 DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
376 switch (syscall_number) {
377 case amd64_sys_read:
378 case amd64_x32_sys_read:
379 return gdb_sys_read;
381 case amd64_sys_write:
382 case amd64_x32_sys_write:
383 return gdb_sys_write;
385 case amd64_sys_open:
386 case amd64_x32_sys_open:
387 return gdb_sys_open;
389 case amd64_sys_close:
390 case amd64_x32_sys_close:
391 return gdb_sys_close;
393 case amd64_sys_newstat:
394 case amd64_x32_sys_newstat:
395 return gdb_sys_newstat;
397 case amd64_sys_newfstat:
398 case amd64_x32_sys_newfstat:
399 return gdb_sys_newfstat;
401 case amd64_sys_newlstat:
402 case amd64_x32_sys_newlstat:
403 return gdb_sys_newlstat;
405 case amd64_sys_poll:
406 case amd64_x32_sys_poll:
407 return gdb_sys_poll;
409 case amd64_sys_lseek:
410 case amd64_x32_sys_lseek:
411 return gdb_sys_lseek;
413 case amd64_sys_mmap:
414 case amd64_x32_sys_mmap:
415 return gdb_sys_mmap2;
417 case amd64_sys_mprotect:
418 case amd64_x32_sys_mprotect:
419 return gdb_sys_mprotect;
421 case amd64_sys_munmap:
422 case amd64_x32_sys_munmap:
423 return gdb_sys_munmap;
425 case amd64_sys_brk:
426 case amd64_x32_sys_brk:
427 return gdb_sys_brk;
429 case amd64_sys_rt_sigaction:
430 case amd64_x32_sys_rt_sigaction:
431 return gdb_sys_rt_sigaction;
433 case amd64_sys_rt_sigprocmask:
434 case amd64_x32_sys_rt_sigprocmask:
435 return gdb_sys_rt_sigprocmask;
437 case amd64_sys_rt_sigreturn:
438 case amd64_x32_sys_rt_sigreturn:
439 return gdb_sys_rt_sigreturn;
441 case amd64_sys_ioctl:
442 case amd64_x32_sys_ioctl:
443 return gdb_sys_ioctl;
445 case amd64_sys_pread64:
446 case amd64_x32_sys_pread64:
447 return gdb_sys_pread64;
449 case amd64_sys_pwrite64:
450 case amd64_x32_sys_pwrite64:
451 return gdb_sys_pwrite64;
453 case amd64_sys_readv:
454 case amd64_x32_sys_readv:
455 return gdb_sys_readv;
457 case amd64_sys_writev:
458 case amd64_x32_sys_writev:
459 return gdb_sys_writev;
461 case amd64_sys_access:
462 case amd64_x32_sys_access:
463 return gdb_sys_access;
465 case amd64_sys_pipe:
466 case amd64_x32_sys_pipe:
467 return gdb_sys_pipe;
469 case amd64_sys_pipe2:
470 return gdb_sys_pipe2;
472 case amd64_sys_getrandom:
473 return gdb_sys_getrandom;
475 case amd64_sys_select:
476 case amd64_x32_sys_select:
477 return gdb_sys_select;
479 case amd64_sys_sched_yield:
480 case amd64_x32_sys_sched_yield:
481 return gdb_sys_sched_yield;
483 case amd64_sys_mremap:
484 case amd64_x32_sys_mremap:
485 return gdb_sys_mremap;
487 case amd64_sys_msync:
488 case amd64_x32_sys_msync:
489 return gdb_sys_msync;
491 case amd64_sys_mincore:
492 case amd64_x32_sys_mincore:
493 return gdb_sys_mincore;
495 case amd64_sys_madvise:
496 case amd64_x32_sys_madvise:
497 return gdb_sys_madvise;
499 case amd64_sys_shmget:
500 case amd64_x32_sys_shmget:
501 return gdb_sys_shmget;
503 case amd64_sys_shmat:
504 case amd64_x32_sys_shmat:
505 return gdb_sys_shmat;
507 case amd64_sys_shmctl:
508 case amd64_x32_sys_shmctl:
509 return gdb_sys_shmctl;
511 case amd64_sys_dup:
512 case amd64_x32_sys_dup:
513 return gdb_sys_dup;
515 case amd64_sys_dup2:
516 case amd64_x32_sys_dup2:
517 return gdb_sys_dup2;
519 case amd64_sys_pause:
520 case amd64_x32_sys_pause:
521 return gdb_sys_pause;
523 case amd64_sys_nanosleep:
524 case amd64_x32_sys_nanosleep:
525 return gdb_sys_nanosleep;
527 case amd64_sys_getitimer:
528 case amd64_x32_sys_getitimer:
529 return gdb_sys_getitimer;
531 case amd64_sys_alarm:
532 case amd64_x32_sys_alarm:
533 return gdb_sys_alarm;
535 case amd64_sys_setitimer:
536 case amd64_x32_sys_setitimer:
537 return gdb_sys_setitimer;
539 case amd64_sys_getpid:
540 case amd64_x32_sys_getpid:
541 return gdb_sys_getpid;
543 case amd64_sys_sendfile64:
544 case amd64_x32_sys_sendfile64:
545 return gdb_sys_sendfile64;
547 case amd64_sys_socket:
548 case amd64_x32_sys_socket:
549 return gdb_sys_socket;
551 case amd64_sys_connect:
552 case amd64_x32_sys_connect:
553 return gdb_sys_connect;
555 case amd64_sys_accept:
556 case amd64_x32_sys_accept:
557 return gdb_sys_accept;
559 case amd64_sys_sendto:
560 case amd64_x32_sys_sendto:
561 return gdb_sys_sendto;
563 case amd64_sys_recvfrom:
564 case amd64_x32_sys_recvfrom:
565 return gdb_sys_recvfrom;
567 case amd64_sys_sendmsg:
568 case amd64_x32_sys_sendmsg:
569 return gdb_sys_sendmsg;
571 case amd64_sys_recvmsg:
572 case amd64_x32_sys_recvmsg:
573 return gdb_sys_recvmsg;
575 case amd64_sys_shutdown:
576 case amd64_x32_sys_shutdown:
577 return gdb_sys_shutdown;
579 case amd64_sys_bind:
580 case amd64_x32_sys_bind:
581 return gdb_sys_bind;
583 case amd64_sys_listen:
584 case amd64_x32_sys_listen:
585 return gdb_sys_listen;
587 case amd64_sys_getsockname:
588 case amd64_x32_sys_getsockname:
589 return gdb_sys_getsockname;
591 case amd64_sys_getpeername:
592 case amd64_x32_sys_getpeername:
593 return gdb_sys_getpeername;
595 case amd64_sys_socketpair:
596 case amd64_x32_sys_socketpair:
597 return gdb_sys_socketpair;
599 case amd64_sys_setsockopt:
600 case amd64_x32_sys_setsockopt:
601 return gdb_sys_setsockopt;
603 case amd64_sys_getsockopt:
604 case amd64_x32_sys_getsockopt:
605 return gdb_sys_getsockopt;
607 case amd64_sys_clone:
608 case amd64_x32_sys_clone:
609 return gdb_sys_clone;
611 case amd64_sys_fork:
612 case amd64_x32_sys_fork:
613 return gdb_sys_fork;
615 case amd64_sys_vfork:
616 case amd64_x32_sys_vfork:
617 return gdb_sys_vfork;
619 case amd64_sys_execve:
620 case amd64_x32_sys_execve:
621 return gdb_sys_execve;
623 case amd64_sys_exit:
624 case amd64_x32_sys_exit:
625 return gdb_sys_exit;
627 case amd64_sys_wait4:
628 case amd64_x32_sys_wait4:
629 return gdb_sys_wait4;
631 case amd64_sys_kill:
632 case amd64_x32_sys_kill:
633 return gdb_sys_kill;
635 case amd64_sys_uname:
636 case amd64_x32_sys_uname:
637 return gdb_sys_uname;
639 case amd64_sys_semget:
640 case amd64_x32_sys_semget:
641 return gdb_sys_semget;
643 case amd64_sys_semop:
644 case amd64_x32_sys_semop:
645 return gdb_sys_semop;
647 case amd64_sys_semctl:
648 case amd64_x32_sys_semctl:
649 return gdb_sys_semctl;
651 case amd64_sys_shmdt:
652 case amd64_x32_sys_shmdt:
653 return gdb_sys_shmdt;
655 case amd64_sys_msgget:
656 case amd64_x32_sys_msgget:
657 return gdb_sys_msgget;
659 case amd64_sys_msgsnd:
660 case amd64_x32_sys_msgsnd:
661 return gdb_sys_msgsnd;
663 case amd64_sys_msgrcv:
664 case amd64_x32_sys_msgrcv:
665 return gdb_sys_msgrcv;
667 case amd64_sys_msgctl:
668 case amd64_x32_sys_msgctl:
669 return gdb_sys_msgctl;
671 case amd64_sys_fcntl:
672 case amd64_x32_sys_fcntl:
673 return gdb_sys_fcntl;
675 case amd64_sys_flock:
676 case amd64_x32_sys_flock:
677 return gdb_sys_flock;
679 case amd64_sys_fsync:
680 case amd64_x32_sys_fsync:
681 return gdb_sys_fsync;
683 case amd64_sys_fdatasync:
684 case amd64_x32_sys_fdatasync:
685 return gdb_sys_fdatasync;
687 case amd64_sys_truncate:
688 case amd64_x32_sys_truncate:
689 return gdb_sys_truncate;
691 case amd64_sys_ftruncate:
692 case amd64_x32_sys_ftruncate:
693 return gdb_sys_ftruncate;
695 case amd64_sys_getdents:
696 case amd64_x32_sys_getdents:
697 return gdb_sys_getdents;
699 case amd64_sys_getcwd:
700 case amd64_x32_sys_getcwd:
701 return gdb_sys_getcwd;
703 case amd64_sys_chdir:
704 case amd64_x32_sys_chdir:
705 return gdb_sys_chdir;
707 case amd64_sys_fchdir:
708 case amd64_x32_sys_fchdir:
709 return gdb_sys_fchdir;
711 case amd64_sys_rename:
712 case amd64_x32_sys_rename:
713 return gdb_sys_rename;
715 case amd64_sys_mkdir:
716 case amd64_x32_sys_mkdir:
717 return gdb_sys_mkdir;
719 case amd64_sys_rmdir:
720 case amd64_x32_sys_rmdir:
721 return gdb_sys_rmdir;
723 case amd64_sys_creat:
724 case amd64_x32_sys_creat:
725 return gdb_sys_creat;
727 case amd64_sys_link:
728 case amd64_x32_sys_link:
729 return gdb_sys_link;
731 case amd64_sys_unlink:
732 case amd64_x32_sys_unlink:
733 return gdb_sys_unlink;
735 case amd64_sys_symlink:
736 case amd64_x32_sys_symlink:
737 return gdb_sys_symlink;
739 case amd64_sys_readlink:
740 case amd64_x32_sys_readlink:
741 return gdb_sys_readlink;
743 case amd64_sys_chmod:
744 case amd64_x32_sys_chmod:
745 return gdb_sys_chmod;
747 case amd64_sys_fchmod:
748 case amd64_x32_sys_fchmod:
749 return gdb_sys_fchmod;
751 case amd64_sys_chown:
752 case amd64_x32_sys_chown:
753 return gdb_sys_chown;
755 case amd64_sys_fchown:
756 case amd64_x32_sys_fchown:
757 return gdb_sys_fchown;
759 case amd64_sys_lchown:
760 case amd64_x32_sys_lchown:
761 return gdb_sys_lchown;
763 case amd64_sys_umask:
764 case amd64_x32_sys_umask:
765 return gdb_sys_umask;
767 case amd64_sys_gettimeofday:
768 case amd64_x32_sys_gettimeofday:
769 return gdb_sys_gettimeofday;
771 case amd64_sys_getrlimit:
772 case amd64_x32_sys_getrlimit:
773 return gdb_sys_getrlimit;
775 case amd64_sys_getrusage:
776 case amd64_x32_sys_getrusage:
777 return gdb_sys_getrusage;
779 case amd64_sys_sysinfo:
780 case amd64_x32_sys_sysinfo:
781 return gdb_sys_sysinfo;
783 case amd64_sys_times:
784 case amd64_x32_sys_times:
785 return gdb_sys_times;
787 case amd64_sys_ptrace:
788 case amd64_x32_sys_ptrace:
789 return gdb_sys_ptrace;
791 case amd64_sys_getuid:
792 case amd64_x32_sys_getuid:
793 return gdb_sys_getuid;
795 case amd64_sys_syslog:
796 case amd64_x32_sys_syslog:
797 return gdb_sys_syslog;
799 case amd64_sys_getgid:
800 case amd64_x32_sys_getgid:
801 return gdb_sys_getgid;
803 case amd64_sys_setuid:
804 case amd64_x32_sys_setuid:
805 return gdb_sys_setuid;
807 case amd64_sys_setgid:
808 case amd64_x32_sys_setgid:
809 return gdb_sys_setgid;
811 case amd64_sys_geteuid:
812 case amd64_x32_sys_geteuid:
813 return gdb_sys_geteuid;
815 case amd64_sys_getegid:
816 case amd64_x32_sys_getegid:
817 return gdb_sys_getegid;
819 case amd64_sys_setpgid:
820 case amd64_x32_sys_setpgid:
821 return gdb_sys_setpgid;
823 case amd64_sys_getppid:
824 case amd64_x32_sys_getppid:
825 return gdb_sys_getppid;
827 case amd64_sys_getpgrp:
828 case amd64_x32_sys_getpgrp:
829 return gdb_sys_getpgrp;
831 case amd64_sys_setsid:
832 case amd64_x32_sys_setsid:
833 return gdb_sys_setsid;
835 case amd64_sys_setreuid:
836 case amd64_x32_sys_setreuid:
837 return gdb_sys_setreuid;
839 case amd64_sys_setregid:
840 case amd64_x32_sys_setregid:
841 return gdb_sys_setregid;
843 case amd64_sys_getgroups:
844 case amd64_x32_sys_getgroups:
845 return gdb_sys_getgroups;
847 case amd64_sys_setgroups:
848 case amd64_x32_sys_setgroups:
849 return gdb_sys_setgroups;
851 case amd64_sys_setresuid:
852 case amd64_x32_sys_setresuid:
853 return gdb_sys_setresuid;
855 case amd64_sys_getresuid:
856 case amd64_x32_sys_getresuid:
857 return gdb_sys_getresuid;
859 case amd64_sys_setresgid:
860 case amd64_x32_sys_setresgid:
861 return gdb_sys_setresgid;
863 case amd64_sys_getresgid:
864 case amd64_x32_sys_getresgid:
865 return gdb_sys_getresgid;
867 case amd64_sys_getpgid:
868 case amd64_x32_sys_getpgid:
869 return gdb_sys_getpgid;
871 case amd64_sys_setfsuid:
872 case amd64_x32_sys_setfsuid:
873 return gdb_sys_setfsuid;
875 case amd64_sys_setfsgid:
876 case amd64_x32_sys_setfsgid:
877 return gdb_sys_setfsgid;
879 case amd64_sys_getsid:
880 case amd64_x32_sys_getsid:
881 return gdb_sys_getsid;
883 case amd64_sys_capget:
884 case amd64_x32_sys_capget:
885 return gdb_sys_capget;
887 case amd64_sys_capset:
888 case amd64_x32_sys_capset:
889 return gdb_sys_capset;
891 case amd64_sys_rt_sigpending:
892 case amd64_x32_sys_rt_sigpending:
893 return gdb_sys_rt_sigpending;
895 case amd64_sys_rt_sigtimedwait:
896 case amd64_x32_sys_rt_sigtimedwait:
897 return gdb_sys_rt_sigtimedwait;
899 case amd64_sys_rt_sigqueueinfo:
900 case amd64_x32_sys_rt_sigqueueinfo:
901 return gdb_sys_rt_sigqueueinfo;
903 case amd64_sys_rt_sigsuspend:
904 case amd64_x32_sys_rt_sigsuspend:
905 return gdb_sys_rt_sigsuspend;
907 case amd64_sys_sigaltstack:
908 case amd64_x32_sys_sigaltstack:
909 return gdb_sys_sigaltstack;
911 case amd64_sys_utime:
912 case amd64_x32_sys_utime:
913 return gdb_sys_utime;
915 case amd64_sys_mknod:
916 case amd64_x32_sys_mknod:
917 return gdb_sys_mknod;
919 case amd64_sys_personality:
920 case amd64_x32_sys_personality:
921 return gdb_sys_personality;
923 case amd64_sys_ustat:
924 case amd64_x32_sys_ustat:
925 return gdb_sys_ustat;
927 case amd64_sys_statfs:
928 case amd64_x32_sys_statfs:
929 return gdb_sys_statfs;
931 case amd64_sys_fstatfs:
932 case amd64_x32_sys_fstatfs:
933 return gdb_sys_fstatfs;
935 case amd64_sys_sysfs:
936 case amd64_x32_sys_sysfs:
937 return gdb_sys_sysfs;
939 case amd64_sys_getpriority:
940 case amd64_x32_sys_getpriority:
941 return gdb_sys_getpriority;
943 case amd64_sys_setpriority:
944 case amd64_x32_sys_setpriority:
945 return gdb_sys_setpriority;
947 case amd64_sys_sched_setparam:
948 case amd64_x32_sys_sched_setparam:
949 return gdb_sys_sched_setparam;
951 case amd64_sys_sched_getparam:
952 case amd64_x32_sys_sched_getparam:
953 return gdb_sys_sched_getparam;
955 case amd64_sys_sched_setscheduler:
956 case amd64_x32_sys_sched_setscheduler:
957 return gdb_sys_sched_setscheduler;
959 case amd64_sys_sched_getscheduler:
960 case amd64_x32_sys_sched_getscheduler:
961 return gdb_sys_sched_getscheduler;
963 case amd64_sys_sched_get_priority_max:
964 case amd64_x32_sys_sched_get_priority_max:
965 return gdb_sys_sched_get_priority_max;
967 case amd64_sys_sched_get_priority_min:
968 case amd64_x32_sys_sched_get_priority_min:
969 return gdb_sys_sched_get_priority_min;
971 case amd64_sys_sched_rr_get_interval:
972 case amd64_x32_sys_sched_rr_get_interval:
973 return gdb_sys_sched_rr_get_interval;
975 case amd64_sys_mlock:
976 case amd64_x32_sys_mlock:
977 return gdb_sys_mlock;
979 case amd64_sys_munlock:
980 case amd64_x32_sys_munlock:
981 return gdb_sys_munlock;
983 case amd64_sys_mlockall:
984 case amd64_x32_sys_mlockall:
985 return gdb_sys_mlockall;
987 case amd64_sys_munlockall:
988 case amd64_x32_sys_munlockall:
989 return gdb_sys_munlockall;
991 case amd64_sys_vhangup:
992 case amd64_x32_sys_vhangup:
993 return gdb_sys_vhangup;
995 case amd64_sys_modify_ldt:
996 case amd64_x32_sys_modify_ldt:
997 return gdb_sys_modify_ldt;
999 case amd64_sys_pivot_root:
1000 case amd64_x32_sys_pivot_root:
1001 return gdb_sys_pivot_root;
1003 case amd64_sys_sysctl:
1004 case amd64_x32_sys_sysctl:
1005 return gdb_sys_sysctl;
1007 case amd64_sys_prctl:
1008 case amd64_x32_sys_prctl:
1009 return gdb_sys_prctl;
1011 case amd64_sys_arch_prctl:
1012 case amd64_x32_sys_arch_prctl:
1013 return gdb_sys_no_syscall; /* Note */
1015 case amd64_sys_adjtimex:
1016 case amd64_x32_sys_adjtimex:
1017 return gdb_sys_adjtimex;
1019 case amd64_sys_setrlimit:
1020 case amd64_x32_sys_setrlimit:
1021 return gdb_sys_setrlimit;
1023 case amd64_sys_chroot:
1024 case amd64_x32_sys_chroot:
1025 return gdb_sys_chroot;
1027 case amd64_sys_sync:
1028 case amd64_x32_sys_sync:
1029 return gdb_sys_sync;
1031 case amd64_sys_acct:
1032 case amd64_x32_sys_acct:
1033 return gdb_sys_acct;
1035 case amd64_sys_settimeofday:
1036 case amd64_x32_sys_settimeofday:
1037 return gdb_sys_settimeofday;
1039 case amd64_sys_mount:
1040 case amd64_x32_sys_mount:
1041 return gdb_sys_mount;
1043 case amd64_sys_umount:
1044 case amd64_x32_sys_umount:
1045 return gdb_sys_umount;
1047 case amd64_sys_swapon:
1048 case amd64_x32_sys_swapon:
1049 return gdb_sys_swapon;
1051 case amd64_sys_swapoff:
1052 case amd64_x32_sys_swapoff:
1053 return gdb_sys_swapoff;
1055 case amd64_sys_reboot:
1056 case amd64_x32_sys_reboot:
1057 return gdb_sys_reboot;
1059 case amd64_sys_sethostname:
1060 case amd64_x32_sys_sethostname:
1061 return gdb_sys_sethostname;
1063 case amd64_sys_setdomainname:
1064 case amd64_x32_sys_setdomainname:
1065 return gdb_sys_setdomainname;
1067 case amd64_sys_iopl:
1068 case amd64_x32_sys_iopl:
1069 return gdb_sys_iopl;
1071 case amd64_sys_ioperm:
1072 case amd64_x32_sys_ioperm:
1073 return gdb_sys_ioperm;
1075 case amd64_sys_init_module:
1076 case amd64_x32_sys_init_module:
1077 return gdb_sys_init_module;
1079 case amd64_sys_delete_module:
1080 case amd64_x32_sys_delete_module:
1081 return gdb_sys_delete_module;
1083 case amd64_sys_quotactl:
1084 case amd64_x32_sys_quotactl:
1085 return gdb_sys_quotactl;
1087 case amd64_sys_nfsservctl:
1088 return gdb_sys_nfsservctl;
1090 case amd64_sys_gettid:
1091 case amd64_x32_sys_gettid:
1092 return gdb_sys_gettid;
1094 case amd64_sys_readahead:
1095 case amd64_x32_sys_readahead:
1096 return gdb_sys_readahead;
1098 case amd64_sys_setxattr:
1099 case amd64_x32_sys_setxattr:
1100 return gdb_sys_setxattr;
1102 case amd64_sys_lsetxattr:
1103 case amd64_x32_sys_lsetxattr:
1104 return gdb_sys_lsetxattr;
1106 case amd64_sys_fsetxattr:
1107 case amd64_x32_sys_fsetxattr:
1108 return gdb_sys_fsetxattr;
1110 case amd64_sys_getxattr:
1111 case amd64_x32_sys_getxattr:
1112 return gdb_sys_getxattr;
1114 case amd64_sys_lgetxattr:
1115 case amd64_x32_sys_lgetxattr:
1116 return gdb_sys_lgetxattr;
1118 case amd64_sys_fgetxattr:
1119 case amd64_x32_sys_fgetxattr:
1120 return gdb_sys_fgetxattr;
1122 case amd64_sys_listxattr:
1123 case amd64_x32_sys_listxattr:
1124 return gdb_sys_listxattr;
1126 case amd64_sys_llistxattr:
1127 case amd64_x32_sys_llistxattr:
1128 return gdb_sys_llistxattr;
1130 case amd64_sys_flistxattr:
1131 case amd64_x32_sys_flistxattr:
1132 return gdb_sys_flistxattr;
1134 case amd64_sys_removexattr:
1135 case amd64_x32_sys_removexattr:
1136 return gdb_sys_removexattr;
1138 case amd64_sys_lremovexattr:
1139 case amd64_x32_sys_lremovexattr:
1140 return gdb_sys_lremovexattr;
1142 case amd64_sys_fremovexattr:
1143 case amd64_x32_sys_fremovexattr:
1144 return gdb_sys_fremovexattr;
1146 case amd64_sys_tkill:
1147 case amd64_x32_sys_tkill:
1148 return gdb_sys_tkill;
1150 case amd64_sys_time:
1151 case amd64_x32_sys_time:
1152 return gdb_sys_time;
1154 case amd64_sys_futex:
1155 case amd64_x32_sys_futex:
1156 return gdb_sys_futex;
1158 case amd64_sys_sched_setaffinity:
1159 case amd64_x32_sys_sched_setaffinity:
1160 return gdb_sys_sched_setaffinity;
1162 case amd64_sys_sched_getaffinity:
1163 case amd64_x32_sys_sched_getaffinity:
1164 return gdb_sys_sched_getaffinity;
1166 case amd64_sys_io_setup:
1167 case amd64_x32_sys_io_setup:
1168 return gdb_sys_io_setup;
1170 case amd64_sys_io_destroy:
1171 case amd64_x32_sys_io_destroy:
1172 return gdb_sys_io_destroy;
1174 case amd64_sys_io_getevents:
1175 case amd64_x32_sys_io_getevents:
1176 return gdb_sys_io_getevents;
1178 case amd64_sys_io_submit:
1179 case amd64_x32_sys_io_submit:
1180 return gdb_sys_io_submit;
1182 case amd64_sys_io_cancel:
1183 case amd64_x32_sys_io_cancel:
1184 return gdb_sys_io_cancel;
1186 case amd64_sys_lookup_dcookie:
1187 case amd64_x32_sys_lookup_dcookie:
1188 return gdb_sys_lookup_dcookie;
1190 case amd64_sys_epoll_create:
1191 case amd64_x32_sys_epoll_create:
1192 return gdb_sys_epoll_create;
1194 case amd64_sys_remap_file_pages:
1195 case amd64_x32_sys_remap_file_pages:
1196 return gdb_sys_remap_file_pages;
1198 case amd64_sys_getdents64:
1199 case amd64_x32_sys_getdents64:
1200 return gdb_sys_getdents64;
1202 case amd64_sys_set_tid_address:
1203 case amd64_x32_sys_set_tid_address:
1204 return gdb_sys_set_tid_address;
1206 case amd64_sys_restart_syscall:
1207 case amd64_x32_sys_restart_syscall:
1208 return gdb_sys_restart_syscall;
1210 case amd64_sys_semtimedop:
1211 case amd64_x32_sys_semtimedop:
1212 return gdb_sys_semtimedop;
1214 case amd64_sys_fadvise64:
1215 case amd64_x32_sys_fadvise64:
1216 return gdb_sys_fadvise64;
1218 case amd64_sys_timer_create:
1219 case amd64_x32_sys_timer_create:
1220 return gdb_sys_timer_create;
1222 case amd64_sys_timer_settime:
1223 case amd64_x32_sys_timer_settime:
1224 return gdb_sys_timer_settime;
1226 case amd64_sys_timer_gettime:
1227 case amd64_x32_sys_timer_gettime:
1228 return gdb_sys_timer_gettime;
1230 case amd64_sys_timer_getoverrun:
1231 case amd64_x32_sys_timer_getoverrun:
1232 return gdb_sys_timer_getoverrun;
1234 case amd64_sys_timer_delete:
1235 case amd64_x32_sys_timer_delete:
1236 return gdb_sys_timer_delete;
1238 case amd64_sys_clock_settime:
1239 case amd64_x32_sys_clock_settime:
1240 return gdb_sys_clock_settime;
1242 case amd64_sys_clock_gettime:
1243 case amd64_x32_sys_clock_gettime:
1244 return gdb_sys_clock_gettime;
1246 case amd64_sys_clock_getres:
1247 case amd64_x32_sys_clock_getres:
1248 return gdb_sys_clock_getres;
1250 case amd64_sys_clock_nanosleep:
1251 case amd64_x32_sys_clock_nanosleep:
1252 return gdb_sys_clock_nanosleep;
1254 case amd64_sys_exit_group:
1255 case amd64_x32_sys_exit_group:
1256 return gdb_sys_exit_group;
1258 case amd64_sys_epoll_wait:
1259 case amd64_x32_sys_epoll_wait:
1260 return gdb_sys_epoll_wait;
1262 case amd64_sys_epoll_ctl:
1263 case amd64_x32_sys_epoll_ctl:
1264 return gdb_sys_epoll_ctl;
1266 case amd64_sys_tgkill:
1267 case amd64_x32_sys_tgkill:
1268 return gdb_sys_tgkill;
1270 case amd64_sys_utimes:
1271 case amd64_x32_sys_utimes:
1272 return gdb_sys_utimes;
1274 case amd64_sys_mbind:
1275 case amd64_x32_sys_mbind:
1276 return gdb_sys_mbind;
1278 case amd64_sys_set_mempolicy:
1279 case amd64_x32_sys_set_mempolicy:
1280 return gdb_sys_set_mempolicy;
1282 case amd64_sys_get_mempolicy:
1283 case amd64_x32_sys_get_mempolicy:
1284 return gdb_sys_get_mempolicy;
1286 case amd64_sys_mq_open:
1287 case amd64_x32_sys_mq_open:
1288 return gdb_sys_mq_open;
1290 case amd64_sys_mq_unlink:
1291 case amd64_x32_sys_mq_unlink:
1292 return gdb_sys_mq_unlink;
1294 case amd64_sys_mq_timedsend:
1295 case amd64_x32_sys_mq_timedsend:
1296 return gdb_sys_mq_timedsend;
1298 case amd64_sys_mq_timedreceive:
1299 case amd64_x32_sys_mq_timedreceive:
1300 return gdb_sys_mq_timedreceive;
1302 case amd64_sys_mq_notify:
1303 case amd64_x32_sys_mq_notify:
1304 return gdb_sys_mq_notify;
1306 case amd64_sys_mq_getsetattr:
1307 case amd64_x32_sys_mq_getsetattr:
1308 return gdb_sys_mq_getsetattr;
1310 case amd64_sys_kexec_load:
1311 case amd64_x32_sys_kexec_load:
1312 return gdb_sys_kexec_load;
1314 case amd64_sys_waitid:
1315 case amd64_x32_sys_waitid:
1316 return gdb_sys_waitid;
1318 case amd64_sys_add_key:
1319 case amd64_x32_sys_add_key:
1320 return gdb_sys_add_key;
1322 case amd64_sys_request_key:
1323 case amd64_x32_sys_request_key:
1324 return gdb_sys_request_key;
1326 case amd64_sys_keyctl:
1327 case amd64_x32_sys_keyctl:
1328 return gdb_sys_keyctl;
1330 case amd64_sys_ioprio_set:
1331 case amd64_x32_sys_ioprio_set:
1332 return gdb_sys_ioprio_set;
1334 case amd64_sys_ioprio_get:
1335 case amd64_x32_sys_ioprio_get:
1336 return gdb_sys_ioprio_get;
1338 case amd64_sys_inotify_init:
1339 case amd64_x32_sys_inotify_init:
1340 return gdb_sys_inotify_init;
1342 case amd64_sys_inotify_add_watch:
1343 case amd64_x32_sys_inotify_add_watch:
1344 return gdb_sys_inotify_add_watch;
1346 case amd64_sys_inotify_rm_watch:
1347 case amd64_x32_sys_inotify_rm_watch:
1348 return gdb_sys_inotify_rm_watch;
1350 case amd64_sys_migrate_pages:
1351 case amd64_x32_sys_migrate_pages:
1352 return gdb_sys_migrate_pages;
1354 case amd64_sys_openat:
1355 case amd64_x32_sys_openat:
1356 return gdb_sys_openat;
1358 case amd64_sys_mkdirat:
1359 case amd64_x32_sys_mkdirat:
1360 return gdb_sys_mkdirat;
1362 case amd64_sys_mknodat:
1363 case amd64_x32_sys_mknodat:
1364 return gdb_sys_mknodat;
1366 case amd64_sys_fchownat:
1367 case amd64_x32_sys_fchownat:
1368 return gdb_sys_fchownat;
1370 case amd64_sys_futimesat:
1371 case amd64_x32_sys_futimesat:
1372 return gdb_sys_futimesat;
1374 case amd64_sys_newfstatat:
1375 case amd64_x32_sys_newfstatat:
1376 return gdb_sys_newfstatat;
1378 case amd64_sys_unlinkat:
1379 case amd64_x32_sys_unlinkat:
1380 return gdb_sys_unlinkat;
1382 case amd64_sys_renameat:
1383 case amd64_x32_sys_renameat:
1384 return gdb_sys_renameat;
1386 case amd64_sys_linkat:
1387 case amd64_x32_sys_linkat:
1388 return gdb_sys_linkat;
1390 case amd64_sys_symlinkat:
1391 case amd64_x32_sys_symlinkat:
1392 return gdb_sys_symlinkat;
1394 case amd64_sys_readlinkat:
1395 case amd64_x32_sys_readlinkat:
1396 return gdb_sys_readlinkat;
1398 case amd64_sys_fchmodat:
1399 case amd64_x32_sys_fchmodat:
1400 return gdb_sys_fchmodat;
1402 case amd64_sys_faccessat:
1403 case amd64_x32_sys_faccessat:
1404 return gdb_sys_faccessat;
1406 case amd64_sys_pselect6:
1407 case amd64_x32_sys_pselect6:
1408 return gdb_sys_pselect6;
1410 case amd64_sys_ppoll:
1411 case amd64_x32_sys_ppoll:
1412 return gdb_sys_ppoll;
1414 case amd64_sys_unshare:
1415 case amd64_x32_sys_unshare:
1416 return gdb_sys_unshare;
1418 case amd64_sys_set_robust_list:
1419 case amd64_x32_sys_set_robust_list:
1420 return gdb_sys_set_robust_list;
1422 case amd64_sys_get_robust_list:
1423 case amd64_x32_sys_get_robust_list:
1424 return gdb_sys_get_robust_list;
1426 case amd64_sys_splice:
1427 case amd64_x32_sys_splice:
1428 return gdb_sys_splice;
1430 case amd64_sys_tee:
1431 case amd64_x32_sys_tee:
1432 return gdb_sys_tee;
1434 case amd64_sys_sync_file_range:
1435 case amd64_x32_sys_sync_file_range:
1436 return gdb_sys_sync_file_range;
1438 case amd64_sys_vmsplice:
1439 case amd64_x32_sys_vmsplice:
1440 return gdb_sys_vmsplice;
1442 case amd64_sys_move_pages:
1443 case amd64_x32_sys_move_pages:
1444 return gdb_sys_move_pages;
1446 default:
1447 return gdb_sys_no_syscall;
1450 DIAGNOSTIC_POP
1453 /* Parse the arguments of current system call instruction and record
1454 the values of the registers and memory that will be changed into
1455 "record_full_arch_list". This instruction is "syscall".
1457 Return -1 if something wrong. */
1459 static struct linux_record_tdep amd64_linux_record_tdep;
1460 static struct linux_record_tdep amd64_x32_linux_record_tdep;
1462 #define RECORD_ARCH_GET_FS 0x1003
1463 #define RECORD_ARCH_GET_GS 0x1004
1465 static int
1466 amd64_linux_syscall_record_common (struct regcache *regcache,
1467 struct linux_record_tdep *linux_record_tdep_p)
1469 int ret;
1470 ULONGEST syscall_native;
1471 enum gdb_syscall syscall_gdb = gdb_sys_no_syscall;
1473 regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &syscall_native);
1475 switch (syscall_native)
1477 case amd64_sys_rt_sigreturn:
1478 case amd64_x32_sys_rt_sigreturn:
1479 if (amd64_all_but_ip_registers_record (regcache))
1480 return -1;
1481 return 0;
1482 break;
1484 case amd64_sys_arch_prctl:
1485 case amd64_x32_sys_arch_prctl:
1487 ULONGEST arg3;
1488 regcache_raw_read_unsigned (regcache, linux_record_tdep_p->arg3,
1489 &arg3);
1490 if (arg3 == RECORD_ARCH_GET_FS || arg3 == RECORD_ARCH_GET_GS)
1492 CORE_ADDR addr;
1494 regcache_raw_read_unsigned (regcache,
1495 linux_record_tdep_p->arg2,
1496 &addr);
1497 if (record_full_arch_list_add_mem
1498 (addr, linux_record_tdep_p->size_ulong))
1499 return -1;
1501 goto record_regs;
1503 break;
1506 syscall_gdb
1507 = amd64_canonicalize_syscall ((enum amd64_syscall) syscall_native);
1509 if (syscall_gdb == gdb_sys_no_syscall)
1511 gdb_printf (gdb_stderr,
1512 _("Process record and replay target doesn't "
1513 "support syscall number %s\n"),
1514 pulongest (syscall_native));
1515 return -1;
1517 else
1519 ret = record_linux_system_call (syscall_gdb, regcache,
1520 linux_record_tdep_p);
1521 if (ret)
1522 return ret;
1525 record_regs:
1526 /* Record the return value of the system call. */
1527 if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
1528 return -1;
1529 if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
1530 return -1;
1532 return 0;
1535 static int
1536 amd64_linux_syscall_record (struct regcache *regcache)
1538 return amd64_linux_syscall_record_common (regcache,
1539 &amd64_linux_record_tdep);
1542 static int
1543 amd64_x32_linux_syscall_record (struct regcache *regcache)
1545 return amd64_linux_syscall_record_common (regcache,
1546 &amd64_x32_linux_record_tdep);
1549 #define AMD64_LINUX_redzone 128
1550 #define AMD64_LINUX_xstate 512
1551 #define AMD64_LINUX_frame_size 560
1553 static int
1554 amd64_linux_record_signal (struct gdbarch *gdbarch,
1555 struct regcache *regcache,
1556 enum gdb_signal signal)
1558 ULONGEST rsp;
1560 if (amd64_all_but_ip_registers_record (regcache))
1561 return -1;
1563 if (record_full_arch_list_add_reg (regcache, AMD64_RIP_REGNUM))
1564 return -1;
1566 /* Record the change in the stack. */
1567 regcache_raw_read_unsigned (regcache, AMD64_RSP_REGNUM, &rsp);
1568 /* redzone
1569 sp -= 128; */
1570 rsp -= AMD64_LINUX_redzone;
1571 /* This is for xstate.
1572 sp -= sizeof (struct _fpstate); */
1573 rsp -= AMD64_LINUX_xstate;
1574 /* This is for frame_size.
1575 sp -= sizeof (struct rt_sigframe); */
1576 rsp -= AMD64_LINUX_frame_size;
1577 if (record_full_arch_list_add_mem (rsp, AMD64_LINUX_redzone
1578 + AMD64_LINUX_xstate
1579 + AMD64_LINUX_frame_size))
1580 return -1;
1582 if (record_full_arch_list_add_end ())
1583 return -1;
1585 return 0;
1588 /* Get Linux/x86 target description from core dump. */
1590 static const struct target_desc *
1591 amd64_linux_core_read_description (struct gdbarch *gdbarch,
1592 struct target_ops *target,
1593 bfd *abfd)
1595 /* Linux/x86-64. */
1596 x86_xsave_layout layout;
1597 uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout);
1598 if (xcr0 == 0)
1599 xcr0 = X86_XSTATE_SSE_MASK;
1601 return amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
1602 gdbarch_ptr_bit (gdbarch) == 32);
1605 /* Similar to amd64_supply_fpregset, but use XSAVE extended state. */
1607 static void
1608 amd64_linux_supply_xstateregset (const struct regset *regset,
1609 struct regcache *regcache, int regnum,
1610 const void *xstateregs, size_t len)
1612 amd64_supply_xsave (regcache, regnum, xstateregs);
1615 /* Similar to amd64_collect_fpregset, but use XSAVE extended state. */
1617 static void
1618 amd64_linux_collect_xstateregset (const struct regset *regset,
1619 const struct regcache *regcache,
1620 int regnum, void *xstateregs, size_t len)
1622 amd64_collect_xsave (regcache, regnum, xstateregs, 1);
1625 static const struct regset amd64_linux_xstateregset =
1627 NULL,
1628 amd64_linux_supply_xstateregset,
1629 amd64_linux_collect_xstateregset
1632 /* Iterate over core file register note sections. */
1634 static void
1635 amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
1636 iterate_over_regset_sections_cb *cb,
1637 void *cb_data,
1638 const struct regcache *regcache)
1640 i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
1642 cb (".reg", 27 * 8, 27 * 8, &i386_gregset, NULL, cb_data);
1643 cb (".reg2", 512, 512, &amd64_fpregset, NULL, cb_data);
1644 if (tdep->xsave_layout.sizeof_xsave != 0)
1645 cb (".reg-xstate", tdep->xsave_layout.sizeof_xsave,
1646 tdep->xsave_layout.sizeof_xsave, &amd64_linux_xstateregset,
1647 "XSAVE extended state", cb_data);
1650 /* The instruction sequences used in x86_64 machines for a
1651 disabled is-enabled probe. */
1653 const gdb_byte amd64_dtrace_disabled_probe_sequence_1[] = {
1654 /* xor %rax, %rax */ 0x48, 0x33, 0xc0,
1655 /* nop */ 0x90,
1656 /* nop */ 0x90
1659 const gdb_byte amd64_dtrace_disabled_probe_sequence_2[] = {
1660 /* xor %rax, %rax */ 0x48, 0x33, 0xc0,
1661 /* ret */ 0xc3,
1662 /* nop */ 0x90
1665 /* The instruction sequence used in x86_64 machines for enabling a
1666 DTrace is-enabled probe. */
1668 const gdb_byte amd64_dtrace_enable_probe_sequence[] = {
1669 /* mov $0x1, %eax */ 0xb8, 0x01, 0x00, 0x00, 0x00
1672 /* The instruction sequence used in x86_64 machines for disabling a
1673 DTrace is-enabled probe. */
1675 const gdb_byte amd64_dtrace_disable_probe_sequence[] = {
1676 /* xor %rax, %rax; nop; nop */ 0x48, 0x33, 0xC0, 0x90, 0x90
1679 /* Implementation of `gdbarch_dtrace_probe_is_enabled', as defined in
1680 gdbarch.h. */
1682 static int
1683 amd64_dtrace_probe_is_enabled (struct gdbarch *gdbarch, CORE_ADDR addr)
1685 gdb_byte buf[5];
1687 /* This function returns 1 if the instructions at ADDR do _not_
1688 follow any of the amd64_dtrace_disabled_probe_sequence_*
1689 patterns.
1691 Note that ADDR is offset 3 bytes from the beginning of these
1692 sequences. */
1694 read_code (addr - 3, buf, 5);
1695 return (memcmp (buf, amd64_dtrace_disabled_probe_sequence_1, 5) != 0
1696 && memcmp (buf, amd64_dtrace_disabled_probe_sequence_2, 5) != 0);
1699 /* Implementation of `gdbarch_dtrace_enable_probe', as defined in
1700 gdbarch.h. */
1702 static void
1703 amd64_dtrace_enable_probe (struct gdbarch *gdbarch, CORE_ADDR addr)
1705 /* Note also that ADDR is offset 3 bytes from the beginning of
1706 amd64_dtrace_enable_probe_sequence. */
1708 write_memory (addr - 3, amd64_dtrace_enable_probe_sequence, 5);
1711 /* Implementation of `gdbarch_dtrace_disable_probe', as defined in
1712 gdbarch.h. */
1714 static void
1715 amd64_dtrace_disable_probe (struct gdbarch *gdbarch, CORE_ADDR addr)
1717 /* Note also that ADDR is offset 3 bytes from the beginning of
1718 amd64_dtrace_disable_probe_sequence. */
1720 write_memory (addr - 3, amd64_dtrace_disable_probe_sequence, 5);
1723 /* Implementation of `gdbarch_dtrace_parse_probe_argument', as defined
1724 in gdbarch.h. */
1726 static expr::operation_up
1727 amd64_dtrace_parse_probe_argument (struct gdbarch *gdbarch,
1728 int narg)
1730 /* DTrace probe arguments can be found on the ABI-defined places for
1731 regular arguments at the current PC. The probe abstraction
1732 currently supports up to 12 arguments for probes. */
1734 using namespace expr;
1736 if (narg < 6)
1738 static const int arg_reg_map[6] =
1740 AMD64_RDI_REGNUM, /* Arg 1. */
1741 AMD64_RSI_REGNUM, /* Arg 2. */
1742 AMD64_RDX_REGNUM, /* Arg 3. */
1743 AMD64_RCX_REGNUM, /* Arg 4. */
1744 AMD64_R8_REGNUM, /* Arg 5. */
1745 AMD64_R9_REGNUM /* Arg 6. */
1747 int regno = arg_reg_map[narg];
1748 const char *regname = user_reg_map_regnum_to_name (gdbarch, regno);
1749 return make_operation<register_operation> (regname);
1751 else
1753 /* Additional arguments are passed on the stack. */
1754 const char *regname = user_reg_map_regnum_to_name (gdbarch, AMD64_RSP_REGNUM);
1756 /* Displacement. */
1757 struct type *long_type = builtin_type (gdbarch)->builtin_long;
1758 operation_up disp = make_operation<long_const_operation> (long_type,
1759 narg - 6);
1761 /* Register: SP. */
1762 operation_up reg = make_operation<register_operation> (regname);
1764 operation_up add = make_operation<add_operation> (std::move (disp),
1765 std::move (reg));
1767 /* Cast to long. */
1768 operation_up cast = make_operation<unop_cast_operation> (std::move (add),
1769 long_type);
1771 return make_operation<unop_ind_operation> (std::move (cast));
1775 /* Extract the untagging mask based on the currently active linear address
1776 masking (LAM) mode, which is stored in the /proc/<pid>/status file.
1777 If we cannot extract the untag mask (for example, if we don't have
1778 execution), we assume address tagging is not enabled and return the
1779 DEFAULT_TAG_MASK. */
1781 static CORE_ADDR
1782 amd64_linux_lam_untag_mask ()
1784 if (!target_has_execution ())
1785 return DEFAULT_TAG_MASK;
1787 inferior *inf = current_inferior ();
1788 if (inf->fake_pid_p)
1789 return DEFAULT_TAG_MASK;
1791 const std::string filename = string_printf ("/proc/%d/status", inf->pid);
1792 gdb::unique_xmalloc_ptr<char> status_file
1793 = target_fileio_read_stralloc (nullptr, filename.c_str ());
1795 if (status_file == nullptr)
1796 return DEFAULT_TAG_MASK;
1798 std::string_view status_file_view (status_file.get ());
1799 constexpr std::string_view untag_mask_str = "untag_mask:\t";
1800 const size_t found = status_file_view.find (untag_mask_str);
1801 if (found != std::string::npos)
1803 const char* start = status_file_view.data() + found
1804 + untag_mask_str.length ();
1805 char* endptr;
1806 errno = 0;
1807 unsigned long long result = std::strtoul (start, &endptr, 0);
1808 if (errno != 0 || endptr == start)
1809 error (_("Failed to parse untag_mask from file %s."),
1810 std::string (filename).c_str ());
1812 return result;
1815 return DEFAULT_TAG_MASK;
1818 /* Adjust watchpoint address based on the currently active linear address
1819 masking (LAM) mode using the untag mask. Check each time for a new
1820 mask, as LAM is enabled at runtime. */
1822 static CORE_ADDR
1823 amd64_linux_remove_non_address_bits_watchpoint (gdbarch *gdbarch,
1824 CORE_ADDR addr)
1826 /* Clear insignificant bits of a target address using the untag
1827 mask. */
1828 return (addr & amd64_linux_lam_untag_mask ());
1831 static void
1832 amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch,
1833 int num_disp_step_buffers)
1835 i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
1837 linux_init_abi (info, gdbarch, num_disp_step_buffers);
1839 tdep->sigtramp_p = amd64_linux_sigtramp_p;
1840 tdep->sigcontext_addr = amd64_linux_sigcontext_addr;
1841 tdep->sc_reg_offset = amd64_linux_sc_reg_offset;
1842 tdep->sc_num_regs = ARRAY_SIZE (amd64_linux_sc_reg_offset);
1844 tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET;
1845 set_gdbarch_core_read_x86_xsave_layout
1846 (gdbarch, i386_linux_core_read_x86_xsave_layout);
1848 /* Add the %orig_rax register used for syscall restarting. */
1849 set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc);
1851 tdep->register_reggroup_p = amd64_linux_register_reggroup_p;
1853 /* Functions for 'catch syscall'. */
1854 set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_AMD64);
1855 set_gdbarch_get_syscall_number (gdbarch,
1856 amd64_linux_get_syscall_number);
1858 /* Enable TLS support. */
1859 set_gdbarch_fetch_tls_load_module_address (gdbarch,
1860 svr4_fetch_objfile_link_map);
1862 /* GNU/Linux uses SVR4-style shared libraries. */
1863 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
1865 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
1866 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
1868 /* Iterate over core file register note sections. */
1869 set_gdbarch_iterate_over_regset_sections
1870 (gdbarch, amd64_linux_iterate_over_regset_sections);
1872 set_gdbarch_core_read_description (gdbarch,
1873 amd64_linux_core_read_description);
1875 /* Displaced stepping. */
1876 set_gdbarch_displaced_step_copy_insn (gdbarch,
1877 amd64_displaced_step_copy_insn);
1878 set_gdbarch_displaced_step_fixup (gdbarch, amd64_displaced_step_fixup);
1880 set_gdbarch_process_record (gdbarch, i386_process_record);
1881 set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
1883 set_gdbarch_remove_non_address_bits_watchpoint
1884 (gdbarch, amd64_linux_remove_non_address_bits_watchpoint);
1887 static void
1888 amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1890 i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
1891 struct tdesc_arch_data *tdesc_data = info.tdesc_data;
1892 const struct tdesc_feature *feature;
1893 int valid_p;
1895 gdb_assert (tdesc_data);
1897 tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
1898 tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
1899 tdep->sizeof_gregset = 27 * 8;
1901 amd64_init_abi (info, gdbarch,
1902 amd64_linux_read_description (X86_XSTATE_SSE_MASK, false));
1904 const target_desc *tdesc = tdep->tdesc;
1906 /* Reserve a number for orig_rax. */
1907 set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
1909 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
1910 if (feature == NULL)
1911 return;
1913 valid_p = tdesc_numbered_register (feature, tdesc_data,
1914 AMD64_LINUX_ORIG_RAX_REGNUM,
1915 "orig_rax");
1916 if (!valid_p)
1917 return;
1919 amd64_linux_init_abi_common (info, gdbarch, 2);
1921 /* Initialize the amd64_linux_record_tdep. */
1922 /* These values are the size of the type that will be used in a system
1923 call. They are obtained from Linux Kernel source. */
1924 amd64_linux_record_tdep.size_pointer
1925 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
1926 amd64_linux_record_tdep.size__old_kernel_stat = 32;
1927 amd64_linux_record_tdep.size_tms = 32;
1928 amd64_linux_record_tdep.size_loff_t = 8;
1929 amd64_linux_record_tdep.size_flock = 32;
1930 amd64_linux_record_tdep.size_oldold_utsname = 45;
1931 amd64_linux_record_tdep.size_ustat = 32;
1932 /* ADM64 doesn't need this size because it doesn't have sys_sigaction
1933 but sys_rt_sigaction. */
1934 amd64_linux_record_tdep.size_old_sigaction = 32;
1935 /* ADM64 doesn't need this size because it doesn't have sys_sigpending
1936 but sys_rt_sigpending. */
1937 amd64_linux_record_tdep.size_old_sigset_t = 8;
1938 amd64_linux_record_tdep.size_rlimit = 16;
1939 amd64_linux_record_tdep.size_rusage = 144;
1940 amd64_linux_record_tdep.size_timeval = 16;
1941 amd64_linux_record_tdep.size_timezone = 8;
1942 /* ADM64 doesn't need this size because it doesn't have sys_getgroups16
1943 but sys_getgroups. */
1944 amd64_linux_record_tdep.size_old_gid_t = 2;
1945 /* ADM64 doesn't need this size because it doesn't have sys_getresuid16
1946 but sys_getresuid. */
1947 amd64_linux_record_tdep.size_old_uid_t = 2;
1948 amd64_linux_record_tdep.size_fd_set = 128;
1949 /* ADM64 doesn't need this size because it doesn't have sys_readdir. */
1950 amd64_linux_record_tdep.size_old_dirent = 280;
1951 amd64_linux_record_tdep.size_statfs = 120;
1952 amd64_linux_record_tdep.size_statfs64 = 120;
1953 amd64_linux_record_tdep.size_sockaddr = 16;
1954 amd64_linux_record_tdep.size_int
1955 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
1956 amd64_linux_record_tdep.size_long
1957 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1958 amd64_linux_record_tdep.size_ulong
1959 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1960 amd64_linux_record_tdep.size_msghdr = 56;
1961 amd64_linux_record_tdep.size_itimerval = 32;
1962 amd64_linux_record_tdep.size_stat = 144;
1963 amd64_linux_record_tdep.size_old_utsname = 325;
1964 amd64_linux_record_tdep.size_sysinfo = 112;
1965 amd64_linux_record_tdep.size_msqid_ds = 120;
1966 amd64_linux_record_tdep.size_shmid_ds = 112;
1967 amd64_linux_record_tdep.size_new_utsname = 390;
1968 amd64_linux_record_tdep.size_timex = 208;
1969 amd64_linux_record_tdep.size_mem_dqinfo = 24;
1970 amd64_linux_record_tdep.size_if_dqblk = 72;
1971 amd64_linux_record_tdep.size_fs_quota_stat = 80;
1972 amd64_linux_record_tdep.size_timespec = 16;
1973 amd64_linux_record_tdep.size_pollfd = 8;
1974 amd64_linux_record_tdep.size_NFS_FHSIZE = 32;
1975 amd64_linux_record_tdep.size_knfsd_fh = 132;
1976 amd64_linux_record_tdep.size_TASK_COMM_LEN = 16;
1977 amd64_linux_record_tdep.size_sigaction = 32;
1978 amd64_linux_record_tdep.size_sigset_t = 8;
1979 amd64_linux_record_tdep.size_siginfo_t = 128;
1980 amd64_linux_record_tdep.size_cap_user_data_t = 8;
1981 amd64_linux_record_tdep.size_stack_t = 24;
1982 amd64_linux_record_tdep.size_off_t = 8;
1983 amd64_linux_record_tdep.size_stat64 = 144;
1984 amd64_linux_record_tdep.size_gid_t = 4;
1985 amd64_linux_record_tdep.size_uid_t = 4;
1986 amd64_linux_record_tdep.size_PAGE_SIZE = 4096;
1987 amd64_linux_record_tdep.size_flock64 = 32;
1988 amd64_linux_record_tdep.size_user_desc = 16;
1989 amd64_linux_record_tdep.size_io_event = 32;
1990 amd64_linux_record_tdep.size_iocb = 64;
1991 amd64_linux_record_tdep.size_epoll_event = 12;
1992 amd64_linux_record_tdep.size_itimerspec = 32;
1993 amd64_linux_record_tdep.size_mq_attr = 64;
1994 amd64_linux_record_tdep.size_termios = 36;
1995 amd64_linux_record_tdep.size_termios2 = 44;
1996 amd64_linux_record_tdep.size_pid_t = 4;
1997 amd64_linux_record_tdep.size_winsize = 8;
1998 amd64_linux_record_tdep.size_serial_struct = 72;
1999 amd64_linux_record_tdep.size_serial_icounter_struct = 80;
2000 amd64_linux_record_tdep.size_hayes_esp_config = 12;
2001 amd64_linux_record_tdep.size_size_t = 8;
2002 amd64_linux_record_tdep.size_iovec = 16;
2003 amd64_linux_record_tdep.size_time_t = 8;
2005 /* These values are the second argument of system call "sys_fcntl"
2006 and "sys_fcntl64". They are obtained from Linux Kernel source. */
2007 amd64_linux_record_tdep.fcntl_F_GETLK = 5;
2008 amd64_linux_record_tdep.fcntl_F_GETLK64 = 12;
2009 amd64_linux_record_tdep.fcntl_F_SETLK64 = 13;
2010 amd64_linux_record_tdep.fcntl_F_SETLKW64 = 14;
2012 amd64_linux_record_tdep.arg1 = AMD64_RDI_REGNUM;
2013 amd64_linux_record_tdep.arg2 = AMD64_RSI_REGNUM;
2014 amd64_linux_record_tdep.arg3 = AMD64_RDX_REGNUM;
2015 amd64_linux_record_tdep.arg4 = AMD64_R10_REGNUM;
2016 amd64_linux_record_tdep.arg5 = AMD64_R8_REGNUM;
2017 amd64_linux_record_tdep.arg6 = AMD64_R9_REGNUM;
2019 /* These values are the second argument of system call "sys_ioctl".
2020 They are obtained from Linux Kernel source. */
2021 amd64_linux_record_tdep.ioctl_TCGETS = 0x5401;
2022 amd64_linux_record_tdep.ioctl_TCSETS = 0x5402;
2023 amd64_linux_record_tdep.ioctl_TCSETSW = 0x5403;
2024 amd64_linux_record_tdep.ioctl_TCSETSF = 0x5404;
2025 amd64_linux_record_tdep.ioctl_TCGETA = 0x5405;
2026 amd64_linux_record_tdep.ioctl_TCSETA = 0x5406;
2027 amd64_linux_record_tdep.ioctl_TCSETAW = 0x5407;
2028 amd64_linux_record_tdep.ioctl_TCSETAF = 0x5408;
2029 amd64_linux_record_tdep.ioctl_TCSBRK = 0x5409;
2030 amd64_linux_record_tdep.ioctl_TCXONC = 0x540A;
2031 amd64_linux_record_tdep.ioctl_TCFLSH = 0x540B;
2032 amd64_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
2033 amd64_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
2034 amd64_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
2035 amd64_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
2036 amd64_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
2037 amd64_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
2038 amd64_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
2039 amd64_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
2040 amd64_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
2041 amd64_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
2042 amd64_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
2043 amd64_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
2044 amd64_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
2045 amd64_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
2046 amd64_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
2047 amd64_linux_record_tdep.ioctl_FIONREAD = 0x541B;
2048 amd64_linux_record_tdep.ioctl_TIOCINQ
2049 = amd64_linux_record_tdep.ioctl_FIONREAD;
2050 amd64_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
2051 amd64_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
2052 amd64_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
2053 amd64_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
2054 amd64_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
2055 amd64_linux_record_tdep.ioctl_FIONBIO = 0x5421;
2056 amd64_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
2057 amd64_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
2058 amd64_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
2059 amd64_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
2060 amd64_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
2061 amd64_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
2062 amd64_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
2063 amd64_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
2064 amd64_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
2065 amd64_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
2066 amd64_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
2067 amd64_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
2068 amd64_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
2069 amd64_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
2070 amd64_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
2071 amd64_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
2072 amd64_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
2073 amd64_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
2074 amd64_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
2075 amd64_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
2076 amd64_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
2077 amd64_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
2078 amd64_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
2079 amd64_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
2080 amd64_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
2081 amd64_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
2082 amd64_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
2083 amd64_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
2084 amd64_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
2085 amd64_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
2086 amd64_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
2088 tdep->i386_syscall_record = amd64_linux_syscall_record;
2090 /* GNU/Linux uses SVR4-style shared libraries. */
2091 set_solib_svr4_fetch_link_map_offsets
2092 (gdbarch, linux_lp64_fetch_link_map_offsets);
2094 /* Register DTrace handlers. */
2095 set_gdbarch_dtrace_parse_probe_argument (gdbarch, amd64_dtrace_parse_probe_argument);
2096 set_gdbarch_dtrace_probe_is_enabled (gdbarch, amd64_dtrace_probe_is_enabled);
2097 set_gdbarch_dtrace_enable_probe (gdbarch, amd64_dtrace_enable_probe);
2098 set_gdbarch_dtrace_disable_probe (gdbarch, amd64_dtrace_disable_probe);
2101 static void
2102 amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
2104 i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
2105 struct tdesc_arch_data *tdesc_data = info.tdesc_data;
2106 const struct tdesc_feature *feature;
2107 int valid_p;
2109 gdb_assert (tdesc_data);
2111 tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
2112 tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
2113 tdep->sizeof_gregset = 27 * 8;
2115 amd64_x32_init_abi (info, gdbarch,
2116 amd64_linux_read_description (X86_XSTATE_SSE_MASK,
2117 true));
2119 /* Reserve a number for orig_rax. */
2120 set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
2122 const target_desc *tdesc = tdep->tdesc;
2124 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
2125 if (feature == NULL)
2126 return;
2128 valid_p = tdesc_numbered_register (feature, tdesc_data,
2129 AMD64_LINUX_ORIG_RAX_REGNUM,
2130 "orig_rax");
2131 if (!valid_p)
2132 return;
2134 amd64_linux_init_abi_common (info, gdbarch, 0);
2136 /* Initialize the amd64_x32_linux_record_tdep. */
2137 /* These values are the size of the type that will be used in a system
2138 call. They are obtained from Linux Kernel source. */
2139 amd64_x32_linux_record_tdep.size_pointer
2140 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
2141 amd64_x32_linux_record_tdep.size__old_kernel_stat = 32;
2142 amd64_x32_linux_record_tdep.size_tms = 32;
2143 amd64_x32_linux_record_tdep.size_loff_t = 8;
2144 amd64_x32_linux_record_tdep.size_flock = 32;
2145 amd64_x32_linux_record_tdep.size_oldold_utsname = 45;
2146 amd64_x32_linux_record_tdep.size_ustat = 32;
2147 /* ADM64 doesn't need this size because it doesn't have sys_sigaction
2148 but sys_rt_sigaction. */
2149 amd64_x32_linux_record_tdep.size_old_sigaction = 16;
2150 /* ADM64 doesn't need this size because it doesn't have sys_sigpending
2151 but sys_rt_sigpending. */
2152 amd64_x32_linux_record_tdep.size_old_sigset_t = 4;
2153 amd64_x32_linux_record_tdep.size_rlimit = 16;
2154 amd64_x32_linux_record_tdep.size_rusage = 144;
2155 amd64_x32_linux_record_tdep.size_timeval = 16;
2156 amd64_x32_linux_record_tdep.size_timezone = 8;
2157 /* ADM64 doesn't need this size because it doesn't have sys_getgroups16
2158 but sys_getgroups. */
2159 amd64_x32_linux_record_tdep.size_old_gid_t = 2;
2160 /* ADM64 doesn't need this size because it doesn't have sys_getresuid16
2161 but sys_getresuid. */
2162 amd64_x32_linux_record_tdep.size_old_uid_t = 2;
2163 amd64_x32_linux_record_tdep.size_fd_set = 128;
2164 /* ADM64 doesn't need this size because it doesn't have sys_readdir. */
2165 amd64_x32_linux_record_tdep.size_old_dirent = 268;
2166 amd64_x32_linux_record_tdep.size_statfs = 120;
2167 amd64_x32_linux_record_tdep.size_statfs64 = 120;
2168 amd64_x32_linux_record_tdep.size_sockaddr = 16;
2169 amd64_x32_linux_record_tdep.size_int
2170 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
2171 amd64_x32_linux_record_tdep.size_long
2172 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
2173 amd64_x32_linux_record_tdep.size_ulong
2174 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
2175 amd64_x32_linux_record_tdep.size_msghdr = 28;
2176 amd64_x32_linux_record_tdep.size_itimerval = 32;
2177 amd64_x32_linux_record_tdep.size_stat = 144;
2178 amd64_x32_linux_record_tdep.size_old_utsname = 325;
2179 amd64_x32_linux_record_tdep.size_sysinfo = 112;
2180 amd64_x32_linux_record_tdep.size_msqid_ds = 120;
2181 amd64_x32_linux_record_tdep.size_shmid_ds = 112;
2182 amd64_x32_linux_record_tdep.size_new_utsname = 390;
2183 amd64_x32_linux_record_tdep.size_timex = 208;
2184 amd64_x32_linux_record_tdep.size_mem_dqinfo = 24;
2185 amd64_x32_linux_record_tdep.size_if_dqblk = 72;
2186 amd64_x32_linux_record_tdep.size_fs_quota_stat = 80;
2187 amd64_x32_linux_record_tdep.size_timespec = 16;
2188 amd64_x32_linux_record_tdep.size_pollfd = 8;
2189 amd64_x32_linux_record_tdep.size_NFS_FHSIZE = 32;
2190 amd64_x32_linux_record_tdep.size_knfsd_fh = 132;
2191 amd64_x32_linux_record_tdep.size_TASK_COMM_LEN = 16;
2192 amd64_x32_linux_record_tdep.size_sigaction = 20;
2193 amd64_x32_linux_record_tdep.size_sigset_t = 8;
2194 amd64_x32_linux_record_tdep.size_siginfo_t = 128;
2195 amd64_x32_linux_record_tdep.size_cap_user_data_t = 8;
2196 amd64_x32_linux_record_tdep.size_stack_t = 12;
2197 amd64_x32_linux_record_tdep.size_off_t = 8;
2198 amd64_x32_linux_record_tdep.size_stat64 = 144;
2199 amd64_x32_linux_record_tdep.size_gid_t = 4;
2200 amd64_x32_linux_record_tdep.size_uid_t = 4;
2201 amd64_x32_linux_record_tdep.size_PAGE_SIZE = 4096;
2202 amd64_x32_linux_record_tdep.size_flock64 = 32;
2203 amd64_x32_linux_record_tdep.size_user_desc = 16;
2204 amd64_x32_linux_record_tdep.size_io_event = 32;
2205 amd64_x32_linux_record_tdep.size_iocb = 64;
2206 amd64_x32_linux_record_tdep.size_epoll_event = 12;
2207 amd64_x32_linux_record_tdep.size_itimerspec = 32;
2208 amd64_x32_linux_record_tdep.size_mq_attr = 64;
2209 amd64_x32_linux_record_tdep.size_termios = 36;
2210 amd64_x32_linux_record_tdep.size_termios2 = 44;
2211 amd64_x32_linux_record_tdep.size_pid_t = 4;
2212 amd64_x32_linux_record_tdep.size_winsize = 8;
2213 amd64_x32_linux_record_tdep.size_serial_struct = 72;
2214 amd64_x32_linux_record_tdep.size_serial_icounter_struct = 80;
2215 amd64_x32_linux_record_tdep.size_hayes_esp_config = 12;
2216 amd64_x32_linux_record_tdep.size_size_t = 4;
2217 amd64_x32_linux_record_tdep.size_iovec = 8;
2218 amd64_x32_linux_record_tdep.size_time_t = 8;
2220 /* These values are the second argument of system call "sys_fcntl"
2221 and "sys_fcntl64". They are obtained from Linux Kernel source. */
2222 amd64_x32_linux_record_tdep.fcntl_F_GETLK = 5;
2223 amd64_x32_linux_record_tdep.fcntl_F_GETLK64 = 12;
2224 amd64_x32_linux_record_tdep.fcntl_F_SETLK64 = 13;
2225 amd64_x32_linux_record_tdep.fcntl_F_SETLKW64 = 14;
2227 amd64_x32_linux_record_tdep.arg1 = AMD64_RDI_REGNUM;
2228 amd64_x32_linux_record_tdep.arg2 = AMD64_RSI_REGNUM;
2229 amd64_x32_linux_record_tdep.arg3 = AMD64_RDX_REGNUM;
2230 amd64_x32_linux_record_tdep.arg4 = AMD64_R10_REGNUM;
2231 amd64_x32_linux_record_tdep.arg5 = AMD64_R8_REGNUM;
2232 amd64_x32_linux_record_tdep.arg6 = AMD64_R9_REGNUM;
2234 /* These values are the second argument of system call "sys_ioctl".
2235 They are obtained from Linux Kernel source. */
2236 amd64_x32_linux_record_tdep.ioctl_TCGETS = 0x5401;
2237 amd64_x32_linux_record_tdep.ioctl_TCSETS = 0x5402;
2238 amd64_x32_linux_record_tdep.ioctl_TCSETSW = 0x5403;
2239 amd64_x32_linux_record_tdep.ioctl_TCSETSF = 0x5404;
2240 amd64_x32_linux_record_tdep.ioctl_TCGETA = 0x5405;
2241 amd64_x32_linux_record_tdep.ioctl_TCSETA = 0x5406;
2242 amd64_x32_linux_record_tdep.ioctl_TCSETAW = 0x5407;
2243 amd64_x32_linux_record_tdep.ioctl_TCSETAF = 0x5408;
2244 amd64_x32_linux_record_tdep.ioctl_TCSBRK = 0x5409;
2245 amd64_x32_linux_record_tdep.ioctl_TCXONC = 0x540A;
2246 amd64_x32_linux_record_tdep.ioctl_TCFLSH = 0x540B;
2247 amd64_x32_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
2248 amd64_x32_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
2249 amd64_x32_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
2250 amd64_x32_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
2251 amd64_x32_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
2252 amd64_x32_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
2253 amd64_x32_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
2254 amd64_x32_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
2255 amd64_x32_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
2256 amd64_x32_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
2257 amd64_x32_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
2258 amd64_x32_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
2259 amd64_x32_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
2260 amd64_x32_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
2261 amd64_x32_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
2262 amd64_x32_linux_record_tdep.ioctl_FIONREAD = 0x541B;
2263 amd64_x32_linux_record_tdep.ioctl_TIOCINQ = amd64_x32_linux_record_tdep.ioctl_FIONREAD;
2264 amd64_x32_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
2265 amd64_x32_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
2266 amd64_x32_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
2267 amd64_x32_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
2268 amd64_x32_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
2269 amd64_x32_linux_record_tdep.ioctl_FIONBIO = 0x5421;
2270 amd64_x32_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
2271 amd64_x32_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
2272 amd64_x32_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
2273 amd64_x32_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
2274 amd64_x32_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
2275 amd64_x32_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
2276 amd64_x32_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
2277 amd64_x32_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
2278 amd64_x32_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
2279 amd64_x32_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
2280 amd64_x32_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
2281 amd64_x32_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
2282 amd64_x32_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
2283 amd64_x32_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
2284 amd64_x32_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
2285 amd64_x32_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
2286 amd64_x32_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
2287 amd64_x32_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
2288 amd64_x32_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
2289 amd64_x32_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
2290 amd64_x32_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
2291 amd64_x32_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
2292 amd64_x32_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
2293 amd64_x32_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
2294 amd64_x32_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
2295 amd64_x32_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
2296 amd64_x32_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
2297 amd64_x32_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
2298 amd64_x32_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
2299 amd64_x32_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
2300 amd64_x32_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
2302 tdep->i386_syscall_record = amd64_x32_linux_syscall_record;
2304 /* GNU/Linux uses SVR4-style shared libraries. */
2305 set_solib_svr4_fetch_link_map_offsets
2306 (gdbarch, linux_ilp32_fetch_link_map_offsets);
2309 void _initialize_amd64_linux_tdep ();
2310 void
2311 _initialize_amd64_linux_tdep ()
2313 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
2314 GDB_OSABI_LINUX, amd64_linux_init_abi);
2315 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32,
2316 GDB_OSABI_LINUX, amd64_x32_linux_init_abi);