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