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