1 /* Target-dependent code for GNU/Linux i386.
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 #include "reggroups.h"
29 #include "dwarf2-frame.h"
30 #include "gdb_string.h"
32 #include "i386-tdep.h"
33 #include "i386-linux-tdep.h"
34 #include "linux-tdep.h"
35 #include "glibc-tdep.h"
36 #include "solib-svr4.h"
38 #include "arch-utils.h"
42 #include "linux-record.h"
45 /* Supported register note sections. */
46 static struct core_regset_section i386_linux_regset_sections[] =
54 /* Return the name of register REG. */
57 i386_linux_register_name (struct gdbarch *gdbarch, int reg)
59 /* Deal with the extra "orig_eax" pseudo register. */
60 if (reg == I386_LINUX_ORIG_EAX_REGNUM)
63 return i386_register_name (gdbarch, reg);
66 /* Return non-zero, when the register is in the corresponding register
67 group. Put the LINUX_ORIG_EAX register in the system group. */
69 i386_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
70 struct reggroup *group)
72 if (regnum == I386_LINUX_ORIG_EAX_REGNUM)
73 return (group == system_reggroup
74 || group == save_reggroup
75 || group == restore_reggroup);
76 return i386_register_reggroup_p (gdbarch, regnum, group);
80 /* Recognizing signal handler frames. */
82 /* GNU/Linux has two flavors of signals. Normal signal handlers, and
83 "realtime" (RT) signals. The RT signals can provide additional
84 information to the signal handler if the SA_SIGINFO flag is set
85 when establishing a signal handler using `sigaction'. It is not
86 unlikely that future versions of GNU/Linux will support SA_SIGINFO
87 for normal signals too. */
89 /* When the i386 Linux kernel calls a signal handler and the
90 SA_RESTORER flag isn't set, the return address points to a bit of
91 code on the stack. This function returns whether the PC appears to
92 be within this bit of code.
94 The instruction sequence for normal signals is
98 or 0x58 0xb8 0x77 0x00 0x00 0x00 0xcd 0x80.
100 Checking for the code sequence should be somewhat reliable, because
101 the effect is to call the system call sigreturn. This is unlikely
102 to occur anywhere other than in a signal trampoline.
104 It kind of sucks that we have to read memory from the process in
105 order to identify a signal trampoline, but there doesn't seem to be
106 any other way. Therefore we only do the memory reads if no
107 function name could be identified, which should be the case since
108 the code is on the stack.
110 Detection of signal trampolines for handlers that set the
111 SA_RESTORER flag is in general not possible. Unfortunately this is
112 what the GNU C Library has been doing for quite some time now.
113 However, as of version 2.1.2, the GNU C Library uses signal
114 trampolines (named __restore and __restore_rt) that are identical
115 to the ones used by the kernel. Therefore, these trampolines are
118 #define LINUX_SIGTRAMP_INSN0 0x58 /* pop %eax */
119 #define LINUX_SIGTRAMP_OFFSET0 0
120 #define LINUX_SIGTRAMP_INSN1 0xb8 /* mov $NNNN, %eax */
121 #define LINUX_SIGTRAMP_OFFSET1 1
122 #define LINUX_SIGTRAMP_INSN2 0xcd /* int */
123 #define LINUX_SIGTRAMP_OFFSET2 6
125 static const gdb_byte linux_sigtramp_code[] =
127 LINUX_SIGTRAMP_INSN0, /* pop %eax */
128 LINUX_SIGTRAMP_INSN1, 0x77, 0x00, 0x00, 0x00, /* mov $0x77, %eax */
129 LINUX_SIGTRAMP_INSN2, 0x80 /* int $0x80 */
132 #define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
134 /* If THIS_FRAME is a sigtramp routine, return the address of the
135 start of the routine. Otherwise, return 0. */
138 i386_linux_sigtramp_start (struct frame_info *this_frame)
140 CORE_ADDR pc = get_frame_pc (this_frame);
141 gdb_byte buf[LINUX_SIGTRAMP_LEN];
143 /* We only recognize a signal trampoline if PC is at the start of
144 one of the three instructions. We optimize for finding the PC at
145 the start, as will be the case when the trampoline is not the
146 first frame on the stack. We assume that in the case where the
147 PC is not at the start of the instruction sequence, there will be
148 a few trailing readable bytes on the stack. */
150 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
153 if (buf[0] != LINUX_SIGTRAMP_INSN0)
159 case LINUX_SIGTRAMP_INSN1:
160 adjust = LINUX_SIGTRAMP_OFFSET1;
162 case LINUX_SIGTRAMP_INSN2:
163 adjust = LINUX_SIGTRAMP_OFFSET2;
171 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
175 if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
181 /* This function does the same for RT signals. Here the instruction
185 or 0xb8 0xad 0x00 0x00 0x00 0xcd 0x80.
187 The effect is to call the system call rt_sigreturn. */
189 #define LINUX_RT_SIGTRAMP_INSN0 0xb8 /* mov $NNNN, %eax */
190 #define LINUX_RT_SIGTRAMP_OFFSET0 0
191 #define LINUX_RT_SIGTRAMP_INSN1 0xcd /* int */
192 #define LINUX_RT_SIGTRAMP_OFFSET1 5
194 static const gdb_byte linux_rt_sigtramp_code[] =
196 LINUX_RT_SIGTRAMP_INSN0, 0xad, 0x00, 0x00, 0x00, /* mov $0xad, %eax */
197 LINUX_RT_SIGTRAMP_INSN1, 0x80 /* int $0x80 */
200 #define LINUX_RT_SIGTRAMP_LEN (sizeof linux_rt_sigtramp_code)
202 /* If THIS_FRAME is an RT sigtramp routine, return the address of the
203 start of the routine. Otherwise, return 0. */
206 i386_linux_rt_sigtramp_start (struct frame_info *this_frame)
208 CORE_ADDR pc = get_frame_pc (this_frame);
209 gdb_byte buf[LINUX_RT_SIGTRAMP_LEN];
211 /* We only recognize a signal trampoline if PC is at the start of
212 one of the two instructions. We optimize for finding the PC at
213 the start, as will be the case when the trampoline is not the
214 first frame on the stack. We assume that in the case where the
215 PC is not at the start of the instruction sequence, there will be
216 a few trailing readable bytes on the stack. */
218 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN))
221 if (buf[0] != LINUX_RT_SIGTRAMP_INSN0)
223 if (buf[0] != LINUX_RT_SIGTRAMP_INSN1)
226 pc -= LINUX_RT_SIGTRAMP_OFFSET1;
228 if (!safe_frame_unwind_memory (this_frame, pc, buf,
229 LINUX_RT_SIGTRAMP_LEN))
233 if (memcmp (buf, linux_rt_sigtramp_code, LINUX_RT_SIGTRAMP_LEN) != 0)
239 /* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
243 i386_linux_sigtramp_p (struct frame_info *this_frame)
245 CORE_ADDR pc = get_frame_pc (this_frame);
248 find_pc_partial_function (pc, &name, NULL, NULL);
250 /* If we have NAME, we can optimize the search. The trampolines are
251 named __restore and __restore_rt. However, they aren't dynamically
252 exported from the shared C library, so the trampoline may appear to
253 be part of the preceding function. This should always be sigaction,
254 __sigaction, or __libc_sigaction (all aliases to the same function). */
255 if (name == NULL || strstr (name, "sigaction") != NULL)
256 return (i386_linux_sigtramp_start (this_frame) != 0
257 || i386_linux_rt_sigtramp_start (this_frame) != 0);
259 return (strcmp ("__restore", name) == 0
260 || strcmp ("__restore_rt", name) == 0);
263 /* Return one if the PC of THIS_FRAME is in a signal trampoline which
264 may have DWARF-2 CFI. */
267 i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
268 struct frame_info *this_frame)
270 CORE_ADDR pc = get_frame_pc (this_frame);
273 find_pc_partial_function (pc, &name, NULL, NULL);
275 /* If a vsyscall DSO is in use, the signal trampolines may have these
277 if (name && (strcmp (name, "__kernel_sigreturn") == 0
278 || strcmp (name, "__kernel_rt_sigreturn") == 0))
284 /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
285 #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
287 /* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
288 address of the associated sigcontext structure. */
291 i386_linux_sigcontext_addr (struct frame_info *this_frame)
297 get_frame_register (this_frame, I386_ESP_REGNUM, buf);
298 sp = extract_unsigned_integer (buf, 4);
300 pc = i386_linux_sigtramp_start (this_frame);
303 /* The sigcontext structure lives on the stack, right after
304 the signum argument. We determine the address of the
305 sigcontext structure by looking at the frame's stack
306 pointer. Keep in mind that the first instruction of the
307 sigtramp code is "pop %eax". If the PC is after this
308 instruction, adjust the returned value accordingly. */
309 if (pc == get_frame_pc (this_frame))
314 pc = i386_linux_rt_sigtramp_start (this_frame);
317 CORE_ADDR ucontext_addr;
319 /* The sigcontext structure is part of the user context. A
320 pointer to the user context is passed as the third argument
321 to the signal handler. */
322 read_memory (sp + 8, buf, 4);
323 ucontext_addr = extract_unsigned_integer (buf, 4);
324 return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
327 error (_("Couldn't recognize signal trampoline."));
331 /* Set the program counter for process PTID to PC. */
334 i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
336 regcache_cooked_write_unsigned (regcache, I386_EIP_REGNUM, pc);
338 /* We must be careful with modifying the program counter. If we
339 just interrupted a system call, the kernel might try to restart
340 it when we resume the inferior. On restarting the system call,
341 the kernel will try backing up the program counter even though it
342 no longer points at the system call. This typically results in a
343 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
344 "orig_eax" pseudo-register.
346 Note that "orig_eax" is saved when setting up a dummy call frame.
347 This means that it is properly restored when that frame is
348 popped, and that the interrupted system call will be restarted
349 when we resume the inferior on return from a function call from
350 within GDB. In all other cases the system call will not be
352 regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1);
355 /* Parse the arguments of current system call instruction and record
356 the values of the registers and memory that will be changed into
357 "record_arch_list". This instruction is "int 0x80" (Linux
358 Kernel2.4) or "sysenter" (Linux Kernel 2.6).
360 Return -1 if something wrong. */
362 static struct linux_record_tdep i386_linux_record_tdep;
365 i386_linux_intx80_sysenter_record (struct regcache *regcache)
370 regcache_raw_read (regcache, I386_EAX_REGNUM, (gdb_byte *)&tmpu32);
372 ret = record_linux_system_call (tmpu32, regcache,
373 &i386_linux_record_tdep);
377 /* Record the return value of the system call. */
378 if (record_arch_list_add_reg (regcache, I386_EAX_REGNUM))
385 /* The register sets used in GNU/Linux ELF core-dumps are identical to
386 the register sets in `struct user' that are used for a.out
387 core-dumps. These are also used by ptrace(2). The corresponding
388 types are `elf_gregset_t' for the general-purpose registers (with
389 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
390 for the floating-point registers.
392 Those types used to be available under the names `gregset_t' and
393 `fpregset_t' too, and GDB used those names in the past. But those
394 names are now used for the register sets used in the `mcontext_t'
395 type, which have a different size and layout. */
397 /* Mapping between the general-purpose registers in `struct user'
398 format and GDB's register cache layout. */
400 /* From <sys/reg.h>. */
401 static int i386_linux_gregset_reg_offset[] =
412 14 * 4, /* %eflags */
419 -1, -1, -1, -1, -1, -1, -1, -1,
420 -1, -1, -1, -1, -1, -1, -1, -1,
421 -1, -1, -1, -1, -1, -1, -1, -1,
423 11 * 4 /* "orig_eax" */
426 /* Mapping between the general-purpose registers in `struct
427 sigcontext' format and GDB's register cache layout. */
429 /* From <asm/sigcontext.h>. */
430 static int i386_linux_sc_reg_offset[] =
441 16 * 4, /* %eflags */
451 i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
453 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
455 /* GNU/Linux uses ELF. */
456 i386_elf_init_abi (info, gdbarch);
458 /* Since we have the extra "orig_eax" register on GNU/Linux, we have
459 to adjust a few things. */
461 set_gdbarch_write_pc (gdbarch, i386_linux_write_pc);
462 set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
463 set_gdbarch_register_name (gdbarch, i386_linux_register_name);
464 set_gdbarch_register_reggroup_p (gdbarch, i386_linux_register_reggroup_p);
466 tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
467 tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
468 tdep->sizeof_gregset = 17 * 4;
470 tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
472 tdep->sigtramp_p = i386_linux_sigtramp_p;
473 tdep->sigcontext_addr = i386_linux_sigcontext_addr;
474 tdep->sc_reg_offset = i386_linux_sc_reg_offset;
475 tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset);
477 set_gdbarch_process_record (gdbarch, i386_process_record);
479 /* Initialize the i386_linux_record_tdep. */
480 /* These values are the size of the type that will be used in a system
481 call. They are obtained from Linux Kernel source. */
482 i386_linux_record_tdep.size__old_kernel_stat = 32;
483 i386_linux_record_tdep.size_tms = 16;
484 i386_linux_record_tdep.size_loff_t = 8;
485 i386_linux_record_tdep.size_flock = 16;
486 i386_linux_record_tdep.size_oldold_utsname = 45;
487 i386_linux_record_tdep.size_ustat = 20;
488 i386_linux_record_tdep.size_old_sigaction = 140;
489 i386_linux_record_tdep.size_old_sigset_t = 128;
490 i386_linux_record_tdep.size_rlimit = 8;
491 i386_linux_record_tdep.size_rusage = 72;
492 i386_linux_record_tdep.size_timeval = 8;
493 i386_linux_record_tdep.size_timezone = 8;
494 i386_linux_record_tdep.size_old_gid_t = 2;
495 i386_linux_record_tdep.size_old_uid_t = 2;
496 i386_linux_record_tdep.size_fd_set = 128;
497 i386_linux_record_tdep.size_dirent = 268;
498 i386_linux_record_tdep.size_dirent64 = 276;
499 i386_linux_record_tdep.size_statfs = 64;
500 i386_linux_record_tdep.size_statfs64 = 84;
501 i386_linux_record_tdep.size_sockaddr = 16;
502 i386_linux_record_tdep.size_int = 4;
503 i386_linux_record_tdep.size_long = 4;
504 i386_linux_record_tdep.size_ulong = 4;
505 i386_linux_record_tdep.size_msghdr = 28;
506 i386_linux_record_tdep.size_itimerval = 16;
507 i386_linux_record_tdep.size_stat = 88;
508 i386_linux_record_tdep.size_old_utsname = 325;
509 i386_linux_record_tdep.size_sysinfo = 64;
510 i386_linux_record_tdep.size_msqid_ds = 88;
511 i386_linux_record_tdep.size_shmid_ds = 84;
512 i386_linux_record_tdep.size_new_utsname = 390;
513 i386_linux_record_tdep.size_timex = 128;
514 i386_linux_record_tdep.size_mem_dqinfo = 24;
515 i386_linux_record_tdep.size_if_dqblk = 68;
516 i386_linux_record_tdep.size_fs_quota_stat = 68;
517 i386_linux_record_tdep.size_timespec = 8;
518 i386_linux_record_tdep.size_pollfd = 8;
519 i386_linux_record_tdep.size_NFS_FHSIZE = 32;
520 i386_linux_record_tdep.size_knfsd_fh = 132;
521 i386_linux_record_tdep.size_TASK_COMM_LEN = 16;
522 i386_linux_record_tdep.size_sigaction = 140;
523 i386_linux_record_tdep.size_sigset_t = 8;
524 i386_linux_record_tdep.size_siginfo_t = 128;
525 i386_linux_record_tdep.size_cap_user_data_t = 12;
526 i386_linux_record_tdep.size_stack_t = 12;
527 i386_linux_record_tdep.size_off_t = i386_linux_record_tdep.size_long;
528 i386_linux_record_tdep.size_stat64 = 96;
529 i386_linux_record_tdep.size_gid_t = 2;
530 i386_linux_record_tdep.size_uid_t = 2;
531 i386_linux_record_tdep.size_PAGE_SIZE = 4096;
532 i386_linux_record_tdep.size_flock64 = 24;
533 i386_linux_record_tdep.size_user_desc = 16;
534 i386_linux_record_tdep.size_io_event = 32;
535 i386_linux_record_tdep.size_iocb = 64;
536 i386_linux_record_tdep.size_epoll_event = 12;
537 i386_linux_record_tdep.size_itimerspec = i386_linux_record_tdep.size_timespec * 2;
538 i386_linux_record_tdep.size_mq_attr = 32;
539 i386_linux_record_tdep.size_siginfo = 128;
540 i386_linux_record_tdep.size_termios = 36;
541 i386_linux_record_tdep.size_termios2 = 44;
542 i386_linux_record_tdep.size_pid_t = 4;
543 i386_linux_record_tdep.size_winsize = 8;
544 i386_linux_record_tdep.size_serial_struct = 60;
545 i386_linux_record_tdep.size_serial_icounter_struct = 80;
546 i386_linux_record_tdep.size_hayes_esp_config = 12;
548 /* These values are the second argument of system call "sys_ioctl".
549 They are obtained from Linux Kernel source. */
550 i386_linux_record_tdep.ioctl_TCGETS = 0x5401;
551 i386_linux_record_tdep.ioctl_TCSETS = 0x5402;
552 i386_linux_record_tdep.ioctl_TCSETSW = 0x5403;
553 i386_linux_record_tdep.ioctl_TCSETSF = 0x5404;
554 i386_linux_record_tdep.ioctl_TCGETA = 0x5405;
555 i386_linux_record_tdep.ioctl_TCSETA = 0x5406;
556 i386_linux_record_tdep.ioctl_TCSETAW = 0x5407;
557 i386_linux_record_tdep.ioctl_TCSETAF = 0x5408;
558 i386_linux_record_tdep.ioctl_TCSBRK = 0x5409;
559 i386_linux_record_tdep.ioctl_TCXONC = 0x540A;
560 i386_linux_record_tdep.ioctl_TCFLSH = 0x540B;
561 i386_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
562 i386_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
563 i386_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
564 i386_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
565 i386_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
566 i386_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
567 i386_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
568 i386_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
569 i386_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
570 i386_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
571 i386_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
572 i386_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
573 i386_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
574 i386_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
575 i386_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
576 i386_linux_record_tdep.ioctl_FIONREAD = 0x541B;
577 i386_linux_record_tdep.ioctl_TIOCINQ = i386_linux_record_tdep.ioctl_FIONREAD;
578 i386_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
579 i386_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
580 i386_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
581 i386_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
582 i386_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
583 i386_linux_record_tdep.ioctl_FIONBIO = 0x5421;
584 i386_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
585 i386_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
586 i386_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
587 i386_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
588 i386_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
589 i386_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
590 i386_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
591 i386_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
592 i386_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
593 i386_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
594 i386_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
595 i386_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
596 i386_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
597 i386_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
598 i386_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
599 i386_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
600 i386_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
601 i386_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
602 i386_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
603 i386_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
604 i386_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
605 i386_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
606 i386_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
607 i386_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
608 i386_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
609 i386_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
610 i386_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
611 i386_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
612 i386_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
613 i386_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
614 i386_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
616 /* These values are the second argument of system call "sys_fcntl"
617 and "sys_fcntl64". They are obtained from Linux Kernel source. */
618 i386_linux_record_tdep.fcntl_F_GETLK = 5;
619 i386_linux_record_tdep.fcntl_F_GETLK64 = 12;
620 i386_linux_record_tdep.fcntl_F_SETLK64 = 13;
621 i386_linux_record_tdep.fcntl_F_SETLKW64 = 14;
623 i386_linux_record_tdep.arg1 = I386_EBX_REGNUM;
624 i386_linux_record_tdep.arg2 = I386_ECX_REGNUM;
625 i386_linux_record_tdep.arg3 = I386_EDX_REGNUM;
626 i386_linux_record_tdep.arg4 = I386_ESI_REGNUM;
627 i386_linux_record_tdep.arg5 = I386_EDI_REGNUM;
629 tdep->i386_intx80_record = i386_linux_intx80_sysenter_record;
630 tdep->i386_sysenter_record = i386_linux_intx80_sysenter_record;
632 /* N_FUN symbols in shared libaries have 0 for their values and need
634 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
636 /* GNU/Linux uses SVR4-style shared libraries. */
637 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
638 set_solib_svr4_fetch_link_map_offsets
639 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
641 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
642 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
644 dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
646 /* Enable TLS support. */
647 set_gdbarch_fetch_tls_load_module_address (gdbarch,
648 svr4_fetch_objfile_link_map);
650 /* Install supported register note sections. */
651 set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections);
653 /* Displaced stepping. */
654 set_gdbarch_displaced_step_copy_insn (gdbarch,
655 simple_displaced_step_copy_insn);
656 set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup);
657 set_gdbarch_displaced_step_free_closure (gdbarch,
658 simple_displaced_step_free_closure);
659 set_gdbarch_displaced_step_location (gdbarch,
660 displaced_step_at_entry_point);
662 set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
665 /* Provide a prototype to silence -Wmissing-prototypes. */
666 extern void _initialize_i386_linux_tdep (void);
669 _initialize_i386_linux_tdep (void)
671 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
672 i386_linux_init_abi);