* infrun.c (handle_inferior_event): Clear trap_expected after
[deliverable/binutils-gdb.git] / gdb / i386-linux-tdep.c
CommitLineData
871fbe6a 1/* Target-dependent code for GNU/Linux i386.
ca557f44 2
0fb0cc75 3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
4252dc94 4 Free Software Foundation, Inc.
e7ee86a9
JB
5
6 This file is part of GDB.
7
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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
e7ee86a9
JB
11 (at your option) any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
e7ee86a9
JB
20
21#include "defs.h"
22#include "gdbcore.h"
23#include "frame.h"
24#include "value.h"
4e052eda 25#include "regcache.h"
6441c4a0 26#include "inferior.h"
0670c0aa 27#include "osabi.h"
38c968cf 28#include "reggroups.h"
5cb2fe25 29#include "dwarf2-frame.h"
0670c0aa 30#include "gdb_string.h"
4be87837 31
8201327c
MK
32#include "i386-tdep.h"
33#include "i386-linux-tdep.h"
4aa995e1 34#include "linux-tdep.h"
0670c0aa 35#include "glibc-tdep.h"
871fbe6a 36#include "solib-svr4.h"
982e9687 37#include "symtab.h"
237fc4c9 38#include "arch-utils.h"
17ea7499
CES
39#include "regset.h"
40
77fcef51
HZ
41#include "record.h"
42#include "linux-record.h"
43#include <stdint.h>
44
17ea7499
CES
45/* Supported register note sections. */
46static struct core_regset_section i386_linux_regset_sections[] =
47{
48 { ".reg", 144 },
49 { ".reg2", 108 },
50 { ".reg-xfp", 512 },
51 { NULL, 0 }
52};
8201327c 53
6441c4a0
MK
54/* Return the name of register REG. */
55
16775908 56static const char *
d93859e2 57i386_linux_register_name (struct gdbarch *gdbarch, int reg)
6441c4a0
MK
58{
59 /* Deal with the extra "orig_eax" pseudo register. */
60 if (reg == I386_LINUX_ORIG_EAX_REGNUM)
61 return "orig_eax";
62
d93859e2 63 return i386_register_name (gdbarch, reg);
6441c4a0 64}
38c968cf
AC
65
66/* Return non-zero, when the register is in the corresponding register
67 group. Put the LINUX_ORIG_EAX register in the system group. */
68static int
69i386_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
70 struct reggroup *group)
71{
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);
77}
78
e7ee86a9
JB
79\f
80/* Recognizing signal handler frames. */
81
ca557f44 82/* GNU/Linux has two flavors of signals. Normal signal handlers, and
e7ee86a9
JB
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
ca557f44
AC
86 unlikely that future versions of GNU/Linux will support SA_SIGINFO
87 for normal signals too. */
e7ee86a9
JB
88
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.
93
94 The instruction sequence for normal signals is
95 pop %eax
acd5c798 96 mov $0x77, %eax
e7ee86a9
JB
97 int $0x80
98 or 0x58 0xb8 0x77 0x00 0x00 0x00 0xcd 0x80.
99
100 Checking for the code sequence should be somewhat reliable, because
101 the effect is to call the system call sigreturn. This is unlikely
911bc6ee 102 to occur anywhere other than in a signal trampoline.
e7ee86a9
JB
103
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
911bc6ee
MK
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.
e7ee86a9
JB
109
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
116 supported too. */
117
acd5c798
MK
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
e7ee86a9 124
4252dc94 125static const gdb_byte linux_sigtramp_code[] =
e7ee86a9
JB
126{
127 LINUX_SIGTRAMP_INSN0, /* pop %eax */
acd5c798 128 LINUX_SIGTRAMP_INSN1, 0x77, 0x00, 0x00, 0x00, /* mov $0x77, %eax */
e7ee86a9
JB
129 LINUX_SIGTRAMP_INSN2, 0x80 /* int $0x80 */
130};
131
132#define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
133
10458914
DJ
134/* If THIS_FRAME is a sigtramp routine, return the address of the
135 start of the routine. Otherwise, return 0. */
e7ee86a9
JB
136
137static CORE_ADDR
10458914 138i386_linux_sigtramp_start (struct frame_info *this_frame)
e7ee86a9 139{
10458914 140 CORE_ADDR pc = get_frame_pc (this_frame);
4252dc94 141 gdb_byte buf[LINUX_SIGTRAMP_LEN];
e7ee86a9
JB
142
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. */
149
10458914 150 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
e7ee86a9
JB
151 return 0;
152
153 if (buf[0] != LINUX_SIGTRAMP_INSN0)
154 {
155 int adjust;
156
157 switch (buf[0])
158 {
159 case LINUX_SIGTRAMP_INSN1:
160 adjust = LINUX_SIGTRAMP_OFFSET1;
161 break;
162 case LINUX_SIGTRAMP_INSN2:
163 adjust = LINUX_SIGTRAMP_OFFSET2;
164 break;
165 default:
166 return 0;
167 }
168
169 pc -= adjust;
170
10458914 171 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
e7ee86a9
JB
172 return 0;
173 }
174
175 if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
176 return 0;
177
178 return pc;
179}
180
181/* This function does the same for RT signals. Here the instruction
182 sequence is
acd5c798 183 mov $0xad, %eax
e7ee86a9
JB
184 int $0x80
185 or 0xb8 0xad 0x00 0x00 0x00 0xcd 0x80.
186
187 The effect is to call the system call rt_sigreturn. */
188
acd5c798
MK
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
e7ee86a9 193
4252dc94 194static const gdb_byte linux_rt_sigtramp_code[] =
e7ee86a9 195{
acd5c798 196 LINUX_RT_SIGTRAMP_INSN0, 0xad, 0x00, 0x00, 0x00, /* mov $0xad, %eax */
e7ee86a9
JB
197 LINUX_RT_SIGTRAMP_INSN1, 0x80 /* int $0x80 */
198};
199
200#define LINUX_RT_SIGTRAMP_LEN (sizeof linux_rt_sigtramp_code)
201
10458914
DJ
202/* If THIS_FRAME is an RT sigtramp routine, return the address of the
203 start of the routine. Otherwise, return 0. */
e7ee86a9
JB
204
205static CORE_ADDR
10458914 206i386_linux_rt_sigtramp_start (struct frame_info *this_frame)
e7ee86a9 207{
10458914 208 CORE_ADDR pc = get_frame_pc (this_frame);
4252dc94 209 gdb_byte buf[LINUX_RT_SIGTRAMP_LEN];
e7ee86a9
JB
210
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. */
217
10458914 218 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN))
e7ee86a9
JB
219 return 0;
220
221 if (buf[0] != LINUX_RT_SIGTRAMP_INSN0)
222 {
223 if (buf[0] != LINUX_RT_SIGTRAMP_INSN1)
224 return 0;
225
226 pc -= LINUX_RT_SIGTRAMP_OFFSET1;
227
10458914 228 if (!safe_frame_unwind_memory (this_frame, pc, buf,
8e6bed05 229 LINUX_RT_SIGTRAMP_LEN))
e7ee86a9
JB
230 return 0;
231 }
232
233 if (memcmp (buf, linux_rt_sigtramp_code, LINUX_RT_SIGTRAMP_LEN) != 0)
234 return 0;
235
236 return pc;
237}
238
10458914
DJ
239/* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
240 routine. */
e7ee86a9 241
8201327c 242static int
10458914 243i386_linux_sigtramp_p (struct frame_info *this_frame)
e7ee86a9 244{
10458914 245 CORE_ADDR pc = get_frame_pc (this_frame);
911bc6ee
MK
246 char *name;
247
248 find_pc_partial_function (pc, &name, NULL, NULL);
249
ef17e74b
DJ
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)
10458914
DJ
256 return (i386_linux_sigtramp_start (this_frame) != 0
257 || i386_linux_rt_sigtramp_start (this_frame) != 0);
ef17e74b
DJ
258
259 return (strcmp ("__restore", name) == 0
260 || strcmp ("__restore_rt", name) == 0);
e7ee86a9
JB
261}
262
4a4e5149
DJ
263/* Return one if the PC of THIS_FRAME is in a signal trampoline which
264 may have DWARF-2 CFI. */
12b8a2cb
DJ
265
266static int
267i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
4a4e5149 268 struct frame_info *this_frame)
12b8a2cb 269{
4a4e5149 270 CORE_ADDR pc = get_frame_pc (this_frame);
12b8a2cb
DJ
271 char *name;
272
273 find_pc_partial_function (pc, &name, NULL, NULL);
274
275 /* If a vsyscall DSO is in use, the signal trampolines may have these
276 names. */
277 if (name && (strcmp (name, "__kernel_sigreturn") == 0
278 || strcmp (name, "__kernel_rt_sigreturn") == 0))
279 return 1;
280
281 return 0;
282}
283
acd5c798
MK
284/* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
285#define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
286
10458914
DJ
287/* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
288 address of the associated sigcontext structure. */
e7ee86a9 289
b7d15bf7 290static CORE_ADDR
10458914 291i386_linux_sigcontext_addr (struct frame_info *this_frame)
e7ee86a9 292{
e17a4113
UW
293 struct gdbarch *gdbarch = get_frame_arch (this_frame);
294 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
e7ee86a9 295 CORE_ADDR pc;
acd5c798 296 CORE_ADDR sp;
4252dc94 297 gdb_byte buf[4];
acd5c798 298
10458914 299 get_frame_register (this_frame, I386_ESP_REGNUM, buf);
e17a4113 300 sp = extract_unsigned_integer (buf, 4, byte_order);
e7ee86a9 301
10458914 302 pc = i386_linux_sigtramp_start (this_frame);
e7ee86a9
JB
303 if (pc)
304 {
acd5c798
MK
305 /* The sigcontext structure lives on the stack, right after
306 the signum argument. We determine the address of the
307 sigcontext structure by looking at the frame's stack
308 pointer. Keep in mind that the first instruction of the
309 sigtramp code is "pop %eax". If the PC is after this
310 instruction, adjust the returned value accordingly. */
10458914 311 if (pc == get_frame_pc (this_frame))
e7ee86a9
JB
312 return sp + 4;
313 return sp;
314 }
315
10458914 316 pc = i386_linux_rt_sigtramp_start (this_frame);
e7ee86a9
JB
317 if (pc)
318 {
acd5c798
MK
319 CORE_ADDR ucontext_addr;
320
321 /* The sigcontext structure is part of the user context. A
322 pointer to the user context is passed as the third argument
323 to the signal handler. */
324 read_memory (sp + 8, buf, 4);
e17a4113 325 ucontext_addr = extract_unsigned_integer (buf, 4, byte_order);
acd5c798 326 return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
e7ee86a9
JB
327 }
328
8a3fe4f8 329 error (_("Couldn't recognize signal trampoline."));
e7ee86a9
JB
330 return 0;
331}
332
6441c4a0
MK
333/* Set the program counter for process PTID to PC. */
334
8201327c 335static void
61a1198a 336i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
6441c4a0 337{
61a1198a 338 regcache_cooked_write_unsigned (regcache, I386_EIP_REGNUM, pc);
6441c4a0
MK
339
340 /* We must be careful with modifying the program counter. If we
341 just interrupted a system call, the kernel might try to restart
342 it when we resume the inferior. On restarting the system call,
343 the kernel will try backing up the program counter even though it
344 no longer points at the system call. This typically results in a
345 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
346 "orig_eax" pseudo-register.
347
348 Note that "orig_eax" is saved when setting up a dummy call frame.
349 This means that it is properly restored when that frame is
350 popped, and that the interrupted system call will be restarted
351 when we resume the inferior on return from a function call from
352 within GDB. In all other cases the system call will not be
353 restarted. */
61a1198a 354 regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1);
6441c4a0 355}
77fcef51
HZ
356
357/* Parse the arguments of current system call instruction and record
358 the values of the registers and memory that will be changed into
359 "record_arch_list". This instruction is "int 0x80" (Linux
360 Kernel2.4) or "sysenter" (Linux Kernel 2.6).
361
362 Return -1 if something wrong. */
363
364static struct linux_record_tdep i386_linux_record_tdep;
365
366static int
367i386_linux_intx80_sysenter_record (struct regcache *regcache)
368{
369 int ret;
370 uint32_t tmpu32;
371
372 regcache_raw_read (regcache, I386_EAX_REGNUM, (gdb_byte *)&tmpu32);
373
374 ret = record_linux_system_call (tmpu32, regcache,
375 &i386_linux_record_tdep);
376 if (ret)
377 return ret;
378
379 /* Record the return value of the system call. */
380 if (record_arch_list_add_reg (regcache, I386_EAX_REGNUM))
381 return -1;
382
383 return 0;
384}
6441c4a0 385\f
8201327c 386
e9f1aad5
MK
387/* The register sets used in GNU/Linux ELF core-dumps are identical to
388 the register sets in `struct user' that are used for a.out
389 core-dumps. These are also used by ptrace(2). The corresponding
390 types are `elf_gregset_t' for the general-purpose registers (with
391 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
392 for the floating-point registers.
393
394 Those types used to be available under the names `gregset_t' and
395 `fpregset_t' too, and GDB used those names in the past. But those
396 names are now used for the register sets used in the `mcontext_t'
397 type, which have a different size and layout. */
398
399/* Mapping between the general-purpose registers in `struct user'
400 format and GDB's register cache layout. */
401
402/* From <sys/reg.h>. */
403static int i386_linux_gregset_reg_offset[] =
404{
405 6 * 4, /* %eax */
406 1 * 4, /* %ecx */
407 2 * 4, /* %edx */
408 0 * 4, /* %ebx */
409 15 * 4, /* %esp */
410 5 * 4, /* %ebp */
411 3 * 4, /* %esi */
412 4 * 4, /* %edi */
413 12 * 4, /* %eip */
414 14 * 4, /* %eflags */
415 13 * 4, /* %cs */
416 16 * 4, /* %ss */
417 7 * 4, /* %ds */
418 8 * 4, /* %es */
419 9 * 4, /* %fs */
420 10 * 4, /* %gs */
421 -1, -1, -1, -1, -1, -1, -1, -1,
422 -1, -1, -1, -1, -1, -1, -1, -1,
423 -1, -1, -1, -1, -1, -1, -1, -1,
424 -1,
425 11 * 4 /* "orig_eax" */
426};
427
428/* Mapping between the general-purpose registers in `struct
429 sigcontext' format and GDB's register cache layout. */
430
a3386186 431/* From <asm/sigcontext.h>. */
bb489b3c 432static int i386_linux_sc_reg_offset[] =
a3386186
MK
433{
434 11 * 4, /* %eax */
435 10 * 4, /* %ecx */
436 9 * 4, /* %edx */
437 8 * 4, /* %ebx */
438 7 * 4, /* %esp */
439 6 * 4, /* %ebp */
440 5 * 4, /* %esi */
441 4 * 4, /* %edi */
442 14 * 4, /* %eip */
443 16 * 4, /* %eflags */
444 15 * 4, /* %cs */
445 18 * 4, /* %ss */
446 3 * 4, /* %ds */
447 2 * 4, /* %es */
448 1 * 4, /* %fs */
449 0 * 4 /* %gs */
450};
451
8201327c
MK
452static void
453i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
454{
455 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
456
457 /* GNU/Linux uses ELF. */
458 i386_elf_init_abi (info, gdbarch);
459
8201327c
MK
460 /* Since we have the extra "orig_eax" register on GNU/Linux, we have
461 to adjust a few things. */
462
463 set_gdbarch_write_pc (gdbarch, i386_linux_write_pc);
bb489b3c 464 set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
8201327c 465 set_gdbarch_register_name (gdbarch, i386_linux_register_name);
38c968cf 466 set_gdbarch_register_reggroup_p (gdbarch, i386_linux_register_reggroup_p);
8201327c 467
e9f1aad5
MK
468 tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
469 tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
470 tdep->sizeof_gregset = 17 * 4;
471
8201327c
MK
472 tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
473
911bc6ee 474 tdep->sigtramp_p = i386_linux_sigtramp_p;
b7d15bf7 475 tdep->sigcontext_addr = i386_linux_sigcontext_addr;
a3386186 476 tdep->sc_reg_offset = i386_linux_sc_reg_offset;
bb489b3c 477 tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset);
8201327c 478
a6b808b4
HZ
479 set_gdbarch_process_record (gdbarch, i386_process_record);
480
77fcef51 481 /* Initialize the i386_linux_record_tdep. */
5e31abdf
HZ
482 /* These values are the size of the type that will be used in a system
483 call. They are obtained from Linux Kernel source. */
484 i386_linux_record_tdep.size__old_kernel_stat = 32;
485 i386_linux_record_tdep.size_tms = 16;
486 i386_linux_record_tdep.size_loff_t = 8;
487 i386_linux_record_tdep.size_flock = 16;
488 i386_linux_record_tdep.size_oldold_utsname = 45;
489 i386_linux_record_tdep.size_ustat = 20;
490 i386_linux_record_tdep.size_old_sigaction = 140;
491 i386_linux_record_tdep.size_old_sigset_t = 128;
492 i386_linux_record_tdep.size_rlimit = 8;
493 i386_linux_record_tdep.size_rusage = 72;
494 i386_linux_record_tdep.size_timeval = 8;
495 i386_linux_record_tdep.size_timezone = 8;
496 i386_linux_record_tdep.size_old_gid_t = 2;
497 i386_linux_record_tdep.size_old_uid_t = 2;
498 i386_linux_record_tdep.size_fd_set = 128;
499 i386_linux_record_tdep.size_dirent = 268;
500 i386_linux_record_tdep.size_dirent64 = 276;
501 i386_linux_record_tdep.size_statfs = 64;
502 i386_linux_record_tdep.size_statfs64 = 84;
503 i386_linux_record_tdep.size_sockaddr = 16;
504 i386_linux_record_tdep.size_int = 4;
505 i386_linux_record_tdep.size_long = 4;
506 i386_linux_record_tdep.size_ulong = 4;
507 i386_linux_record_tdep.size_msghdr = 28;
508 i386_linux_record_tdep.size_itimerval = 16;
509 i386_linux_record_tdep.size_stat = 88;
510 i386_linux_record_tdep.size_old_utsname = 325;
511 i386_linux_record_tdep.size_sysinfo = 64;
512 i386_linux_record_tdep.size_msqid_ds = 88;
513 i386_linux_record_tdep.size_shmid_ds = 84;
514 i386_linux_record_tdep.size_new_utsname = 390;
515 i386_linux_record_tdep.size_timex = 128;
516 i386_linux_record_tdep.size_mem_dqinfo = 24;
517 i386_linux_record_tdep.size_if_dqblk = 68;
518 i386_linux_record_tdep.size_fs_quota_stat = 68;
519 i386_linux_record_tdep.size_timespec = 8;
520 i386_linux_record_tdep.size_pollfd = 8;
521 i386_linux_record_tdep.size_NFS_FHSIZE = 32;
522 i386_linux_record_tdep.size_knfsd_fh = 132;
523 i386_linux_record_tdep.size_TASK_COMM_LEN = 16;
524 i386_linux_record_tdep.size_sigaction = 140;
525 i386_linux_record_tdep.size_sigset_t = 8;
526 i386_linux_record_tdep.size_siginfo_t = 128;
527 i386_linux_record_tdep.size_cap_user_data_t = 12;
528 i386_linux_record_tdep.size_stack_t = 12;
529 i386_linux_record_tdep.size_off_t = i386_linux_record_tdep.size_long;
530 i386_linux_record_tdep.size_stat64 = 96;
531 i386_linux_record_tdep.size_gid_t = 2;
532 i386_linux_record_tdep.size_uid_t = 2;
533 i386_linux_record_tdep.size_PAGE_SIZE = 4096;
534 i386_linux_record_tdep.size_flock64 = 24;
535 i386_linux_record_tdep.size_user_desc = 16;
536 i386_linux_record_tdep.size_io_event = 32;
537 i386_linux_record_tdep.size_iocb = 64;
538 i386_linux_record_tdep.size_epoll_event = 12;
539 i386_linux_record_tdep.size_itimerspec = i386_linux_record_tdep.size_timespec * 2;
540 i386_linux_record_tdep.size_mq_attr = 32;
541 i386_linux_record_tdep.size_siginfo = 128;
542 i386_linux_record_tdep.size_termios = 36;
543 i386_linux_record_tdep.size_termios2 = 44;
544 i386_linux_record_tdep.size_pid_t = 4;
545 i386_linux_record_tdep.size_winsize = 8;
546 i386_linux_record_tdep.size_serial_struct = 60;
547 i386_linux_record_tdep.size_serial_icounter_struct = 80;
548 i386_linux_record_tdep.size_hayes_esp_config = 12;
549
550 /* These values are the second argument of system call "sys_ioctl".
551 They are obtained from Linux Kernel source. */
552 i386_linux_record_tdep.ioctl_TCGETS = 0x5401;
553 i386_linux_record_tdep.ioctl_TCSETS = 0x5402;
554 i386_linux_record_tdep.ioctl_TCSETSW = 0x5403;
555 i386_linux_record_tdep.ioctl_TCSETSF = 0x5404;
556 i386_linux_record_tdep.ioctl_TCGETA = 0x5405;
557 i386_linux_record_tdep.ioctl_TCSETA = 0x5406;
558 i386_linux_record_tdep.ioctl_TCSETAW = 0x5407;
559 i386_linux_record_tdep.ioctl_TCSETAF = 0x5408;
560 i386_linux_record_tdep.ioctl_TCSBRK = 0x5409;
561 i386_linux_record_tdep.ioctl_TCXONC = 0x540A;
562 i386_linux_record_tdep.ioctl_TCFLSH = 0x540B;
563 i386_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
564 i386_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
565 i386_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
566 i386_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
567 i386_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
568 i386_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
569 i386_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
570 i386_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
571 i386_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
572 i386_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
573 i386_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
574 i386_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
575 i386_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
576 i386_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
577 i386_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
578 i386_linux_record_tdep.ioctl_FIONREAD = 0x541B;
579 i386_linux_record_tdep.ioctl_TIOCINQ = i386_linux_record_tdep.ioctl_FIONREAD;
580 i386_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
581 i386_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
582 i386_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
583 i386_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
584 i386_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
585 i386_linux_record_tdep.ioctl_FIONBIO = 0x5421;
586 i386_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
587 i386_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
588 i386_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
589 i386_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
590 i386_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
591 i386_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
592 i386_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
593 i386_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
594 i386_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
595 i386_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
596 i386_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
597 i386_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
598 i386_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
599 i386_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
600 i386_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
601 i386_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
602 i386_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
603 i386_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
604 i386_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
605 i386_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
606 i386_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
607 i386_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
608 i386_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
609 i386_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
610 i386_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
611 i386_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
612 i386_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
613 i386_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
614 i386_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
615 i386_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
616 i386_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
617
618 /* These values are the second argument of system call "sys_fcntl"
619 and "sys_fcntl64". They are obtained from Linux Kernel source. */
620 i386_linux_record_tdep.fcntl_F_GETLK = 5;
621 i386_linux_record_tdep.fcntl_F_GETLK64 = 12;
622 i386_linux_record_tdep.fcntl_F_SETLK64 = 13;
623 i386_linux_record_tdep.fcntl_F_SETLKW64 = 14;
50ef67b3 624
77fcef51
HZ
625 i386_linux_record_tdep.arg1 = I386_EBX_REGNUM;
626 i386_linux_record_tdep.arg2 = I386_ECX_REGNUM;
627 i386_linux_record_tdep.arg3 = I386_EDX_REGNUM;
628 i386_linux_record_tdep.arg4 = I386_ESI_REGNUM;
629 i386_linux_record_tdep.arg5 = I386_EDI_REGNUM;
630
631 tdep->i386_intx80_record = i386_linux_intx80_sysenter_record;
632 tdep->i386_sysenter_record = i386_linux_intx80_sysenter_record;
633
203c3895
UW
634 /* N_FUN symbols in shared libaries have 0 for their values and need
635 to be relocated. */
636 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
637
871fbe6a 638 /* GNU/Linux uses SVR4-style shared libraries. */
982e9687 639 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
871fbe6a
MK
640 set_solib_svr4_fetch_link_map_offsets
641 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
642
643 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
bb41a796 644 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
12b8a2cb
DJ
645
646 dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
b2756930
KB
647
648 /* Enable TLS support. */
649 set_gdbarch_fetch_tls_load_module_address (gdbarch,
650 svr4_fetch_objfile_link_map);
237fc4c9 651
17ea7499
CES
652 /* Install supported register note sections. */
653 set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections);
654
237fc4c9
PA
655 /* Displaced stepping. */
656 set_gdbarch_displaced_step_copy_insn (gdbarch,
657 simple_displaced_step_copy_insn);
658 set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup);
659 set_gdbarch_displaced_step_free_closure (gdbarch,
660 simple_displaced_step_free_closure);
661 set_gdbarch_displaced_step_location (gdbarch,
662 displaced_step_at_entry_point);
4aa995e1
PA
663
664 set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
8201327c
MK
665}
666
667/* Provide a prototype to silence -Wmissing-prototypes. */
668extern void _initialize_i386_linux_tdep (void);
669
670void
671_initialize_i386_linux_tdep (void)
672{
05816f70 673 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
8201327c
MK
674 i386_linux_init_abi);
675}
This page took 0.952241 seconds and 4 git commands to generate.