Support amd64 AVX.
[deliverable/binutils-gdb.git] / gdb / amd64-linux-tdep.c
CommitLineData
51433e4b 1/* Target-dependent code for GNU/Linux x86-64.
a4b6fc86 2
4c38e0a4 3 Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
6aba47ca 4 Free Software Foundation, Inc.
53e95fcf
JS
5 Contributed by Jiri Smid, SuSE Labs.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
53e95fcf
JS
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
53e95fcf
JS
21
22#include "defs.h"
35669430 23#include "arch-utils.h"
187e21d1 24#include "frame.h"
53e95fcf
JS
25#include "gdbcore.h"
26#include "regcache.h"
84dc46cb 27#include "osabi.h"
911bc6ee 28#include "symtab.h"
8695c747
DJ
29#include "gdbtypes.h"
30#include "reggroups.h"
a055a187 31#include "regset.h"
8695c747 32#include "amd64-linux-tdep.h"
a055a187 33#include "i386-linux-tdep.h"
4aa995e1 34#include "linux-tdep.h"
a055a187 35#include "i386-xstate.h"
53e95fcf 36
c4f35dd8 37#include "gdb_string.h"
53e95fcf 38
9c1488cb 39#include "amd64-tdep.h"
187e21d1 40#include "solib-svr4.h"
a96d9b2e
SDJ
41#include "xml-syscall.h"
42
90884b2b 43#include "features/i386/amd64-linux.c"
a055a187 44#include "features/i386/amd64-avx-linux.c"
90884b2b 45
a96d9b2e
SDJ
46/* The syscall's XML filename for i386. */
47#define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
eba29c8c 48
952b2d63
HZ
49#include "record.h"
50#include "linux-record.h"
51
a055a187
L
52/* Supported register note sections. */
53static struct core_regset_section amd64_linux_regset_sections[] =
54{
55 { ".reg", 144, "general-purpose" },
56 { ".reg2", 512, "floating-point" },
57 { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
58 { NULL, 0 }
59};
60
eba29c8c 61/* Mapping between the general-purpose registers in `struct user'
187e21d1 62 format and GDB's register cache layout. */
eba29c8c 63
187e21d1
MK
64/* From <sys/reg.h>. */
65static int amd64_linux_gregset_reg_offset[] =
eba29c8c 66{
187e21d1
MK
67 10 * 8, /* %rax */
68 5 * 8, /* %rbx */
69 11 * 8, /* %rcx */
70 12 * 8, /* %rdx */
71 13 * 8, /* %rsi */
72 14 * 8, /* %rdi */
73 4 * 8, /* %rbp */
74 19 * 8, /* %rsp */
75 9 * 8, /* %r8 ... */
76 8 * 8,
77 7 * 8,
78 6 * 8,
79 3 * 8,
80 2 * 8,
81 1 * 8,
82 0 * 8, /* ... %r15 */
83 16 * 8, /* %rip */
84 18 * 8, /* %eflags */
85 17 * 8, /* %cs */
86 20 * 8, /* %ss */
87 23 * 8, /* %ds */
88 24 * 8, /* %es */
89 25 * 8, /* %fs */
90 26 * 8 /* %gs */
eba29c8c 91};
187e21d1 92\f
eba29c8c 93
187e21d1 94/* Support for signal handlers. */
c4f35dd8
MK
95
96#define LINUX_SIGTRAMP_INSN0 0x48 /* mov $NNNNNNNN, %rax */
97#define LINUX_SIGTRAMP_OFFSET0 0
98#define LINUX_SIGTRAMP_INSN1 0x0f /* syscall */
99#define LINUX_SIGTRAMP_OFFSET1 7
100
4252dc94 101static const gdb_byte linux_sigtramp_code[] =
c4f35dd8
MK
102{
103 /* mov $__NR_rt_sigreturn, %rax */
baed091b
ML
104 LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00,
105 /* syscall */
106 LINUX_SIGTRAMP_INSN1, 0x05
53e95fcf
JS
107};
108
109#define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
110
111/* If PC is in a sigtramp routine, return the address of the start of
112 the routine. Otherwise, return 0. */
113
114static CORE_ADDR
10458914 115amd64_linux_sigtramp_start (struct frame_info *this_frame)
53e95fcf 116{
10458914 117 CORE_ADDR pc = get_frame_pc (this_frame);
4252dc94 118 gdb_byte buf[LINUX_SIGTRAMP_LEN];
c4f35dd8
MK
119
120 /* We only recognize a signal trampoline if PC is at the start of
121 one of the two instructions. We optimize for finding the PC at
122 the start, as will be the case when the trampoline is not the
123 first frame on the stack. We assume that in the case where the
124 PC is not at the start of the instruction sequence, there will be
125 a few trailing readable bytes on the stack. */
126
10458914 127 if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
53e95fcf
JS
128 return 0;
129
130 if (buf[0] != LINUX_SIGTRAMP_INSN0)
131 {
132 if (buf[0] != LINUX_SIGTRAMP_INSN1)
133 return 0;
134
135 pc -= LINUX_SIGTRAMP_OFFSET1;
10458914 136 if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
53e95fcf
JS
137 return 0;
138 }
139
140 if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
141 return 0;
142
143 return pc;
144}
145
10458914
DJ
146/* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
147 routine. */
baed091b 148
c4f35dd8 149static int
10458914 150amd64_linux_sigtramp_p (struct frame_info *this_frame)
baed091b 151{
10458914 152 CORE_ADDR pc = get_frame_pc (this_frame);
911bc6ee
MK
153 char *name;
154
155 find_pc_partial_function (pc, &name, NULL, NULL);
156
c4f35dd8
MK
157 /* If we have NAME, we can optimize the search. The trampoline is
158 named __restore_rt. However, it isn't dynamically exported from
159 the shared C library, so the trampoline may appear to be part of
160 the preceding function. This should always be sigaction,
161 __sigaction, or __libc_sigaction (all aliases to the same
162 function). */
163 if (name == NULL || strstr (name, "sigaction") != NULL)
10458914 164 return (amd64_linux_sigtramp_start (this_frame) != 0);
c4f35dd8
MK
165
166 return (strcmp ("__restore_rt", name) == 0);
baed091b
ML
167}
168
c4f35dd8 169/* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
51433e4b 170#define AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 40
b64bbf8c 171
10458914
DJ
172/* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
173 address of the associated sigcontext structure. */
baed091b 174
c4f35dd8 175static CORE_ADDR
10458914 176amd64_linux_sigcontext_addr (struct frame_info *this_frame)
baed091b 177{
e17a4113
UW
178 struct gdbarch *gdbarch = get_frame_arch (this_frame);
179 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
c4f35dd8 180 CORE_ADDR sp;
4252dc94 181 gdb_byte buf[8];
c4f35dd8 182
10458914 183 get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
e17a4113 184 sp = extract_unsigned_integer (buf, 8, byte_order);
c4f35dd8
MK
185
186 /* The sigcontext structure is part of the user context. A pointer
187 to the user context is passed as the third argument to the signal
188 handler, i.e. in %rdx. Unfortunately %rdx isn't preserved across
189 function calls so we can't use it. Fortunately the user context
190 is part of the signal frame and the unwound %rsp directly points
191 at it. */
51433e4b 192 return sp + AMD64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
baed091b 193}
2213a65d
MK
194\f
195
a96d9b2e
SDJ
196static LONGEST
197amd64_linux_get_syscall_number (struct gdbarch *gdbarch,
198 ptid_t ptid)
199{
200 struct regcache *regcache = get_thread_regcache (ptid);
201 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
202 /* The content of a register. */
203 gdb_byte buf[8];
204 /* The result. */
205 LONGEST ret;
206
207 /* Getting the system call number from the register.
208 When dealing with x86_64 architecture, this information
209 is stored at %rax register. */
210 regcache_cooked_read (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, buf);
211
212 ret = extract_signed_integer (buf, 8, byte_order);
213
214 return ret;
215}
216
217
2b5e0749 218/* From <asm/sigcontext.h>. */
51433e4b 219static int amd64_linux_sc_reg_offset[] =
2b5e0749
MK
220{
221 13 * 8, /* %rax */
222 11 * 8, /* %rbx */
223 14 * 8, /* %rcx */
224 12 * 8, /* %rdx */
225 9 * 8, /* %rsi */
226 8 * 8, /* %rdi */
227 10 * 8, /* %rbp */
228 15 * 8, /* %rsp */
229 0 * 8, /* %r8 */
230 1 * 8, /* %r9 */
231 2 * 8, /* %r10 */
232 3 * 8, /* %r11 */
233 4 * 8, /* %r12 */
234 5 * 8, /* %r13 */
235 6 * 8, /* %r14 */
236 7 * 8, /* %r15 */
237 16 * 8, /* %rip */
238 17 * 8, /* %eflags */
2b5e0749 239
af233647 240 /* FIXME: kettenis/2002030531: The registers %cs, %fs and %gs are
2b5e0749
MK
241 available in `struct sigcontext'. However, they only occupy two
242 bytes instead of four, which makes using them here rather
243 difficult. Leave them out for now. */
af233647
MK
244 -1, /* %cs */
245 -1, /* %ss */
246 -1, /* %ds */
247 -1, /* %es */
2b5e0749
MK
248 -1, /* %fs */
249 -1 /* %gs */
250};
251
8695c747
DJ
252static int
253amd64_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
254 struct reggroup *group)
255{
256 if (regnum == AMD64_LINUX_ORIG_RAX_REGNUM)
257 return (group == system_reggroup
258 || group == save_reggroup
259 || group == restore_reggroup);
84d90c10 260 return i386_register_reggroup_p (gdbarch, regnum, group);
8695c747
DJ
261}
262
263/* Set the program counter for process PTID to PC. */
264
265static void
61a1198a 266amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
8695c747 267{
61a1198a 268 regcache_cooked_write_unsigned (regcache, AMD64_RIP_REGNUM, pc);
8695c747
DJ
269
270 /* We must be careful with modifying the program counter. If we
271 just interrupted a system call, the kernel might try to restart
272 it when we resume the inferior. On restarting the system call,
273 the kernel will try backing up the program counter even though it
274 no longer points at the system call. This typically results in a
275 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
276 "orig_rax" pseudo-register.
277
278 Note that "orig_rax" is saved when setting up a dummy call frame.
279 This means that it is properly restored when that frame is
280 popped, and that the interrupted system call will be restarted
281 when we resume the inferior on return from a function call from
282 within GDB. In all other cases the system call will not be
283 restarted. */
61a1198a 284 regcache_cooked_write_unsigned (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, -1);
8695c747
DJ
285}
286
cdfbdf30 287/* Record all registers but IP register for process-record. */
952b2d63 288
cdfbdf30
HZ
289static int
290amd64_all_but_ip_registers_record (struct regcache *regcache)
291{
292 if (record_arch_list_add_reg (regcache, AMD64_RAX_REGNUM))
293 return -1;
294 if (record_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
295 return -1;
296 if (record_arch_list_add_reg (regcache, AMD64_RDX_REGNUM))
297 return -1;
298 if (record_arch_list_add_reg (regcache, AMD64_RBX_REGNUM))
299 return -1;
300 if (record_arch_list_add_reg (regcache, AMD64_RSP_REGNUM))
301 return -1;
302 if (record_arch_list_add_reg (regcache, AMD64_RBP_REGNUM))
303 return -1;
304 if (record_arch_list_add_reg (regcache, AMD64_RSI_REGNUM))
305 return -1;
306 if (record_arch_list_add_reg (regcache, AMD64_RDI_REGNUM))
307 return -1;
308 if (record_arch_list_add_reg (regcache, AMD64_R8_REGNUM))
309 return -1;
310 if (record_arch_list_add_reg (regcache, AMD64_R9_REGNUM))
311 return -1;
312 if (record_arch_list_add_reg (regcache, AMD64_R10_REGNUM))
313 return -1;
314 if (record_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
315 return -1;
316 if (record_arch_list_add_reg (regcache, AMD64_R12_REGNUM))
317 return -1;
318 if (record_arch_list_add_reg (regcache, AMD64_R13_REGNUM))
319 return -1;
320 if (record_arch_list_add_reg (regcache, AMD64_R14_REGNUM))
321 return -1;
322 if (record_arch_list_add_reg (regcache, AMD64_R15_REGNUM))
323 return -1;
324 if (record_arch_list_add_reg (regcache, AMD64_EFLAGS_REGNUM))
325 return -1;
952b2d63 326
cdfbdf30
HZ
327 return 0;
328}
952b2d63 329
13b6d1d4
MS
330/* amd64_canonicalize_syscall maps from the native amd64 Linux set
331 of syscall ids into a canonical set of syscall ids used by
332 process record. */
333
334static enum gdb_syscall
335amd64_canonicalize_syscall (enum amd64_syscall syscall)
336{
337 switch (syscall) {
338 case amd64_sys_read:
339 return gdb_sys_read;
340
341 case amd64_sys_write:
342 return gdb_sys_write;
343
344 case amd64_sys_open:
345 return gdb_sys_open;
346
347 case amd64_sys_close:
348 return gdb_sys_close;
349
350 case amd64_sys_newstat:
351 return gdb_sys_newstat;
352
353 case amd64_sys_newfstat:
354 return gdb_sys_newfstat;
355
356 case amd64_sys_newlstat:
357 return gdb_sys_newlstat;
358
359 case amd64_sys_poll:
360 return gdb_sys_poll;
361
362 case amd64_sys_lseek:
363 return gdb_sys_lseek;
364
365 case amd64_sys_mmap:
366 return gdb_sys_mmap2;
367
368 case amd64_sys_mprotect:
369 return gdb_sys_mprotect;
370
371 case amd64_sys_munmap:
372 return gdb_sys_munmap;
373
374 case amd64_sys_brk:
375 return gdb_sys_brk;
376
377 case amd64_sys_rt_sigaction:
378 return gdb_sys_rt_sigaction;
379
380 case amd64_sys_rt_sigprocmask:
381 return gdb_sys_rt_sigprocmask;
382
383 case amd64_sys_rt_sigreturn:
384 return gdb_sys_rt_sigreturn;
385
386 case amd64_sys_ioctl:
387 return gdb_sys_ioctl;
388
389 case amd64_sys_pread64:
390 return gdb_sys_pread64;
391
392 case amd64_sys_pwrite64:
393 return gdb_sys_pwrite64;
394
395 case amd64_sys_readv:
396 return gdb_sys_readv;
397
398 case amd64_sys_writev:
399 return gdb_sys_writev;
400
401 case amd64_sys_access:
402 return gdb_sys_access;
403
404 case amd64_sys_pipe:
405 return gdb_sys_pipe;
406
407 case amd64_sys_select:
408 return gdb_sys_select;
409
410 case amd64_sys_sched_yield:
411 return gdb_sys_sched_yield;
412
413 case amd64_sys_mremap:
414 return gdb_sys_mremap;
415
416 case amd64_sys_msync:
417 return gdb_sys_msync;
418
419 case amd64_sys_mincore:
420 return gdb_sys_mincore;
421
422 case amd64_sys_madvise:
423 return gdb_sys_madvise;
424
425 case amd64_sys_shmget:
426 return gdb_sys_shmget;
427
428 case amd64_sys_shmat:
429 return gdb_sys_shmat;
430
431 case amd64_sys_shmctl:
432 return gdb_sys_shmctl;
433
434 case amd64_sys_dup:
435 return gdb_sys_dup;
436
437 case amd64_sys_dup2:
438 return gdb_sys_dup2;
439
440 case amd64_sys_pause:
441 return gdb_sys_pause;
442
443 case amd64_sys_nanosleep:
444 return gdb_sys_nanosleep;
445
446 case amd64_sys_getitimer:
447 return gdb_sys_getitimer;
448
449 case amd64_sys_alarm:
450 return gdb_sys_alarm;
451
452 case amd64_sys_setitimer:
453 return gdb_sys_setitimer;
454
455 case amd64_sys_getpid:
456 return gdb_sys_getpid;
457
458 case amd64_sys_sendfile64:
459 return gdb_sys_sendfile64;
460
461 case amd64_sys_socket:
462 return gdb_sys_socket;
463
464 case amd64_sys_connect:
465 return gdb_sys_connect;
466
467 case amd64_sys_accept:
468 return gdb_sys_accept;
469
470 case amd64_sys_sendto:
471 return gdb_sys_sendto;
472
473 case amd64_sys_recvfrom:
474 return gdb_sys_recvfrom;
475
476 case amd64_sys_sendmsg:
477 return gdb_sys_sendmsg;
478
479 case amd64_sys_recvmsg:
480 return gdb_sys_recvmsg;
481
482 case amd64_sys_shutdown:
483 return gdb_sys_shutdown;
484
485 case amd64_sys_bind:
486 return gdb_sys_bind;
487
488 case amd64_sys_listen:
489 return gdb_sys_listen;
490
491 case amd64_sys_getsockname:
492 return gdb_sys_getsockname;
493
494 case amd64_sys_getpeername:
495 return gdb_sys_getpeername;
496
497 case amd64_sys_socketpair:
498 return gdb_sys_socketpair;
499
500 case amd64_sys_setsockopt:
501 return gdb_sys_setsockopt;
502
503 case amd64_sys_getsockopt:
504 return gdb_sys_getsockopt;
505
506 case amd64_sys_clone:
507 return gdb_sys_clone;
508
509 case amd64_sys_fork:
510 return gdb_sys_fork;
511
512 case amd64_sys_vfork:
513 return gdb_sys_vfork;
514
515 case amd64_sys_execve:
516 return gdb_sys_execve;
517
518 case amd64_sys_exit:
519 return gdb_sys_exit;
520
521 case amd64_sys_wait4:
522 return gdb_sys_wait4;
523
524 case amd64_sys_kill:
525 return gdb_sys_kill;
526
527 case amd64_sys_uname:
528 return gdb_sys_uname;
529
530 case amd64_sys_semget:
531 return gdb_sys_semget;
532
533 case amd64_sys_semop:
534 return gdb_sys_semop;
535
536 case amd64_sys_semctl:
537 return gdb_sys_semctl;
538
539 case amd64_sys_shmdt:
540 return gdb_sys_shmdt;
541
542 case amd64_sys_msgget:
543 return gdb_sys_msgget;
544
545 case amd64_sys_msgsnd:
546 return gdb_sys_msgsnd;
547
548 case amd64_sys_msgrcv:
549 return gdb_sys_msgrcv;
550
551 case amd64_sys_msgctl:
552 return gdb_sys_msgctl;
553
554 case amd64_sys_fcntl:
555 return gdb_sys_fcntl;
556
557 case amd64_sys_flock:
558 return gdb_sys_flock;
559
560 case amd64_sys_fsync:
561 return gdb_sys_fsync;
562
563 case amd64_sys_fdatasync:
564 return gdb_sys_fdatasync;
565
566 case amd64_sys_truncate:
567 return gdb_sys_truncate;
568
569 case amd64_sys_ftruncate:
570 return gdb_sys_ftruncate;
571
572 case amd64_sys_getdents:
573 return gdb_sys_getdents;
574
575 case amd64_sys_getcwd:
576 return gdb_sys_getcwd;
577
578 case amd64_sys_chdir:
579 return gdb_sys_chdir;
580
581 case amd64_sys_fchdir:
582 return gdb_sys_fchdir;
583
584 case amd64_sys_rename:
585 return gdb_sys_rename;
586
587 case amd64_sys_mkdir:
588 return gdb_sys_mkdir;
589
590 case amd64_sys_rmdir:
591 return gdb_sys_rmdir;
592
593 case amd64_sys_creat:
594 return gdb_sys_creat;
595
596 case amd64_sys_link:
597 return gdb_sys_link;
598
599 case amd64_sys_unlink:
600 return gdb_sys_unlink;
601
602 case amd64_sys_symlink:
603 return gdb_sys_symlink;
604
605 case amd64_sys_readlink:
606 return gdb_sys_readlink;
607
608 case amd64_sys_chmod:
609 return gdb_sys_chmod;
610
611 case amd64_sys_fchmod:
612 return gdb_sys_fchmod;
613
614 case amd64_sys_chown:
615 return gdb_sys_chown;
616
617 case amd64_sys_fchown:
618 return gdb_sys_fchown;
619
620 case amd64_sys_lchown:
621 return gdb_sys_lchown;
622
623 case amd64_sys_umask:
624 return gdb_sys_umask;
625
626 case amd64_sys_gettimeofday:
627 return gdb_sys_gettimeofday;
628
629 case amd64_sys_getrlimit:
630 return gdb_sys_getrlimit;
631
632 case amd64_sys_getrusage:
633 return gdb_sys_getrusage;
634
635 case amd64_sys_sysinfo:
636 return gdb_sys_sysinfo;
637
638 case amd64_sys_times:
639 return gdb_sys_times;
640
641 case amd64_sys_ptrace:
642 return gdb_sys_ptrace;
643
644 case amd64_sys_getuid:
645 return gdb_sys_getuid;
646
647 case amd64_sys_syslog:
648 return gdb_sys_syslog;
649
650 case amd64_sys_getgid:
651 return gdb_sys_getgid;
652
653 case amd64_sys_setuid:
654 return gdb_sys_setuid;
655
656 case amd64_sys_setgid:
657 return gdb_sys_setgid;
658
659 case amd64_sys_geteuid:
660 return gdb_sys_geteuid;
661
662 case amd64_sys_getegid:
663 return gdb_sys_getegid;
664
665 case amd64_sys_setpgid:
666 return gdb_sys_setpgid;
667
668 case amd64_sys_getppid:
669 return gdb_sys_getppid;
670
671 case amd64_sys_getpgrp:
672 return gdb_sys_getpgrp;
673
674 case amd64_sys_setsid:
675 return gdb_sys_setsid;
676
677 case amd64_sys_setreuid:
678 return gdb_sys_setreuid;
679
680 case amd64_sys_setregid:
681 return gdb_sys_setregid;
682
683 case amd64_sys_getgroups:
684 return gdb_sys_getgroups;
685
686 case amd64_sys_setgroups:
687 return gdb_sys_setgroups;
688
689 case amd64_sys_setresuid:
690 return gdb_sys_setresuid;
691
692 case amd64_sys_getresuid:
693 return gdb_sys_getresuid;
694
695 case amd64_sys_setresgid:
696 return gdb_sys_setresgid;
697
698 case amd64_sys_getresgid:
699 return gdb_sys_getresgid;
700
701 case amd64_sys_getpgid:
702 return gdb_sys_getpgid;
703
704 case amd64_sys_setfsuid:
705 return gdb_sys_setfsuid;
706
707 case amd64_sys_setfsgid:
708 return gdb_sys_setfsgid;
709
710 case amd64_sys_getsid:
711 return gdb_sys_getsid;
712
713 case amd64_sys_capget:
714 return gdb_sys_capget;
715
716 case amd64_sys_capset:
717 return gdb_sys_capset;
718
719 case amd64_sys_rt_sigpending:
720 return gdb_sys_rt_sigpending;
721
722 case amd64_sys_rt_sigtimedwait:
723 return gdb_sys_rt_sigtimedwait;
724
725 case amd64_sys_rt_sigqueueinfo:
726 return gdb_sys_rt_sigqueueinfo;
727
728 case amd64_sys_rt_sigsuspend:
729 return gdb_sys_rt_sigsuspend;
730
731 case amd64_sys_sigaltstack:
732 return gdb_sys_sigaltstack;
733
734 case amd64_sys_utime:
735 return gdb_sys_utime;
736
737 case amd64_sys_mknod:
738 return gdb_sys_mknod;
739
740 case amd64_sys_personality:
741 return gdb_sys_personality;
742
743 case amd64_sys_ustat:
744 return gdb_sys_ustat;
745
746 case amd64_sys_statfs:
747 return gdb_sys_statfs;
748
749 case amd64_sys_fstatfs:
750 return gdb_sys_fstatfs;
751
752 case amd64_sys_sysfs:
753 return gdb_sys_sysfs;
754
755 case amd64_sys_getpriority:
756 return gdb_sys_getpriority;
757
758 case amd64_sys_setpriority:
759 return gdb_sys_setpriority;
760
761 case amd64_sys_sched_setparam:
762 return gdb_sys_sched_setparam;
763
764 case amd64_sys_sched_getparam:
765 return gdb_sys_sched_getparam;
766
767 case amd64_sys_sched_setscheduler:
768 return gdb_sys_sched_setscheduler;
769
770 case amd64_sys_sched_getscheduler:
771 return gdb_sys_sched_getscheduler;
772
773 case amd64_sys_sched_get_priority_max:
774 return gdb_sys_sched_get_priority_max;
775
776 case amd64_sys_sched_get_priority_min:
777 return gdb_sys_sched_get_priority_min;
778
779 case amd64_sys_sched_rr_get_interval:
780 return gdb_sys_sched_rr_get_interval;
781
782 case amd64_sys_mlock:
783 return gdb_sys_mlock;
784
785 case amd64_sys_munlock:
786 return gdb_sys_munlock;
787
788 case amd64_sys_mlockall:
789 return gdb_sys_mlockall;
790
791 case amd64_sys_munlockall:
792 return gdb_sys_munlockall;
793
794 case amd64_sys_vhangup:
795 return gdb_sys_vhangup;
796
797 case amd64_sys_modify_ldt:
798 return gdb_sys_modify_ldt;
799
800 case amd64_sys_pivot_root:
801 return gdb_sys_pivot_root;
802
803 case amd64_sys_sysctl:
804 return gdb_sys_sysctl;
805
806 case amd64_sys_prctl:
807 return gdb_sys_prctl;
808
809 case amd64_sys_arch_prctl:
810 return -1; /* Note */
811
812 case amd64_sys_adjtimex:
813 return gdb_sys_adjtimex;
814
815 case amd64_sys_setrlimit:
816 return gdb_sys_setrlimit;
817
818 case amd64_sys_chroot:
819 return gdb_sys_chroot;
820
821 case amd64_sys_sync:
822 return gdb_sys_sync;
823
824 case amd64_sys_acct:
825 return gdb_sys_acct;
826
827 case amd64_sys_settimeofday:
828 return gdb_sys_settimeofday;
829
830 case amd64_sys_mount:
831 return gdb_sys_mount;
832
833 case amd64_sys_umount:
834 return gdb_sys_umount;
835
836 case amd64_sys_swapon:
837 return gdb_sys_swapon;
838
839 case amd64_sys_swapoff:
840 return gdb_sys_swapoff;
841
842 case amd64_sys_reboot:
843 return gdb_sys_reboot;
844
845 case amd64_sys_sethostname:
846 return gdb_sys_sethostname;
847
848 case amd64_sys_setdomainname:
849 return gdb_sys_setdomainname;
850
851 case amd64_sys_iopl:
852 return gdb_sys_iopl;
853
854 case amd64_sys_ioperm:
855 return gdb_sys_ioperm;
856
857 case amd64_sys_init_module:
858 return gdb_sys_init_module;
859
860 case amd64_sys_delete_module:
861 return gdb_sys_delete_module;
862
863 case amd64_sys_quotactl:
864 return gdb_sys_quotactl;
865
866 case amd64_sys_nfsservctl:
867 return gdb_sys_nfsservctl;
868
869 case amd64_sys_gettid:
870 return gdb_sys_gettid;
871
872 case amd64_sys_readahead:
873 return gdb_sys_readahead;
874
875 case amd64_sys_setxattr:
876 return gdb_sys_setxattr;
877
878 case amd64_sys_lsetxattr:
879 return gdb_sys_lsetxattr;
880
881 case amd64_sys_fsetxattr:
882 return gdb_sys_fsetxattr;
883
884 case amd64_sys_getxattr:
885 return gdb_sys_getxattr;
886
887 case amd64_sys_lgetxattr:
888 return gdb_sys_lgetxattr;
889
890 case amd64_sys_fgetxattr:
891 return gdb_sys_fgetxattr;
892
893 case amd64_sys_listxattr:
894 return gdb_sys_listxattr;
895
896 case amd64_sys_llistxattr:
897 return gdb_sys_llistxattr;
898
899 case amd64_sys_flistxattr:
900 return gdb_sys_flistxattr;
901
902 case amd64_sys_removexattr:
903 return gdb_sys_removexattr;
904
905 case amd64_sys_lremovexattr:
906 return gdb_sys_lremovexattr;
907
908 case amd64_sys_fremovexattr:
909 return gdb_sys_fremovexattr;
910
911 case amd64_sys_tkill:
912 return gdb_sys_tkill;
913
914 case amd64_sys_time:
915 return gdb_sys_time;
916
917 case amd64_sys_futex:
918 return gdb_sys_futex;
919
920 case amd64_sys_sched_setaffinity:
921 return gdb_sys_sched_setaffinity;
922
923 case amd64_sys_sched_getaffinity:
924 return gdb_sys_sched_getaffinity;
925
926 case amd64_sys_io_setup:
927 return gdb_sys_io_setup;
928
929 case amd64_sys_io_destroy:
930 return gdb_sys_io_destroy;
931
932 case amd64_sys_io_getevents:
933 return gdb_sys_io_getevents;
934
935 case amd64_sys_io_submit:
936 return gdb_sys_io_submit;
937
938 case amd64_sys_io_cancel:
939 return gdb_sys_io_cancel;
940
941 case amd64_sys_lookup_dcookie:
942 return gdb_sys_lookup_dcookie;
943
944 case amd64_sys_epoll_create:
945 return gdb_sys_epoll_create;
946
947 case amd64_sys_remap_file_pages:
948 return gdb_sys_remap_file_pages;
949
950 case amd64_sys_getdents64:
951 return gdb_sys_getdents64;
952
953 case amd64_sys_set_tid_address:
954 return gdb_sys_set_tid_address;
955
956 case amd64_sys_restart_syscall:
957 return gdb_sys_restart_syscall;
958
959 case amd64_sys_semtimedop:
960 return gdb_sys_semtimedop;
961
962 case amd64_sys_fadvise64:
963 return gdb_sys_fadvise64;
964
965 case amd64_sys_timer_create:
966 return gdb_sys_timer_create;
967
968 case amd64_sys_timer_settime:
969 return gdb_sys_timer_settime;
970
971 case amd64_sys_timer_gettime:
972 return gdb_sys_timer_gettime;
973
974 case amd64_sys_timer_getoverrun:
975 return gdb_sys_timer_getoverrun;
976
977 case amd64_sys_timer_delete:
978 return gdb_sys_timer_delete;
979
980 case amd64_sys_clock_settime:
981 return gdb_sys_clock_settime;
982
983 case amd64_sys_clock_gettime:
984 return gdb_sys_clock_gettime;
985
986 case amd64_sys_clock_getres:
987 return gdb_sys_clock_getres;
988
989 case amd64_sys_clock_nanosleep:
990 return gdb_sys_clock_nanosleep;
991
992 case amd64_sys_exit_group:
993 return gdb_sys_exit_group;
994
995 case amd64_sys_epoll_wait:
996 return gdb_sys_epoll_wait;
997
998 case amd64_sys_epoll_ctl:
999 return gdb_sys_epoll_ctl;
1000
1001 case amd64_sys_tgkill:
1002 return gdb_sys_tgkill;
1003
1004 case amd64_sys_utimes:
1005 return gdb_sys_utimes;
1006
1007 case amd64_sys_mbind:
1008 return gdb_sys_mbind;
1009
1010 case amd64_sys_set_mempolicy:
1011 return gdb_sys_set_mempolicy;
1012
1013 case amd64_sys_get_mempolicy:
1014 return gdb_sys_get_mempolicy;
1015
1016 case amd64_sys_mq_open:
1017 return gdb_sys_mq_open;
1018
1019 case amd64_sys_mq_unlink:
1020 return gdb_sys_mq_unlink;
1021
1022 case amd64_sys_mq_timedsend:
1023 return gdb_sys_mq_timedsend;
1024
1025 case amd64_sys_mq_timedreceive:
1026 return gdb_sys_mq_timedreceive;
1027
1028 case amd64_sys_mq_notify:
1029 return gdb_sys_mq_notify;
1030
1031 case amd64_sys_mq_getsetattr:
1032 return gdb_sys_mq_getsetattr;
1033
1034 case amd64_sys_kexec_load:
1035 return gdb_sys_kexec_load;
1036
1037 case amd64_sys_waitid:
1038 return gdb_sys_waitid;
1039
1040 case amd64_sys_add_key:
1041 return gdb_sys_add_key;
1042
1043 case amd64_sys_request_key:
1044 return gdb_sys_request_key;
1045
1046 case amd64_sys_keyctl:
1047 return gdb_sys_keyctl;
1048
1049 case amd64_sys_ioprio_set:
1050 return gdb_sys_ioprio_set;
1051
1052 case amd64_sys_ioprio_get:
1053 return gdb_sys_ioprio_get;
1054
1055 case amd64_sys_inotify_init:
1056 return gdb_sys_inotify_init;
1057
1058 case amd64_sys_inotify_add_watch:
1059 return gdb_sys_inotify_add_watch;
1060
1061 case amd64_sys_inotify_rm_watch:
1062 return gdb_sys_inotify_rm_watch;
1063
1064 case amd64_sys_migrate_pages:
1065 return gdb_sys_migrate_pages;
1066
1067 case amd64_sys_openat:
1068 return gdb_sys_openat;
1069
1070 case amd64_sys_mkdirat:
1071 return gdb_sys_mkdirat;
1072
1073 case amd64_sys_mknodat:
1074 return gdb_sys_mknodat;
1075
1076 case amd64_sys_fchownat:
1077 return gdb_sys_fchownat;
1078
1079 case amd64_sys_futimesat:
1080 return gdb_sys_futimesat;
1081
1082 case amd64_sys_newfstatat:
1083 return gdb_sys_newfstatat;
1084
1085 case amd64_sys_unlinkat:
1086 return gdb_sys_unlinkat;
1087
1088 case amd64_sys_renameat:
1089 return gdb_sys_renameat;
1090
1091 case amd64_sys_linkat:
1092 return gdb_sys_linkat;
1093
1094 case amd64_sys_symlinkat:
1095 return gdb_sys_symlinkat;
1096
1097 case amd64_sys_readlinkat:
1098 return gdb_sys_readlinkat;
1099
1100 case amd64_sys_fchmodat:
1101 return gdb_sys_fchmodat;
1102
1103 case amd64_sys_faccessat:
1104 return gdb_sys_faccessat;
1105
1106 case amd64_sys_pselect6:
1107 return gdb_sys_pselect6;
1108
1109 case amd64_sys_ppoll:
1110 return gdb_sys_ppoll;
1111
1112 case amd64_sys_unshare:
1113 return gdb_sys_unshare;
1114
1115 case amd64_sys_set_robust_list:
1116 return gdb_sys_set_robust_list;
1117
1118 case amd64_sys_get_robust_list:
1119 return gdb_sys_get_robust_list;
1120
1121 case amd64_sys_splice:
1122 return gdb_sys_splice;
1123
1124 case amd64_sys_tee:
1125 return gdb_sys_tee;
1126
1127 case amd64_sys_sync_file_range:
1128 return gdb_sys_sync_file_range;
1129
1130 case amd64_sys_vmsplice:
1131 return gdb_sys_vmsplice;
1132
1133 case amd64_sys_move_pages:
1134 return gdb_sys_move_pages;
1135
1136 default:
1137 return -1;
1138 }
1139}
1140
cdfbdf30
HZ
1141/* Parse the arguments of current system call instruction and record
1142 the values of the registers and memory that will be changed into
1143 "record_arch_list". This instruction is "syscall".
1144
1145 Return -1 if something wrong. */
1146
1147static struct linux_record_tdep amd64_linux_record_tdep;
1148
1149#define RECORD_ARCH_GET_FS 0x1003
1150#define RECORD_ARCH_GET_GS 0x1004
1151
952b2d63
HZ
1152static int
1153amd64_linux_syscall_record (struct regcache *regcache)
1154{
13b6d1d4
MS
1155 int ret;
1156 ULONGEST syscall_native;
1157 enum gdb_syscall syscall_gdb = -1;
1158
1159 regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &syscall_native);
952b2d63 1160
cdfbdf30 1161 switch (syscall_native)
952b2d63 1162 {
cdfbdf30
HZ
1163 case amd64_sys_rt_sigreturn:
1164 if (amd64_all_but_ip_registers_record (regcache))
1165 return -1;
1166 return 0;
1167 break;
1168
1169 case amd64_sys_arch_prctl:
1170 if (syscall_native == amd64_sys_arch_prctl)
1171 {
1172 ULONGEST arg3;
1173
1174 regcache_raw_read_unsigned (regcache, amd64_linux_record_tdep.arg3,
1175 &arg3);
1176 if (arg3 == RECORD_ARCH_GET_FS || arg3 == RECORD_ARCH_GET_GS)
1177 {
1178 CORE_ADDR addr;
1179
1180 regcache_raw_read_unsigned (regcache,
1181 amd64_linux_record_tdep.arg2,
1182 &addr);
1183 if (record_arch_list_add_mem (addr,
1184 amd64_linux_record_tdep.size_ulong))
1185 return -1;
1186 }
1187 goto record_regs;
1188 }
1189 break;
13b6d1d4
MS
1190 }
1191
cdfbdf30
HZ
1192 syscall_gdb = amd64_canonicalize_syscall (syscall_native);
1193
13b6d1d4
MS
1194 if (syscall_gdb < 0)
1195 {
952b2d63 1196 printf_unfiltered (_("Process record and replay target doesn't "
13b6d1d4
MS
1197 "support syscall number %s\n"),
1198 pulongest (syscall_native));
952b2d63 1199 return -1;
952b2d63 1200 }
13b6d1d4 1201 else
952b2d63 1202 {
13b6d1d4 1203 ret = record_linux_system_call (syscall_gdb, regcache,
952b2d63
HZ
1204 &amd64_linux_record_tdep);
1205 if (ret)
1206 return ret;
1207 }
1208
13b6d1d4 1209 record_regs:
952b2d63
HZ
1210 /* Record the return value of the system call. */
1211 if (record_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
1212 return -1;
1213 if (record_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
1214 return -1;
1215
cdfbdf30
HZ
1216 return 0;
1217}
1218
1219#define AMD64_LINUX_redzone 128
1220#define AMD64_LINUX_xstate 512
1221#define AMD64_LINUX_frame_size 560
1222
1223int
1224amd64_linux_record_signal (struct gdbarch *gdbarch,
1225 struct regcache *regcache,
1226 enum target_signal signal)
1227{
1228 ULONGEST rsp;
1229
1230 if (amd64_all_but_ip_registers_record (regcache))
1231 return -1;
1232
1233 if (record_arch_list_add_reg (regcache, AMD64_RIP_REGNUM))
1234 return -1;
1235
1236 /* Record the change in the stack. */
1237 regcache_raw_read_unsigned (regcache, AMD64_RSP_REGNUM, &rsp);
1238 /* redzone
1239 sp -= 128; */
1240 rsp -= AMD64_LINUX_redzone;
1241 /* This is for xstate.
1242 sp -= sizeof (struct _fpstate); */
1243 rsp -= AMD64_LINUX_xstate;
1244 /* This is for frame_size.
1245 sp -= sizeof (struct rt_sigframe); */
1246 rsp -= AMD64_LINUX_frame_size;
1247 if (record_arch_list_add_mem (rsp, AMD64_LINUX_redzone
1248 + AMD64_LINUX_xstate
1249 + AMD64_LINUX_frame_size))
1250 return -1;
1251
1252 if (record_arch_list_add_end ())
1253 return -1;
952b2d63
HZ
1254
1255 return 0;
1256}
1257
90884b2b
L
1258/* Get Linux/x86 target description from core dump. */
1259
1260static const struct target_desc *
1261amd64_linux_core_read_description (struct gdbarch *gdbarch,
1262 struct target_ops *target,
1263 bfd *abfd)
1264{
1265 asection *section = bfd_get_section_by_name (abfd, ".reg2");
a055a187 1266 uint64_t xcr0;
90884b2b
L
1267
1268 if (section == NULL)
1269 return NULL;
1270
1271 /* Linux/x86-64. */
a055a187
L
1272 xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
1273 if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK)
1274 return tdesc_amd64_avx_linux;
1275 else
1276 return tdesc_amd64_linux;
90884b2b
L
1277}
1278
2213a65d 1279static void
51433e4b 1280amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
2213a65d 1281{
c4f35dd8 1282 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
90884b2b
L
1283 const struct target_desc *tdesc = info.target_desc;
1284 struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
1285 const struct tdesc_feature *feature;
1286 int valid_p;
1287
1288 gdb_assert (tdesc_data);
187e21d1
MK
1289
1290 tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset;
1291 tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
1292 tdep->sizeof_gregset = 27 * 8;
1293
90f90721 1294 amd64_init_abi (info, gdbarch);
c4f35dd8 1295
90884b2b
L
1296 /* Reserve a number for orig_rax. */
1297 set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
1298
1299 if (! tdesc_has_registers (tdesc))
1300 tdesc = tdesc_amd64_linux;
1301 tdep->tdesc = tdesc;
1302
1303 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
1304 if (feature == NULL)
1305 return;
1306
1307 valid_p = tdesc_numbered_register (feature, tdesc_data,
1308 AMD64_LINUX_ORIG_RAX_REGNUM,
1309 "orig_rax");
1310 if (!valid_p)
1311 return;
1312
911bc6ee 1313 tdep->sigtramp_p = amd64_linux_sigtramp_p;
51433e4b
MK
1314 tdep->sigcontext_addr = amd64_linux_sigcontext_addr;
1315 tdep->sc_reg_offset = amd64_linux_sc_reg_offset;
1316 tdep->sc_num_regs = ARRAY_SIZE (amd64_linux_sc_reg_offset);
187e21d1 1317
a055a187
L
1318 tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET;
1319
187e21d1
MK
1320 /* GNU/Linux uses SVR4-style shared libraries. */
1321 set_solib_svr4_fetch_link_map_offsets
1322 (gdbarch, svr4_lp64_fetch_link_map_offsets);
b2756930 1323
8695c747
DJ
1324 /* Add the %orig_rax register used for syscall restarting. */
1325 set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc);
90884b2b
L
1326
1327 tdep->register_reggroup_p = amd64_linux_register_reggroup_p;
8695c747 1328
a96d9b2e
SDJ
1329 /* Functions for 'catch syscall'. */
1330 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_AMD64);
1331 set_gdbarch_get_syscall_number (gdbarch,
1332 amd64_linux_get_syscall_number);
1333
b2756930
KB
1334 /* Enable TLS support. */
1335 set_gdbarch_fetch_tls_load_module_address (gdbarch,
1336 svr4_fetch_objfile_link_map);
35669430 1337
872761f4
MS
1338 /* GNU/Linux uses SVR4-style shared libraries. */
1339 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
1340
a055a187
L
1341 /* Install supported register note sections. */
1342 set_gdbarch_core_regset_sections (gdbarch, amd64_linux_regset_sections);
1343
90884b2b
L
1344 set_gdbarch_core_read_description (gdbarch,
1345 amd64_linux_core_read_description);
1346
35669430
DE
1347 /* Displaced stepping. */
1348 set_gdbarch_displaced_step_copy_insn (gdbarch,
1349 amd64_displaced_step_copy_insn);
1350 set_gdbarch_displaced_step_fixup (gdbarch, amd64_displaced_step_fixup);
1351 set_gdbarch_displaced_step_free_closure (gdbarch,
1352 simple_displaced_step_free_closure);
1353 set_gdbarch_displaced_step_location (gdbarch,
1354 displaced_step_at_entry_point);
4aa995e1
PA
1355
1356 set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
952b2d63
HZ
1357
1358 set_gdbarch_process_record (gdbarch, i386_process_record);
cdfbdf30 1359 set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
952b2d63
HZ
1360
1361 /* Initialize the amd64_linux_record_tdep. */
1362 /* These values are the size of the type that will be used in a system
1363 call. They are obtained from Linux Kernel source. */
1364 amd64_linux_record_tdep.size_pointer
1365 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
1366 amd64_linux_record_tdep.size__old_kernel_stat = 32;
1367 amd64_linux_record_tdep.size_tms = 32;
1368 amd64_linux_record_tdep.size_loff_t = 8;
1369 amd64_linux_record_tdep.size_flock = 32;
1370 amd64_linux_record_tdep.size_oldold_utsname = 45;
1371 amd64_linux_record_tdep.size_ustat = 32;
1372 /* ADM64 doesn't need this size because it doesn't have sys_sigaction
1373 but sys_rt_sigaction. */
1374 amd64_linux_record_tdep.size_old_sigaction = 152;
1375 /* ADM64 doesn't need this size because it doesn't have sys_sigpending
1376 but sys_rt_sigpending. */
1377 amd64_linux_record_tdep.size_old_sigset_t = 128;
1378 amd64_linux_record_tdep.size_rlimit = 16;
1379 amd64_linux_record_tdep.size_rusage = 144;
1380 amd64_linux_record_tdep.size_timeval = 16;
1381 amd64_linux_record_tdep.size_timezone = 8;
1382 /* ADM64 doesn't need this size because it doesn't have sys_getgroups16
1383 but sys_getgroups. */
1384 amd64_linux_record_tdep.size_old_gid_t = 2;
1385 /* ADM64 doesn't need this size because it doesn't have sys_getresuid16
1386 but sys_getresuid. */
1387 amd64_linux_record_tdep.size_old_uid_t = 2;
1388 amd64_linux_record_tdep.size_fd_set = 128;
1389 amd64_linux_record_tdep.size_dirent = 280;
1390 amd64_linux_record_tdep.size_dirent64 = 280;
1391 amd64_linux_record_tdep.size_statfs = 120;
1392 amd64_linux_record_tdep.size_statfs64 = 120;
1393 amd64_linux_record_tdep.size_sockaddr = 16;
1394 amd64_linux_record_tdep.size_int
1395 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
1396 amd64_linux_record_tdep.size_long
1397 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1398 amd64_linux_record_tdep.size_ulong
1399 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
1400 amd64_linux_record_tdep.size_msghdr = 56;
1401 amd64_linux_record_tdep.size_itimerval = 32;
1402 amd64_linux_record_tdep.size_stat = 144;
1403 amd64_linux_record_tdep.size_old_utsname = 325;
1404 amd64_linux_record_tdep.size_sysinfo = 112;
1405 amd64_linux_record_tdep.size_msqid_ds = 120;
1406 amd64_linux_record_tdep.size_shmid_ds = 112;
1407 amd64_linux_record_tdep.size_new_utsname = 390;
1408 amd64_linux_record_tdep.size_timex = 208;
1409 amd64_linux_record_tdep.size_mem_dqinfo = 24;
1410 amd64_linux_record_tdep.size_if_dqblk = 72;
1411 amd64_linux_record_tdep.size_fs_quota_stat = 80;
1412 amd64_linux_record_tdep.size_timespec = 16;
1413 amd64_linux_record_tdep.size_pollfd = 8;
1414 amd64_linux_record_tdep.size_NFS_FHSIZE = 32;
1415 amd64_linux_record_tdep.size_knfsd_fh = 132;
1416 amd64_linux_record_tdep.size_TASK_COMM_LEN = 16;
1417 amd64_linux_record_tdep.size_sigaction = 152;
1418 amd64_linux_record_tdep.size_sigset_t = 128;
1419 amd64_linux_record_tdep.size_siginfo_t = 128;
1420 amd64_linux_record_tdep.size_cap_user_data_t = 8;
1421 amd64_linux_record_tdep.size_stack_t = 24;
1422 amd64_linux_record_tdep.size_off_t = 8;
1423 amd64_linux_record_tdep.size_stat64 = 144;
1424 amd64_linux_record_tdep.size_gid_t = 4;
1425 amd64_linux_record_tdep.size_uid_t = 4;
1426 amd64_linux_record_tdep.size_PAGE_SIZE = 4096;
1427 amd64_linux_record_tdep.size_flock64 = 32;
1428 amd64_linux_record_tdep.size_user_desc = 16;
1429 amd64_linux_record_tdep.size_io_event = 32;
1430 amd64_linux_record_tdep.size_iocb = 64;
1431 amd64_linux_record_tdep.size_epoll_event = 12;
1432 amd64_linux_record_tdep.size_itimerspec = 32;
1433 amd64_linux_record_tdep.size_mq_attr = 64;
1434 amd64_linux_record_tdep.size_siginfo = 128;
1435 amd64_linux_record_tdep.size_termios = 60;
1436 amd64_linux_record_tdep.size_termios2 = 44;
1437 amd64_linux_record_tdep.size_pid_t = 4;
1438 amd64_linux_record_tdep.size_winsize = 8;
1439 amd64_linux_record_tdep.size_serial_struct = 72;
1440 amd64_linux_record_tdep.size_serial_icounter_struct = 80;
1441 amd64_linux_record_tdep.size_hayes_esp_config = 12;
1442 amd64_linux_record_tdep.size_size_t = 8;
1443 amd64_linux_record_tdep.size_iovec = 16;
1444
1445 /* These values are the second argument of system call "sys_ioctl".
1446 They are obtained from Linux Kernel source. */
1447 amd64_linux_record_tdep.ioctl_TCGETS = 0x5401;
1448 amd64_linux_record_tdep.ioctl_TCSETS = 0x5402;
1449 amd64_linux_record_tdep.ioctl_TCSETSW = 0x5403;
1450 amd64_linux_record_tdep.ioctl_TCSETSF = 0x5404;
1451 amd64_linux_record_tdep.ioctl_TCGETA = 0x5405;
1452 amd64_linux_record_tdep.ioctl_TCSETA = 0x5406;
1453 amd64_linux_record_tdep.ioctl_TCSETAW = 0x5407;
1454 amd64_linux_record_tdep.ioctl_TCSETAF = 0x5408;
1455 amd64_linux_record_tdep.ioctl_TCSBRK = 0x5409;
1456 amd64_linux_record_tdep.ioctl_TCXONC = 0x540A;
1457 amd64_linux_record_tdep.ioctl_TCFLSH = 0x540B;
1458 amd64_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
1459 amd64_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
1460 amd64_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
1461 amd64_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
1462 amd64_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
1463 amd64_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
1464 amd64_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
1465 amd64_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
1466 amd64_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
1467 amd64_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
1468 amd64_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
1469 amd64_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
1470 amd64_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
1471 amd64_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
1472 amd64_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
1473 amd64_linux_record_tdep.ioctl_FIONREAD = 0x541B;
1474 amd64_linux_record_tdep.ioctl_TIOCINQ
1475 = amd64_linux_record_tdep.ioctl_FIONREAD;
1476 amd64_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
1477 amd64_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
1478 amd64_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
1479 amd64_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
1480 amd64_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
1481 amd64_linux_record_tdep.ioctl_FIONBIO = 0x5421;
1482 amd64_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
1483 amd64_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
1484 amd64_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
1485 amd64_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
1486 amd64_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
1487 amd64_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
1488 amd64_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
1489 amd64_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
1490 amd64_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
1491 amd64_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
1492 amd64_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
1493 amd64_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
1494 amd64_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
1495 amd64_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
1496 amd64_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
1497 amd64_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
1498 amd64_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
1499 amd64_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
1500 amd64_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
1501 amd64_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
1502 amd64_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
1503 amd64_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
1504 amd64_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
1505 amd64_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
1506 amd64_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
1507 amd64_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
1508 amd64_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
1509 amd64_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
1510 amd64_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
1511 amd64_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
1512 amd64_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
1513
1514 /* These values are the second argument of system call "sys_fcntl"
1515 and "sys_fcntl64". They are obtained from Linux Kernel source. */
1516 amd64_linux_record_tdep.fcntl_F_GETLK = 5;
1517 amd64_linux_record_tdep.fcntl_F_GETLK64 = 12;
1518 amd64_linux_record_tdep.fcntl_F_SETLK64 = 13;
1519 amd64_linux_record_tdep.fcntl_F_SETLKW64 = 14;
1520
1521 amd64_linux_record_tdep.arg1 = AMD64_RDI_REGNUM;
1522 amd64_linux_record_tdep.arg2 = AMD64_RSI_REGNUM;
1523 amd64_linux_record_tdep.arg3 = AMD64_RDX_REGNUM;
1524 amd64_linux_record_tdep.arg4 = AMD64_R10_REGNUM;
1525 amd64_linux_record_tdep.arg5 = AMD64_R8_REGNUM;
1526 amd64_linux_record_tdep.arg6 = AMD64_R9_REGNUM;
1527
1528 tdep->i386_syscall_record = amd64_linux_syscall_record;
2213a65d 1529}
c4f35dd8 1530\f
2213a65d
MK
1531
1532/* Provide a prototype to silence -Wmissing-prototypes. */
51433e4b 1533extern void _initialize_amd64_linux_tdep (void);
2213a65d
MK
1534
1535void
51433e4b 1536_initialize_amd64_linux_tdep (void)
2213a65d 1537{
51433e4b
MK
1538 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
1539 GDB_OSABI_LINUX, amd64_linux_init_abi);
90884b2b
L
1540
1541 /* Initialize the Linux target description */
1542 initialize_tdesc_amd64_linux ();
a055a187 1543 initialize_tdesc_amd64_avx_linux ();
2213a65d 1544}
This page took 0.649843 seconds and 4 git commands to generate.