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