1 /* Target-dependent code for GNU/Linux x86-64.
3 Copyright (C) 2001-2013 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/>. */
22 #include "arch-utils.h"
29 #include "reggroups.h"
31 #include "amd64-linux-tdep.h"
32 #include "i386-linux-tdep.h"
33 #include "linux-tdep.h"
34 #include "i386-xstate.h"
36 #include "gdb_string.h"
38 #include "amd64-tdep.h"
39 #include "solib-svr4.h"
40 #include "xml-syscall.h"
41 #include "glibc-tdep.h"
43 #include "features/i386/amd64-linux.c"
44 #include "features/i386/amd64-avx-linux.c"
45 #include "features/i386/x32-linux.c"
46 #include "features/i386/x32-avx-linux.c"
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 /* Supported register note sections. */
55 static struct core_regset_section amd64_linux_regset_sections[] =
57 { ".reg", 27 * 8, "general-purpose" },
58 { ".reg2", 512, "floating-point" },
59 { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
63 /* Mapping between the general-purpose registers in `struct user'
64 format and GDB's register cache layout. */
66 /* From <sys/reg.h>. */
67 int amd64_linux_gregset_reg_offset[] =
93 -1, -1, -1, -1, -1, -1, -1, -1,
94 -1, -1, -1, -1, -1, -1, -1, -1,
95 -1, -1, -1, -1, -1, -1, -1, -1,
96 -1, -1, -1, -1, -1, -1, -1, -1, -1,
97 -1, -1, -1, -1, -1, -1, -1, -1,
98 -1, -1, -1, -1, -1, -1, -1, -1,
99 15 * 8 /* "orig_rax" */
103 /* Support for signal handlers. */
105 #define LINUX_SIGTRAMP_INSN0 0x48 /* mov $NNNNNNNN, %rax */
106 #define LINUX_SIGTRAMP_OFFSET0 0
107 #define LINUX_SIGTRAMP_INSN1 0x0f /* syscall */
108 #define LINUX_SIGTRAMP_OFFSET1 7
110 static const gdb_byte amd64_linux_sigtramp_code[] =
112 /* mov $__NR_rt_sigreturn, %rax */
113 LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00,
115 LINUX_SIGTRAMP_INSN1, 0x05
118 static const gdb_byte amd64_x32_linux_sigtramp_code[] =
120 /* mov $__NR_rt_sigreturn, %rax. */
121 LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x01, 0x02, 0x00, 0x40,
123 LINUX_SIGTRAMP_INSN1, 0x05
126 #define LINUX_SIGTRAMP_LEN (sizeof amd64_linux_sigtramp_code)
128 /* If PC is in a sigtramp routine, return the address of the start of
129 the routine. Otherwise, return 0. */
132 amd64_linux_sigtramp_start (struct frame_info *this_frame)
134 struct gdbarch *gdbarch;
135 const gdb_byte *sigtramp_code;
136 CORE_ADDR pc = get_frame_pc (this_frame);
137 gdb_byte buf[LINUX_SIGTRAMP_LEN];
139 /* We only recognize a signal trampoline if PC is at the start of
140 one of the two instructions. We optimize for finding the PC at
141 the start, as will be the case when the trampoline is not the
142 first frame on the stack. We assume that in the case where the
143 PC is not at the start of the instruction sequence, there will be
144 a few trailing readable bytes on the stack. */
146 if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
149 if (buf[0] != LINUX_SIGTRAMP_INSN0)
151 if (buf[0] != LINUX_SIGTRAMP_INSN1)
154 pc -= LINUX_SIGTRAMP_OFFSET1;
155 if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
159 gdbarch = get_frame_arch (this_frame);
160 if (gdbarch_ptr_bit (gdbarch) == 32)
161 sigtramp_code = amd64_x32_linux_sigtramp_code;
163 sigtramp_code = amd64_linux_sigtramp_code;
164 if (memcmp (buf, sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
170 /* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
174 amd64_linux_sigtramp_p (struct frame_info *this_frame)
176 CORE_ADDR pc = get_frame_pc (this_frame);
179 find_pc_partial_function (pc, &name, NULL, NULL);
181 /* If we have NAME, we can optimize the search. The trampoline is
182 named __restore_rt. However, it isn't dynamically exported from
183 the shared C library, so the trampoline may appear to be part of
184 the preceding function. This should always be sigaction,
185 __sigaction, or __libc_sigaction (all aliases to the same
187 if (name == NULL || strstr (name, "sigaction") != NULL)
188 return (amd64_linux_sigtramp_start (this_frame) != 0);
190 return (strcmp ("__restore_rt", name) == 0);
193 /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
194 #define AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 40
196 /* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
197 address of the associated sigcontext structure. */
200 amd64_linux_sigcontext_addr (struct frame_info *this_frame)
202 struct gdbarch *gdbarch = get_frame_arch (this_frame);
203 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
207 get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
208 sp = extract_unsigned_integer (buf, 8, byte_order);
210 /* The sigcontext structure is part of the user context. A pointer
211 to the user context is passed as the third argument to the signal
212 handler, i.e. in %rdx. Unfortunately %rdx isn't preserved across
213 function calls so we can't use it. Fortunately the user context
214 is part of the signal frame and the unwound %rsp directly points
216 return sp + AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
221 amd64_linux_get_syscall_number (struct gdbarch *gdbarch,
224 struct regcache *regcache = get_thread_regcache (ptid);
225 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
226 /* The content of a register. */
231 /* Getting the system call number from the register.
232 When dealing with x86_64 architecture, this information
233 is stored at %rax register. */
234 regcache_cooked_read (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, buf);
236 ret = extract_signed_integer (buf, 8, byte_order);
242 /* From <asm/sigcontext.h>. */
243 static int amd64_linux_sc_reg_offset[] =
262 17 * 8, /* %eflags */
264 /* FIXME: kettenis/2002030531: The registers %cs, %fs and %gs are
265 available in `struct sigcontext'. However, they only occupy two
266 bytes instead of four, which makes using them here rather
267 difficult. Leave them out for now. */
277 amd64_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
278 struct reggroup *group)
280 if (regnum == AMD64_LINUX_ORIG_RAX_REGNUM)
281 return (group == system_reggroup
282 || group == save_reggroup
283 || group == restore_reggroup);
284 return i386_register_reggroup_p (gdbarch, regnum, group);
287 /* Set the program counter for process PTID to PC. */
290 amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
292 regcache_cooked_write_unsigned (regcache, AMD64_RIP_REGNUM, pc);
294 /* We must be careful with modifying the program counter. If we
295 just interrupted a system call, the kernel might try to restart
296 it when we resume the inferior. On restarting the system call,
297 the kernel will try backing up the program counter even though it
298 no longer points at the system call. This typically results in a
299 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
300 "orig_rax" pseudo-register.
302 Note that "orig_rax" is saved when setting up a dummy call frame.
303 This means that it is properly restored when that frame is
304 popped, and that the interrupted system call will be restarted
305 when we resume the inferior on return from a function call from
306 within GDB. In all other cases the system call will not be
308 regcache_cooked_write_unsigned (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, -1);
311 /* Record all registers but IP register for process-record. */
314 amd64_all_but_ip_registers_record (struct regcache *regcache)
316 if (record_full_arch_list_add_reg (regcache, AMD64_RAX_REGNUM))
318 if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
320 if (record_full_arch_list_add_reg (regcache, AMD64_RDX_REGNUM))
322 if (record_full_arch_list_add_reg (regcache, AMD64_RBX_REGNUM))
324 if (record_full_arch_list_add_reg (regcache, AMD64_RSP_REGNUM))
326 if (record_full_arch_list_add_reg (regcache, AMD64_RBP_REGNUM))
328 if (record_full_arch_list_add_reg (regcache, AMD64_RSI_REGNUM))
330 if (record_full_arch_list_add_reg (regcache, AMD64_RDI_REGNUM))
332 if (record_full_arch_list_add_reg (regcache, AMD64_R8_REGNUM))
334 if (record_full_arch_list_add_reg (regcache, AMD64_R9_REGNUM))
336 if (record_full_arch_list_add_reg (regcache, AMD64_R10_REGNUM))
338 if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
340 if (record_full_arch_list_add_reg (regcache, AMD64_R12_REGNUM))
342 if (record_full_arch_list_add_reg (regcache, AMD64_R13_REGNUM))
344 if (record_full_arch_list_add_reg (regcache, AMD64_R14_REGNUM))
346 if (record_full_arch_list_add_reg (regcache, AMD64_R15_REGNUM))
348 if (record_full_arch_list_add_reg (regcache, AMD64_EFLAGS_REGNUM))
354 /* amd64_canonicalize_syscall maps from the native amd64 Linux set
355 of syscall ids into a canonical set of syscall ids used by
358 static enum gdb_syscall
359 amd64_canonicalize_syscall (enum amd64_syscall syscall_number)
361 switch (syscall_number) {
365 case amd64_sys_write:
366 return gdb_sys_write;
371 case amd64_sys_close:
372 return gdb_sys_close;
374 case amd64_sys_newstat:
375 return gdb_sys_newstat;
377 case amd64_sys_newfstat:
378 return gdb_sys_newfstat;
380 case amd64_sys_newlstat:
381 return gdb_sys_newlstat;
386 case amd64_sys_lseek:
387 return gdb_sys_lseek;
390 return gdb_sys_mmap2;
392 case amd64_sys_mprotect:
393 return gdb_sys_mprotect;
395 case amd64_sys_munmap:
396 return gdb_sys_munmap;
401 case amd64_sys_rt_sigaction:
402 return gdb_sys_rt_sigaction;
404 case amd64_sys_rt_sigprocmask:
405 return gdb_sys_rt_sigprocmask;
407 case amd64_sys_rt_sigreturn:
408 return gdb_sys_rt_sigreturn;
410 case amd64_sys_ioctl:
411 return gdb_sys_ioctl;
413 case amd64_sys_pread64:
414 return gdb_sys_pread64;
416 case amd64_sys_pwrite64:
417 return gdb_sys_pwrite64;
419 case amd64_sys_readv:
420 return gdb_sys_readv;
422 case amd64_sys_writev:
423 return gdb_sys_writev;
425 case amd64_sys_access:
426 return gdb_sys_access;
431 case amd64_sys_select:
432 return gdb_sys_select;
434 case amd64_sys_sched_yield:
435 return gdb_sys_sched_yield;
437 case amd64_sys_mremap:
438 return gdb_sys_mremap;
440 case amd64_sys_msync:
441 return gdb_sys_msync;
443 case amd64_sys_mincore:
444 return gdb_sys_mincore;
446 case amd64_sys_madvise:
447 return gdb_sys_madvise;
449 case amd64_sys_shmget:
450 return gdb_sys_shmget;
452 case amd64_sys_shmat:
453 return gdb_sys_shmat;
455 case amd64_sys_shmctl:
456 return gdb_sys_shmctl;
464 case amd64_sys_pause:
465 return gdb_sys_pause;
467 case amd64_sys_nanosleep:
468 return gdb_sys_nanosleep;
470 case amd64_sys_getitimer:
471 return gdb_sys_getitimer;
473 case amd64_sys_alarm:
474 return gdb_sys_alarm;
476 case amd64_sys_setitimer:
477 return gdb_sys_setitimer;
479 case amd64_sys_getpid:
480 return gdb_sys_getpid;
482 case amd64_sys_sendfile64:
483 return gdb_sys_sendfile64;
485 case amd64_sys_socket:
486 return gdb_sys_socket;
488 case amd64_sys_connect:
489 return gdb_sys_connect;
491 case amd64_sys_accept:
492 return gdb_sys_accept;
494 case amd64_sys_sendto:
495 return gdb_sys_sendto;
497 case amd64_sys_recvfrom:
498 return gdb_sys_recvfrom;
500 case amd64_sys_sendmsg:
501 return gdb_sys_sendmsg;
503 case amd64_sys_recvmsg:
504 return gdb_sys_recvmsg;
506 case amd64_sys_shutdown:
507 return gdb_sys_shutdown;
512 case amd64_sys_listen:
513 return gdb_sys_listen;
515 case amd64_sys_getsockname:
516 return gdb_sys_getsockname;
518 case amd64_sys_getpeername:
519 return gdb_sys_getpeername;
521 case amd64_sys_socketpair:
522 return gdb_sys_socketpair;
524 case amd64_sys_setsockopt:
525 return gdb_sys_setsockopt;
527 case amd64_sys_getsockopt:
528 return gdb_sys_getsockopt;
530 case amd64_sys_clone:
531 return gdb_sys_clone;
536 case amd64_sys_vfork:
537 return gdb_sys_vfork;
539 case amd64_sys_execve:
540 return gdb_sys_execve;
545 case amd64_sys_wait4:
546 return gdb_sys_wait4;
551 case amd64_sys_uname:
552 return gdb_sys_uname;
554 case amd64_sys_semget:
555 return gdb_sys_semget;
557 case amd64_sys_semop:
558 return gdb_sys_semop;
560 case amd64_sys_semctl:
561 return gdb_sys_semctl;
563 case amd64_sys_shmdt:
564 return gdb_sys_shmdt;
566 case amd64_sys_msgget:
567 return gdb_sys_msgget;
569 case amd64_sys_msgsnd:
570 return gdb_sys_msgsnd;
572 case amd64_sys_msgrcv:
573 return gdb_sys_msgrcv;
575 case amd64_sys_msgctl:
576 return gdb_sys_msgctl;
578 case amd64_sys_fcntl:
579 return gdb_sys_fcntl;
581 case amd64_sys_flock:
582 return gdb_sys_flock;
584 case amd64_sys_fsync:
585 return gdb_sys_fsync;
587 case amd64_sys_fdatasync:
588 return gdb_sys_fdatasync;
590 case amd64_sys_truncate:
591 return gdb_sys_truncate;
593 case amd64_sys_ftruncate:
594 return gdb_sys_ftruncate;
596 case amd64_sys_getdents:
597 return gdb_sys_getdents;
599 case amd64_sys_getcwd:
600 return gdb_sys_getcwd;
602 case amd64_sys_chdir:
603 return gdb_sys_chdir;
605 case amd64_sys_fchdir:
606 return gdb_sys_fchdir;
608 case amd64_sys_rename:
609 return gdb_sys_rename;
611 case amd64_sys_mkdir:
612 return gdb_sys_mkdir;
614 case amd64_sys_rmdir:
615 return gdb_sys_rmdir;
617 case amd64_sys_creat:
618 return gdb_sys_creat;
623 case amd64_sys_unlink:
624 return gdb_sys_unlink;
626 case amd64_sys_symlink:
627 return gdb_sys_symlink;
629 case amd64_sys_readlink:
630 return gdb_sys_readlink;
632 case amd64_sys_chmod:
633 return gdb_sys_chmod;
635 case amd64_sys_fchmod:
636 return gdb_sys_fchmod;
638 case amd64_sys_chown:
639 return gdb_sys_chown;
641 case amd64_sys_fchown:
642 return gdb_sys_fchown;
644 case amd64_sys_lchown:
645 return gdb_sys_lchown;
647 case amd64_sys_umask:
648 return gdb_sys_umask;
650 case amd64_sys_gettimeofday:
651 return gdb_sys_gettimeofday;
653 case amd64_sys_getrlimit:
654 return gdb_sys_getrlimit;
656 case amd64_sys_getrusage:
657 return gdb_sys_getrusage;
659 case amd64_sys_sysinfo:
660 return gdb_sys_sysinfo;
662 case amd64_sys_times:
663 return gdb_sys_times;
665 case amd64_sys_ptrace:
666 return gdb_sys_ptrace;
668 case amd64_sys_getuid:
669 return gdb_sys_getuid;
671 case amd64_sys_syslog:
672 return gdb_sys_syslog;
674 case amd64_sys_getgid:
675 return gdb_sys_getgid;
677 case amd64_sys_setuid:
678 return gdb_sys_setuid;
680 case amd64_sys_setgid:
681 return gdb_sys_setgid;
683 case amd64_sys_geteuid:
684 return gdb_sys_geteuid;
686 case amd64_sys_getegid:
687 return gdb_sys_getegid;
689 case amd64_sys_setpgid:
690 return gdb_sys_setpgid;
692 case amd64_sys_getppid:
693 return gdb_sys_getppid;
695 case amd64_sys_getpgrp:
696 return gdb_sys_getpgrp;
698 case amd64_sys_setsid:
699 return gdb_sys_setsid;
701 case amd64_sys_setreuid:
702 return gdb_sys_setreuid;
704 case amd64_sys_setregid:
705 return gdb_sys_setregid;
707 case amd64_sys_getgroups:
708 return gdb_sys_getgroups;
710 case amd64_sys_setgroups:
711 return gdb_sys_setgroups;
713 case amd64_sys_setresuid:
714 return gdb_sys_setresuid;
716 case amd64_sys_getresuid:
717 return gdb_sys_getresuid;
719 case amd64_sys_setresgid:
720 return gdb_sys_setresgid;
722 case amd64_sys_getresgid:
723 return gdb_sys_getresgid;
725 case amd64_sys_getpgid:
726 return gdb_sys_getpgid;
728 case amd64_sys_setfsuid:
729 return gdb_sys_setfsuid;
731 case amd64_sys_setfsgid:
732 return gdb_sys_setfsgid;
734 case amd64_sys_getsid:
735 return gdb_sys_getsid;
737 case amd64_sys_capget:
738 return gdb_sys_capget;
740 case amd64_sys_capset:
741 return gdb_sys_capset;
743 case amd64_sys_rt_sigpending:
744 return gdb_sys_rt_sigpending;
746 case amd64_sys_rt_sigtimedwait:
747 return gdb_sys_rt_sigtimedwait;
749 case amd64_sys_rt_sigqueueinfo:
750 return gdb_sys_rt_sigqueueinfo;
752 case amd64_sys_rt_sigsuspend:
753 return gdb_sys_rt_sigsuspend;
755 case amd64_sys_sigaltstack:
756 return gdb_sys_sigaltstack;
758 case amd64_sys_utime:
759 return gdb_sys_utime;
761 case amd64_sys_mknod:
762 return gdb_sys_mknod;
764 case amd64_sys_personality:
765 return gdb_sys_personality;
767 case amd64_sys_ustat:
768 return gdb_sys_ustat;
770 case amd64_sys_statfs:
771 return gdb_sys_statfs;
773 case amd64_sys_fstatfs:
774 return gdb_sys_fstatfs;
776 case amd64_sys_sysfs:
777 return gdb_sys_sysfs;
779 case amd64_sys_getpriority:
780 return gdb_sys_getpriority;
782 case amd64_sys_setpriority:
783 return gdb_sys_setpriority;
785 case amd64_sys_sched_setparam:
786 return gdb_sys_sched_setparam;
788 case amd64_sys_sched_getparam:
789 return gdb_sys_sched_getparam;
791 case amd64_sys_sched_setscheduler:
792 return gdb_sys_sched_setscheduler;
794 case amd64_sys_sched_getscheduler:
795 return gdb_sys_sched_getscheduler;
797 case amd64_sys_sched_get_priority_max:
798 return gdb_sys_sched_get_priority_max;
800 case amd64_sys_sched_get_priority_min:
801 return gdb_sys_sched_get_priority_min;
803 case amd64_sys_sched_rr_get_interval:
804 return gdb_sys_sched_rr_get_interval;
806 case amd64_sys_mlock:
807 return gdb_sys_mlock;
809 case amd64_sys_munlock:
810 return gdb_sys_munlock;
812 case amd64_sys_mlockall:
813 return gdb_sys_mlockall;
815 case amd64_sys_munlockall:
816 return gdb_sys_munlockall;
818 case amd64_sys_vhangup:
819 return gdb_sys_vhangup;
821 case amd64_sys_modify_ldt:
822 return gdb_sys_modify_ldt;
824 case amd64_sys_pivot_root:
825 return gdb_sys_pivot_root;
827 case amd64_sys_sysctl:
828 return gdb_sys_sysctl;
830 case amd64_sys_prctl:
831 return gdb_sys_prctl;
833 case amd64_sys_arch_prctl:
834 return -1; /* Note */
836 case amd64_sys_adjtimex:
837 return gdb_sys_adjtimex;
839 case amd64_sys_setrlimit:
840 return gdb_sys_setrlimit;
842 case amd64_sys_chroot:
843 return gdb_sys_chroot;
851 case amd64_sys_settimeofday:
852 return gdb_sys_settimeofday;
854 case amd64_sys_mount:
855 return gdb_sys_mount;
857 case amd64_sys_umount:
858 return gdb_sys_umount;
860 case amd64_sys_swapon:
861 return gdb_sys_swapon;
863 case amd64_sys_swapoff:
864 return gdb_sys_swapoff;
866 case amd64_sys_reboot:
867 return gdb_sys_reboot;
869 case amd64_sys_sethostname:
870 return gdb_sys_sethostname;
872 case amd64_sys_setdomainname:
873 return gdb_sys_setdomainname;
878 case amd64_sys_ioperm:
879 return gdb_sys_ioperm;
881 case amd64_sys_init_module:
882 return gdb_sys_init_module;
884 case amd64_sys_delete_module:
885 return gdb_sys_delete_module;
887 case amd64_sys_quotactl:
888 return gdb_sys_quotactl;
890 case amd64_sys_nfsservctl:
891 return gdb_sys_nfsservctl;
893 case amd64_sys_gettid:
894 return gdb_sys_gettid;
896 case amd64_sys_readahead:
897 return gdb_sys_readahead;
899 case amd64_sys_setxattr:
900 return gdb_sys_setxattr;
902 case amd64_sys_lsetxattr:
903 return gdb_sys_lsetxattr;
905 case amd64_sys_fsetxattr:
906 return gdb_sys_fsetxattr;
908 case amd64_sys_getxattr:
909 return gdb_sys_getxattr;
911 case amd64_sys_lgetxattr:
912 return gdb_sys_lgetxattr;
914 case amd64_sys_fgetxattr:
915 return gdb_sys_fgetxattr;
917 case amd64_sys_listxattr:
918 return gdb_sys_listxattr;
920 case amd64_sys_llistxattr:
921 return gdb_sys_llistxattr;
923 case amd64_sys_flistxattr:
924 return gdb_sys_flistxattr;
926 case amd64_sys_removexattr:
927 return gdb_sys_removexattr;
929 case amd64_sys_lremovexattr:
930 return gdb_sys_lremovexattr;
932 case amd64_sys_fremovexattr:
933 return gdb_sys_fremovexattr;
935 case amd64_sys_tkill:
936 return gdb_sys_tkill;
941 case amd64_sys_futex:
942 return gdb_sys_futex;
944 case amd64_sys_sched_setaffinity:
945 return gdb_sys_sched_setaffinity;
947 case amd64_sys_sched_getaffinity:
948 return gdb_sys_sched_getaffinity;
950 case amd64_sys_io_setup:
951 return gdb_sys_io_setup;
953 case amd64_sys_io_destroy:
954 return gdb_sys_io_destroy;
956 case amd64_sys_io_getevents:
957 return gdb_sys_io_getevents;
959 case amd64_sys_io_submit:
960 return gdb_sys_io_submit;
962 case amd64_sys_io_cancel:
963 return gdb_sys_io_cancel;
965 case amd64_sys_lookup_dcookie:
966 return gdb_sys_lookup_dcookie;
968 case amd64_sys_epoll_create:
969 return gdb_sys_epoll_create;
971 case amd64_sys_remap_file_pages:
972 return gdb_sys_remap_file_pages;
974 case amd64_sys_getdents64:
975 return gdb_sys_getdents64;
977 case amd64_sys_set_tid_address:
978 return gdb_sys_set_tid_address;
980 case amd64_sys_restart_syscall:
981 return gdb_sys_restart_syscall;
983 case amd64_sys_semtimedop:
984 return gdb_sys_semtimedop;
986 case amd64_sys_fadvise64:
987 return gdb_sys_fadvise64;
989 case amd64_sys_timer_create:
990 return gdb_sys_timer_create;
992 case amd64_sys_timer_settime:
993 return gdb_sys_timer_settime;
995 case amd64_sys_timer_gettime:
996 return gdb_sys_timer_gettime;
998 case amd64_sys_timer_getoverrun:
999 return gdb_sys_timer_getoverrun;
1001 case amd64_sys_timer_delete:
1002 return gdb_sys_timer_delete;
1004 case amd64_sys_clock_settime:
1005 return gdb_sys_clock_settime;
1007 case amd64_sys_clock_gettime:
1008 return gdb_sys_clock_gettime;
1010 case amd64_sys_clock_getres:
1011 return gdb_sys_clock_getres;
1013 case amd64_sys_clock_nanosleep:
1014 return gdb_sys_clock_nanosleep;
1016 case amd64_sys_exit_group:
1017 return gdb_sys_exit_group;
1019 case amd64_sys_epoll_wait:
1020 return gdb_sys_epoll_wait;
1022 case amd64_sys_epoll_ctl:
1023 return gdb_sys_epoll_ctl;
1025 case amd64_sys_tgkill:
1026 return gdb_sys_tgkill;
1028 case amd64_sys_utimes:
1029 return gdb_sys_utimes;
1031 case amd64_sys_mbind:
1032 return gdb_sys_mbind;
1034 case amd64_sys_set_mempolicy:
1035 return gdb_sys_set_mempolicy;
1037 case amd64_sys_get_mempolicy:
1038 return gdb_sys_get_mempolicy;
1040 case amd64_sys_mq_open:
1041 return gdb_sys_mq_open;
1043 case amd64_sys_mq_unlink:
1044 return gdb_sys_mq_unlink;
1046 case amd64_sys_mq_timedsend:
1047 return gdb_sys_mq_timedsend;
1049 case amd64_sys_mq_timedreceive:
1050 return gdb_sys_mq_timedreceive;
1052 case amd64_sys_mq_notify:
1053 return gdb_sys_mq_notify;
1055 case amd64_sys_mq_getsetattr:
1056 return gdb_sys_mq_getsetattr;
1058 case amd64_sys_kexec_load:
1059 return gdb_sys_kexec_load;
1061 case amd64_sys_waitid:
1062 return gdb_sys_waitid;
1064 case amd64_sys_add_key:
1065 return gdb_sys_add_key;
1067 case amd64_sys_request_key:
1068 return gdb_sys_request_key;
1070 case amd64_sys_keyctl:
1071 return gdb_sys_keyctl;
1073 case amd64_sys_ioprio_set:
1074 return gdb_sys_ioprio_set;
1076 case amd64_sys_ioprio_get:
1077 return gdb_sys_ioprio_get;
1079 case amd64_sys_inotify_init:
1080 return gdb_sys_inotify_init;
1082 case amd64_sys_inotify_add_watch:
1083 return gdb_sys_inotify_add_watch;
1085 case amd64_sys_inotify_rm_watch:
1086 return gdb_sys_inotify_rm_watch;
1088 case amd64_sys_migrate_pages:
1089 return gdb_sys_migrate_pages;
1091 case amd64_sys_openat:
1092 return gdb_sys_openat;
1094 case amd64_sys_mkdirat:
1095 return gdb_sys_mkdirat;
1097 case amd64_sys_mknodat:
1098 return gdb_sys_mknodat;
1100 case amd64_sys_fchownat:
1101 return gdb_sys_fchownat;
1103 case amd64_sys_futimesat:
1104 return gdb_sys_futimesat;
1106 case amd64_sys_newfstatat:
1107 return gdb_sys_newfstatat;
1109 case amd64_sys_unlinkat:
1110 return gdb_sys_unlinkat;
1112 case amd64_sys_renameat:
1113 return gdb_sys_renameat;
1115 case amd64_sys_linkat:
1116 return gdb_sys_linkat;
1118 case amd64_sys_symlinkat:
1119 return gdb_sys_symlinkat;
1121 case amd64_sys_readlinkat:
1122 return gdb_sys_readlinkat;
1124 case amd64_sys_fchmodat:
1125 return gdb_sys_fchmodat;
1127 case amd64_sys_faccessat:
1128 return gdb_sys_faccessat;
1130 case amd64_sys_pselect6:
1131 return gdb_sys_pselect6;
1133 case amd64_sys_ppoll:
1134 return gdb_sys_ppoll;
1136 case amd64_sys_unshare:
1137 return gdb_sys_unshare;
1139 case amd64_sys_set_robust_list:
1140 return gdb_sys_set_robust_list;
1142 case amd64_sys_get_robust_list:
1143 return gdb_sys_get_robust_list;
1145 case amd64_sys_splice:
1146 return gdb_sys_splice;
1151 case amd64_sys_sync_file_range:
1152 return gdb_sys_sync_file_range;
1154 case amd64_sys_vmsplice:
1155 return gdb_sys_vmsplice;
1157 case amd64_sys_move_pages:
1158 return gdb_sys_move_pages;
1165 /* Parse the arguments of current system call instruction and record
1166 the values of the registers and memory that will be changed into
1167 "record_full_arch_list". This instruction is "syscall".
1169 Return -1 if something wrong. */
1171 static struct linux_record_tdep amd64_linux_record_tdep;
1173 #define RECORD_ARCH_GET_FS 0x1003
1174 #define RECORD_ARCH_GET_GS 0x1004
1177 amd64_linux_syscall_record (struct regcache *regcache)
1180 ULONGEST syscall_native;
1181 enum gdb_syscall syscall_gdb = -1;
1183 regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &syscall_native);
1185 switch (syscall_native)
1187 case amd64_sys_rt_sigreturn:
1188 if (amd64_all_but_ip_registers_record (regcache))
1193 case amd64_sys_arch_prctl:
1197 regcache_raw_read_unsigned (regcache, amd64_linux_record_tdep.arg3,
1199 if (arg3 == RECORD_ARCH_GET_FS || arg3 == RECORD_ARCH_GET_GS)
1203 regcache_raw_read_unsigned (regcache,
1204 amd64_linux_record_tdep.arg2,
1206 if (record_full_arch_list_add_mem
1207 (addr, amd64_linux_record_tdep.size_ulong))
1215 syscall_gdb = amd64_canonicalize_syscall (syscall_native);
1217 if (syscall_gdb < 0)
1219 printf_unfiltered (_("Process record and replay target doesn't "
1220 "support syscall number %s\n"),
1221 pulongest (syscall_native));
1226 ret = record_linux_system_call (syscall_gdb, regcache,
1227 &amd64_linux_record_tdep);
1233 /* Record the return value of the system call. */
1234 if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
1236 if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
1242 #define AMD64_LINUX_redzone 128
1243 #define AMD64_LINUX_xstate 512
1244 #define AMD64_LINUX_frame_size 560
1247 amd64_linux_record_signal (struct gdbarch *gdbarch,
1248 struct regcache *regcache,
1249 enum gdb_signal signal)
1253 if (amd64_all_but_ip_registers_record (regcache))
1256 if (record_full_arch_list_add_reg (regcache, AMD64_RIP_REGNUM))
1259 /* Record the change in the stack. */
1260 regcache_raw_read_unsigned (regcache, AMD64_RSP_REGNUM, &rsp);
1263 rsp -= AMD64_LINUX_redzone;
1264 /* This is for xstate.
1265 sp -= sizeof (struct _fpstate); */
1266 rsp -= AMD64_LINUX_xstate;
1267 /* This is for frame_size.
1268 sp -= sizeof (struct rt_sigframe); */
1269 rsp -= AMD64_LINUX_frame_size;
1270 if (record_full_arch_list_add_mem (rsp, AMD64_LINUX_redzone
1271 + AMD64_LINUX_xstate
1272 + AMD64_LINUX_frame_size))
1275 if (record_full_arch_list_add_end ())
1281 /* Get Linux/x86 target description from core dump. */
1283 static const struct target_desc *
1284 amd64_linux_core_read_description (struct gdbarch *gdbarch,
1285 struct target_ops *target,
1289 uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
1290 switch ((xcr0 & I386_XSTATE_AVX_MASK))
1292 case I386_XSTATE_AVX_MASK:
1293 if (gdbarch_ptr_bit (gdbarch) == 32)
1294 return tdesc_x32_avx_linux;
1296 return tdesc_amd64_avx_linux;
1298 if (gdbarch_ptr_bit (gdbarch) == 32)
1299 return tdesc_x32_linux;
1301 return tdesc_amd64_linux;
1306 amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
1308 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1310 linux_init_abi (info, gdbarch);
1312 tdep->sigtramp_p = amd64_linux_sigtramp_p;
1313 tdep->sigcontext_addr = amd64_linux_sigcontext_addr;
1314 tdep->sc_reg_offset = amd64_linux_sc_reg_offset;
1315 tdep->sc_num_regs = ARRAY_SIZE (amd64_linux_sc_reg_offset);
1317 tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET;
1319 /* Add the %orig_rax register used for syscall restarting. */
1320 set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc);
1322 tdep->register_reggroup_p = amd64_linux_register_reggroup_p;
1324 /* Functions for 'catch syscall'. */
1325 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_AMD64);
1326 set_gdbarch_get_syscall_number (gdbarch,
1327 amd64_linux_get_syscall_number);
1329 /* Enable TLS support. */
1330 set_gdbarch_fetch_tls_load_module_address (gdbarch,
1331 svr4_fetch_objfile_link_map);
1333 /* GNU/Linux uses SVR4-style shared libraries. */
1334 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
1336 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
1337 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
1339 /* Install supported register note sections. */
1340 set_gdbarch_core_regset_sections (gdbarch, amd64_linux_regset_sections);
1342 set_gdbarch_core_read_description (gdbarch,
1343 amd64_linux_core_read_description);
1345 /* Displaced stepping. */
1346 set_gdbarch_displaced_step_copy_insn (gdbarch,
1347 amd64_displaced_step_copy_insn);
1348 set_gdbarch_displaced_step_fixup (gdbarch, amd64_displaced_step_fixup);
1349 set_gdbarch_displaced_step_free_closure (gdbarch,
1350 simple_displaced_step_free_closure);
1351 set_gdbarch_displaced_step_location (gdbarch,
1352 displaced_step_at_entry_point);
1354 set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
1356 set_gdbarch_process_record (gdbarch, i386_process_record);
1357 set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
1359 /* Initialize the amd64_linux_record_tdep. */
1360 /* These values are the size of the type that will be used in a system
1361 call. They are obtained from Linux Kernel source. */
1362 amd64_linux_record_tdep.size_pointer
1363 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
1364 amd64_linux_record_tdep.size__old_kernel_stat = 32;
1365 amd64_linux_record_tdep.size_tms = 32;
1366 amd64_linux_record_tdep.size_loff_t = 8;
1367 amd64_linux_record_tdep.size_flock = 32;
1368 amd64_linux_record_tdep.size_oldold_utsname = 45;
1369 amd64_linux_record_tdep.size_ustat = 32;
1370 /* ADM64 doesn't need this size because it doesn't have sys_sigaction
1371 but sys_rt_sigaction. */
1372 amd64_linux_record_tdep.size_old_sigaction = 152;
1373 /* ADM64 doesn't need this size because it doesn't have sys_sigpending
1374 but sys_rt_sigpending. */
1375 amd64_linux_record_tdep.size_old_sigset_t = 128;
1376 amd64_linux_record_tdep.size_rlimit = 16;
1377 amd64_linux_record_tdep.size_rusage = 144;
1378 amd64_linux_record_tdep.size_timeval = 16;
1379 amd64_linux_record_tdep.size_timezone = 8;
1380 /* ADM64 doesn't need this size because it doesn't have sys_getgroups16
1381 but sys_getgroups. */
1382 amd64_linux_record_tdep.size_old_gid_t = 2;
1383 /* ADM64 doesn't need this size because it doesn't have sys_getresuid16
1384 but sys_getresuid. */
1385 amd64_linux_record_tdep.size_old_uid_t = 2;
1386 amd64_linux_record_tdep.size_fd_set = 128;
1387 amd64_linux_record_tdep.size_dirent = 280;
1388 amd64_linux_record_tdep.size_dirent64 = 280;
1389 amd64_linux_record_tdep.size_statfs = 120;
1390 amd64_linux_record_tdep.size_statfs64 = 120;
1391 amd64_linux_record_tdep.size_sockaddr = 16;
1392 amd64_linux_record_tdep.size_int
1393 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
1394 amd64_linux_record_tdep.size_long
1395 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1396 amd64_linux_record_tdep.size_ulong
1397 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1398 amd64_linux_record_tdep.size_msghdr = 56;
1399 amd64_linux_record_tdep.size_itimerval = 32;
1400 amd64_linux_record_tdep.size_stat = 144;
1401 amd64_linux_record_tdep.size_old_utsname = 325;
1402 amd64_linux_record_tdep.size_sysinfo = 112;
1403 amd64_linux_record_tdep.size_msqid_ds = 120;
1404 amd64_linux_record_tdep.size_shmid_ds = 112;
1405 amd64_linux_record_tdep.size_new_utsname = 390;
1406 amd64_linux_record_tdep.size_timex = 208;
1407 amd64_linux_record_tdep.size_mem_dqinfo = 24;
1408 amd64_linux_record_tdep.size_if_dqblk = 72;
1409 amd64_linux_record_tdep.size_fs_quota_stat = 80;
1410 amd64_linux_record_tdep.size_timespec = 16;
1411 amd64_linux_record_tdep.size_pollfd = 8;
1412 amd64_linux_record_tdep.size_NFS_FHSIZE = 32;
1413 amd64_linux_record_tdep.size_knfsd_fh = 132;
1414 amd64_linux_record_tdep.size_TASK_COMM_LEN = 16;
1415 amd64_linux_record_tdep.size_sigaction = 152;
1416 amd64_linux_record_tdep.size_sigset_t = 128;
1417 amd64_linux_record_tdep.size_siginfo_t = 128;
1418 amd64_linux_record_tdep.size_cap_user_data_t = 8;
1419 amd64_linux_record_tdep.size_stack_t = 24;
1420 amd64_linux_record_tdep.size_off_t = 8;
1421 amd64_linux_record_tdep.size_stat64 = 144;
1422 amd64_linux_record_tdep.size_gid_t = 4;
1423 amd64_linux_record_tdep.size_uid_t = 4;
1424 amd64_linux_record_tdep.size_PAGE_SIZE = 4096;
1425 amd64_linux_record_tdep.size_flock64 = 32;
1426 amd64_linux_record_tdep.size_user_desc = 16;
1427 amd64_linux_record_tdep.size_io_event = 32;
1428 amd64_linux_record_tdep.size_iocb = 64;
1429 amd64_linux_record_tdep.size_epoll_event = 12;
1430 amd64_linux_record_tdep.size_itimerspec = 32;
1431 amd64_linux_record_tdep.size_mq_attr = 64;
1432 amd64_linux_record_tdep.size_siginfo = 128;
1433 amd64_linux_record_tdep.size_termios = 60;
1434 amd64_linux_record_tdep.size_termios2 = 44;
1435 amd64_linux_record_tdep.size_pid_t = 4;
1436 amd64_linux_record_tdep.size_winsize = 8;
1437 amd64_linux_record_tdep.size_serial_struct = 72;
1438 amd64_linux_record_tdep.size_serial_icounter_struct = 80;
1439 amd64_linux_record_tdep.size_hayes_esp_config = 12;
1440 amd64_linux_record_tdep.size_size_t = 8;
1441 amd64_linux_record_tdep.size_iovec = 16;
1443 /* These values are the second argument of system call "sys_ioctl".
1444 They are obtained from Linux Kernel source. */
1445 amd64_linux_record_tdep.ioctl_TCGETS = 0x5401;
1446 amd64_linux_record_tdep.ioctl_TCSETS = 0x5402;
1447 amd64_linux_record_tdep.ioctl_TCSETSW = 0x5403;
1448 amd64_linux_record_tdep.ioctl_TCSETSF = 0x5404;
1449 amd64_linux_record_tdep.ioctl_TCGETA = 0x5405;
1450 amd64_linux_record_tdep.ioctl_TCSETA = 0x5406;
1451 amd64_linux_record_tdep.ioctl_TCSETAW = 0x5407;
1452 amd64_linux_record_tdep.ioctl_TCSETAF = 0x5408;
1453 amd64_linux_record_tdep.ioctl_TCSBRK = 0x5409;
1454 amd64_linux_record_tdep.ioctl_TCXONC = 0x540A;
1455 amd64_linux_record_tdep.ioctl_TCFLSH = 0x540B;
1456 amd64_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
1457 amd64_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
1458 amd64_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
1459 amd64_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
1460 amd64_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
1461 amd64_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
1462 amd64_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
1463 amd64_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
1464 amd64_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
1465 amd64_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
1466 amd64_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
1467 amd64_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
1468 amd64_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
1469 amd64_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
1470 amd64_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
1471 amd64_linux_record_tdep.ioctl_FIONREAD = 0x541B;
1472 amd64_linux_record_tdep.ioctl_TIOCINQ
1473 = amd64_linux_record_tdep.ioctl_FIONREAD;
1474 amd64_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
1475 amd64_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
1476 amd64_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
1477 amd64_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
1478 amd64_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
1479 amd64_linux_record_tdep.ioctl_FIONBIO = 0x5421;
1480 amd64_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
1481 amd64_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
1482 amd64_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
1483 amd64_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
1484 amd64_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
1485 amd64_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
1486 amd64_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
1487 amd64_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
1488 amd64_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
1489 amd64_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
1490 amd64_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
1491 amd64_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
1492 amd64_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
1493 amd64_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
1494 amd64_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
1495 amd64_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
1496 amd64_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
1497 amd64_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
1498 amd64_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
1499 amd64_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
1500 amd64_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
1501 amd64_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
1502 amd64_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
1503 amd64_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
1504 amd64_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
1505 amd64_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
1506 amd64_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
1507 amd64_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
1508 amd64_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
1509 amd64_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
1510 amd64_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
1512 /* These values are the second argument of system call "sys_fcntl"
1513 and "sys_fcntl64". They are obtained from Linux Kernel source. */
1514 amd64_linux_record_tdep.fcntl_F_GETLK = 5;
1515 amd64_linux_record_tdep.fcntl_F_GETLK64 = 12;
1516 amd64_linux_record_tdep.fcntl_F_SETLK64 = 13;
1517 amd64_linux_record_tdep.fcntl_F_SETLKW64 = 14;
1519 amd64_linux_record_tdep.arg1 = AMD64_RDI_REGNUM;
1520 amd64_linux_record_tdep.arg2 = AMD64_RSI_REGNUM;
1521 amd64_linux_record_tdep.arg3 = AMD64_RDX_REGNUM;
1522 amd64_linux_record_tdep.arg4 = AMD64_R10_REGNUM;
1523 amd64_linux_record_tdep.arg5 = AMD64_R8_REGNUM;
1524 amd64_linux_record_tdep.arg6 = AMD64_R9_REGNUM;
1526 tdep->i386_syscall_record = amd64_linux_syscall_record;
1530 amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1532 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1533 const struct target_desc *tdesc = info.target_desc;
1534 struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
1535 const struct tdesc_feature *feature;
1538 gdb_assert (tdesc_data);
1540 tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
1541 tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
1542 tdep->sizeof_gregset = 27 * 8;
1544 amd64_init_abi (info, gdbarch);
1546 /* Reserve a number for orig_rax. */
1547 set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
1549 if (! tdesc_has_registers (tdesc))
1550 tdesc = tdesc_amd64_linux;
1551 tdep->tdesc = tdesc;
1553 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
1554 if (feature == NULL)
1557 valid_p = tdesc_numbered_register (feature, tdesc_data,
1558 AMD64_LINUX_ORIG_RAX_REGNUM,
1563 amd64_linux_init_abi_common (info, gdbarch);
1565 /* GNU/Linux uses SVR4-style shared libraries. */
1566 set_solib_svr4_fetch_link_map_offsets
1567 (gdbarch, svr4_lp64_fetch_link_map_offsets);
1571 amd64_x32_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
1573 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1574 const struct target_desc *tdesc = info.target_desc;
1575 struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
1576 const struct tdesc_feature *feature;
1579 gdb_assert (tdesc_data);
1581 tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
1582 tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
1583 tdep->sizeof_gregset = 27 * 8;
1585 amd64_x32_init_abi (info, gdbarch);
1587 /* Reserve a number for orig_rax. */
1588 set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
1590 if (! tdesc_has_registers (tdesc))
1591 tdesc = tdesc_x32_linux;
1592 tdep->tdesc = tdesc;
1594 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
1595 if (feature == NULL)
1598 valid_p = tdesc_numbered_register (feature, tdesc_data,
1599 AMD64_LINUX_ORIG_RAX_REGNUM,
1604 amd64_linux_init_abi_common (info, gdbarch);
1606 /* GNU/Linux uses SVR4-style shared libraries. */
1607 set_solib_svr4_fetch_link_map_offsets
1608 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
1612 /* Provide a prototype to silence -Wmissing-prototypes. */
1613 extern void _initialize_amd64_linux_tdep (void);
1616 _initialize_amd64_linux_tdep (void)
1618 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
1619 GDB_OSABI_LINUX, amd64_linux_init_abi);
1620 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32,
1621 GDB_OSABI_LINUX, amd64_x32_linux_init_abi);
1623 /* Initialize the Linux target description. */
1624 initialize_tdesc_amd64_linux ();
1625 initialize_tdesc_amd64_avx_linux ();
1626 initialize_tdesc_x32_linux ();
1627 initialize_tdesc_x32_avx_linux ();