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