OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [amd64-linux-tdep.c] - Blame information for rev 855

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.