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