gdb: Add guess_tracepoint_registers hook to gdbarch.
[deliverable/binutils-gdb.git] / gdb / i386-linux-tdep.c
CommitLineData
871fbe6a 1/* Target-dependent code for GNU/Linux i386.
ca557f44 2
618f726f 3 Copyright (C) 2000-2016 Free Software Foundation, Inc.
e7ee86a9
JB
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
e7ee86a9
JB
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
e7ee86a9
JB
19
20#include "defs.h"
21#include "gdbcore.h"
22#include "frame.h"
23#include "value.h"
4e052eda 24#include "regcache.h"
c131fcee 25#include "regset.h"
6441c4a0 26#include "inferior.h"
0670c0aa 27#include "osabi.h"
38c968cf 28#include "reggroups.h"
5cb2fe25 29#include "dwarf2-frame.h"
8201327c
MK
30#include "i386-tdep.h"
31#include "i386-linux-tdep.h"
4aa995e1 32#include "linux-tdep.h"
0670c0aa 33#include "glibc-tdep.h"
871fbe6a 34#include "solib-svr4.h"
982e9687 35#include "symtab.h"
237fc4c9 36#include "arch-utils.h"
a96d9b2e
SDJ
37#include "xml-syscall.h"
38
c131fcee 39#include "i387-tdep.h"
df7e5265 40#include "x86-xstate.h"
c131fcee 41
a96d9b2e
SDJ
42/* The syscall's XML filename for i386. */
43#define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml"
17ea7499 44
d02ed0bb 45#include "record-full.h"
77fcef51 46#include "linux-record.h"
90884b2b 47#include "features/i386/i386-linux.c"
3a13a53b 48#include "features/i386/i386-mmx-linux.c"
1dbcd68c 49#include "features/i386/i386-mpx-linux.c"
c131fcee 50#include "features/i386/i386-avx-linux.c"
01f9f808 51#include "features/i386/i386-avx512-linux.c"
90884b2b 52
38c968cf
AC
53/* Return non-zero, when the register is in the corresponding register
54 group. Put the LINUX_ORIG_EAX register in the system group. */
55static int
56i386_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
57 struct reggroup *group)
58{
59 if (regnum == I386_LINUX_ORIG_EAX_REGNUM)
60 return (group == system_reggroup
61 || group == save_reggroup
62 || group == restore_reggroup);
63 return i386_register_reggroup_p (gdbarch, regnum, group);
64}
65
e7ee86a9
JB
66\f
67/* Recognizing signal handler frames. */
68
ca557f44 69/* GNU/Linux has two flavors of signals. Normal signal handlers, and
e7ee86a9
JB
70 "realtime" (RT) signals. The RT signals can provide additional
71 information to the signal handler if the SA_SIGINFO flag is set
72 when establishing a signal handler using `sigaction'. It is not
ca557f44
AC
73 unlikely that future versions of GNU/Linux will support SA_SIGINFO
74 for normal signals too. */
e7ee86a9
JB
75
76/* When the i386 Linux kernel calls a signal handler and the
77 SA_RESTORER flag isn't set, the return address points to a bit of
78 code on the stack. This function returns whether the PC appears to
79 be within this bit of code.
80
81 The instruction sequence for normal signals is
82 pop %eax
acd5c798 83 mov $0x77, %eax
e7ee86a9
JB
84 int $0x80
85 or 0x58 0xb8 0x77 0x00 0x00 0x00 0xcd 0x80.
86
87 Checking for the code sequence should be somewhat reliable, because
88 the effect is to call the system call sigreturn. This is unlikely
911bc6ee 89 to occur anywhere other than in a signal trampoline.
e7ee86a9
JB
90
91 It kind of sucks that we have to read memory from the process in
92 order to identify a signal trampoline, but there doesn't seem to be
911bc6ee
MK
93 any other way. Therefore we only do the memory reads if no
94 function name could be identified, which should be the case since
95 the code is on the stack.
e7ee86a9
JB
96
97 Detection of signal trampolines for handlers that set the
98 SA_RESTORER flag is in general not possible. Unfortunately this is
99 what the GNU C Library has been doing for quite some time now.
100 However, as of version 2.1.2, the GNU C Library uses signal
101 trampolines (named __restore and __restore_rt) that are identical
102 to the ones used by the kernel. Therefore, these trampolines are
103 supported too. */
104
acd5c798
MK
105#define LINUX_SIGTRAMP_INSN0 0x58 /* pop %eax */
106#define LINUX_SIGTRAMP_OFFSET0 0
107#define LINUX_SIGTRAMP_INSN1 0xb8 /* mov $NNNN, %eax */
108#define LINUX_SIGTRAMP_OFFSET1 1
109#define LINUX_SIGTRAMP_INSN2 0xcd /* int */
110#define LINUX_SIGTRAMP_OFFSET2 6
e7ee86a9 111
4252dc94 112static const gdb_byte linux_sigtramp_code[] =
e7ee86a9
JB
113{
114 LINUX_SIGTRAMP_INSN0, /* pop %eax */
acd5c798 115 LINUX_SIGTRAMP_INSN1, 0x77, 0x00, 0x00, 0x00, /* mov $0x77, %eax */
e7ee86a9
JB
116 LINUX_SIGTRAMP_INSN2, 0x80 /* int $0x80 */
117};
118
119#define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
120
10458914
DJ
121/* If THIS_FRAME is a sigtramp routine, return the address of the
122 start of the routine. Otherwise, return 0. */
e7ee86a9
JB
123
124static CORE_ADDR
10458914 125i386_linux_sigtramp_start (struct frame_info *this_frame)
e7ee86a9 126{
10458914 127 CORE_ADDR pc = get_frame_pc (this_frame);
4252dc94 128 gdb_byte buf[LINUX_SIGTRAMP_LEN];
e7ee86a9
JB
129
130 /* We only recognize a signal trampoline if PC is at the start of
131 one of the three instructions. We optimize for finding the PC at
132 the start, as will be the case when the trampoline is not the
133 first frame on the stack. We assume that in the case where the
134 PC is not at the start of the instruction sequence, there will be
135 a few trailing readable bytes on the stack. */
136
10458914 137 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
e7ee86a9
JB
138 return 0;
139
140 if (buf[0] != LINUX_SIGTRAMP_INSN0)
141 {
142 int adjust;
143
144 switch (buf[0])
145 {
146 case LINUX_SIGTRAMP_INSN1:
147 adjust = LINUX_SIGTRAMP_OFFSET1;
148 break;
149 case LINUX_SIGTRAMP_INSN2:
150 adjust = LINUX_SIGTRAMP_OFFSET2;
151 break;
152 default:
153 return 0;
154 }
155
156 pc -= adjust;
157
10458914 158 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
e7ee86a9
JB
159 return 0;
160 }
161
162 if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
163 return 0;
164
165 return pc;
166}
167
168/* This function does the same for RT signals. Here the instruction
169 sequence is
acd5c798 170 mov $0xad, %eax
e7ee86a9
JB
171 int $0x80
172 or 0xb8 0xad 0x00 0x00 0x00 0xcd 0x80.
173
174 The effect is to call the system call rt_sigreturn. */
175
acd5c798
MK
176#define LINUX_RT_SIGTRAMP_INSN0 0xb8 /* mov $NNNN, %eax */
177#define LINUX_RT_SIGTRAMP_OFFSET0 0
178#define LINUX_RT_SIGTRAMP_INSN1 0xcd /* int */
179#define LINUX_RT_SIGTRAMP_OFFSET1 5
e7ee86a9 180
4252dc94 181static const gdb_byte linux_rt_sigtramp_code[] =
e7ee86a9 182{
acd5c798 183 LINUX_RT_SIGTRAMP_INSN0, 0xad, 0x00, 0x00, 0x00, /* mov $0xad, %eax */
e7ee86a9
JB
184 LINUX_RT_SIGTRAMP_INSN1, 0x80 /* int $0x80 */
185};
186
187#define LINUX_RT_SIGTRAMP_LEN (sizeof linux_rt_sigtramp_code)
188
10458914
DJ
189/* If THIS_FRAME is an RT sigtramp routine, return the address of the
190 start of the routine. Otherwise, return 0. */
e7ee86a9
JB
191
192static CORE_ADDR
10458914 193i386_linux_rt_sigtramp_start (struct frame_info *this_frame)
e7ee86a9 194{
10458914 195 CORE_ADDR pc = get_frame_pc (this_frame);
4252dc94 196 gdb_byte buf[LINUX_RT_SIGTRAMP_LEN];
e7ee86a9
JB
197
198 /* We only recognize a signal trampoline if PC is at the start of
199 one of the two instructions. We optimize for finding the PC at
200 the start, as will be the case when the trampoline is not the
201 first frame on the stack. We assume that in the case where the
202 PC is not at the start of the instruction sequence, there will be
203 a few trailing readable bytes on the stack. */
204
10458914 205 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN))
e7ee86a9
JB
206 return 0;
207
208 if (buf[0] != LINUX_RT_SIGTRAMP_INSN0)
209 {
210 if (buf[0] != LINUX_RT_SIGTRAMP_INSN1)
211 return 0;
212
213 pc -= LINUX_RT_SIGTRAMP_OFFSET1;
214
10458914 215 if (!safe_frame_unwind_memory (this_frame, pc, buf,
8e6bed05 216 LINUX_RT_SIGTRAMP_LEN))
e7ee86a9
JB
217 return 0;
218 }
219
220 if (memcmp (buf, linux_rt_sigtramp_code, LINUX_RT_SIGTRAMP_LEN) != 0)
221 return 0;
222
223 return pc;
224}
225
10458914
DJ
226/* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp
227 routine. */
e7ee86a9 228
8201327c 229static int
10458914 230i386_linux_sigtramp_p (struct frame_info *this_frame)
e7ee86a9 231{
10458914 232 CORE_ADDR pc = get_frame_pc (this_frame);
2c02bd72 233 const char *name;
911bc6ee
MK
234
235 find_pc_partial_function (pc, &name, NULL, NULL);
236
ef17e74b
DJ
237 /* If we have NAME, we can optimize the search. The trampolines are
238 named __restore and __restore_rt. However, they aren't dynamically
239 exported from the shared C library, so the trampoline may appear to
240 be part of the preceding function. This should always be sigaction,
241 __sigaction, or __libc_sigaction (all aliases to the same function). */
242 if (name == NULL || strstr (name, "sigaction") != NULL)
10458914
DJ
243 return (i386_linux_sigtramp_start (this_frame) != 0
244 || i386_linux_rt_sigtramp_start (this_frame) != 0);
ef17e74b
DJ
245
246 return (strcmp ("__restore", name) == 0
247 || strcmp ("__restore_rt", name) == 0);
e7ee86a9
JB
248}
249
4a4e5149
DJ
250/* Return one if the PC of THIS_FRAME is in a signal trampoline which
251 may have DWARF-2 CFI. */
12b8a2cb
DJ
252
253static int
254i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
4a4e5149 255 struct frame_info *this_frame)
12b8a2cb 256{
4a4e5149 257 CORE_ADDR pc = get_frame_pc (this_frame);
2c02bd72 258 const char *name;
12b8a2cb
DJ
259
260 find_pc_partial_function (pc, &name, NULL, NULL);
261
262 /* If a vsyscall DSO is in use, the signal trampolines may have these
263 names. */
264 if (name && (strcmp (name, "__kernel_sigreturn") == 0
265 || strcmp (name, "__kernel_rt_sigreturn") == 0))
266 return 1;
267
268 return 0;
269}
270
acd5c798
MK
271/* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
272#define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
273
10458914
DJ
274/* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the
275 address of the associated sigcontext structure. */
e7ee86a9 276
b7d15bf7 277static CORE_ADDR
10458914 278i386_linux_sigcontext_addr (struct frame_info *this_frame)
e7ee86a9 279{
e17a4113
UW
280 struct gdbarch *gdbarch = get_frame_arch (this_frame);
281 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
e7ee86a9 282 CORE_ADDR pc;
acd5c798 283 CORE_ADDR sp;
4252dc94 284 gdb_byte buf[4];
acd5c798 285
10458914 286 get_frame_register (this_frame, I386_ESP_REGNUM, buf);
e17a4113 287 sp = extract_unsigned_integer (buf, 4, byte_order);
e7ee86a9 288
10458914 289 pc = i386_linux_sigtramp_start (this_frame);
e7ee86a9
JB
290 if (pc)
291 {
acd5c798
MK
292 /* The sigcontext structure lives on the stack, right after
293 the signum argument. We determine the address of the
294 sigcontext structure by looking at the frame's stack
295 pointer. Keep in mind that the first instruction of the
296 sigtramp code is "pop %eax". If the PC is after this
297 instruction, adjust the returned value accordingly. */
10458914 298 if (pc == get_frame_pc (this_frame))
e7ee86a9
JB
299 return sp + 4;
300 return sp;
301 }
302
10458914 303 pc = i386_linux_rt_sigtramp_start (this_frame);
e7ee86a9
JB
304 if (pc)
305 {
acd5c798
MK
306 CORE_ADDR ucontext_addr;
307
308 /* The sigcontext structure is part of the user context. A
309 pointer to the user context is passed as the third argument
310 to the signal handler. */
311 read_memory (sp + 8, buf, 4);
e17a4113 312 ucontext_addr = extract_unsigned_integer (buf, 4, byte_order);
acd5c798 313 return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
e7ee86a9
JB
314 }
315
8a3fe4f8 316 error (_("Couldn't recognize signal trampoline."));
e7ee86a9
JB
317 return 0;
318}
319
6441c4a0
MK
320/* Set the program counter for process PTID to PC. */
321
8201327c 322static void
61a1198a 323i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
6441c4a0 324{
61a1198a 325 regcache_cooked_write_unsigned (regcache, I386_EIP_REGNUM, pc);
6441c4a0
MK
326
327 /* We must be careful with modifying the program counter. If we
328 just interrupted a system call, the kernel might try to restart
329 it when we resume the inferior. On restarting the system call,
330 the kernel will try backing up the program counter even though it
331 no longer points at the system call. This typically results in a
332 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the
333 "orig_eax" pseudo-register.
334
335 Note that "orig_eax" is saved when setting up a dummy call frame.
336 This means that it is properly restored when that frame is
337 popped, and that the interrupted system call will be restarted
338 when we resume the inferior on return from a function call from
339 within GDB. In all other cases the system call will not be
340 restarted. */
61a1198a 341 regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1);
6441c4a0 342}
77fcef51 343
8a2e0e28
HZ
344/* Record all registers but IP register for process-record. */
345
346static int
347i386_all_but_ip_registers_record (struct regcache *regcache)
348{
25ea693b 349 if (record_full_arch_list_add_reg (regcache, I386_EAX_REGNUM))
8a2e0e28 350 return -1;
25ea693b 351 if (record_full_arch_list_add_reg (regcache, I386_ECX_REGNUM))
8a2e0e28 352 return -1;
25ea693b 353 if (record_full_arch_list_add_reg (regcache, I386_EDX_REGNUM))
8a2e0e28 354 return -1;
25ea693b 355 if (record_full_arch_list_add_reg (regcache, I386_EBX_REGNUM))
8a2e0e28 356 return -1;
25ea693b 357 if (record_full_arch_list_add_reg (regcache, I386_ESP_REGNUM))
8a2e0e28 358 return -1;
25ea693b 359 if (record_full_arch_list_add_reg (regcache, I386_EBP_REGNUM))
8a2e0e28 360 return -1;
25ea693b 361 if (record_full_arch_list_add_reg (regcache, I386_ESI_REGNUM))
8a2e0e28 362 return -1;
25ea693b 363 if (record_full_arch_list_add_reg (regcache, I386_EDI_REGNUM))
8a2e0e28 364 return -1;
25ea693b 365 if (record_full_arch_list_add_reg (regcache, I386_EFLAGS_REGNUM))
8a2e0e28
HZ
366 return -1;
367
368 return 0;
369}
13b6d1d4
MS
370
371/* i386_canonicalize_syscall maps from the native i386 Linux set
372 of syscall ids into a canonical set of syscall ids used by
373 process record (a mostly trivial mapping, since the canonical
374 set was originally taken from the i386 set). */
375
376static enum gdb_syscall
377i386_canonicalize_syscall (int syscall)
378{
379 enum { i386_syscall_max = 499 };
380
381 if (syscall <= i386_syscall_max)
aead7601 382 return (enum gdb_syscall) syscall;
13b6d1d4 383 else
f486487f 384 return gdb_sys_no_syscall;
13b6d1d4
MS
385}
386
77fcef51
HZ
387/* Parse the arguments of current system call instruction and record
388 the values of the registers and memory that will be changed into
389 "record_arch_list". This instruction is "int 0x80" (Linux
390 Kernel2.4) or "sysenter" (Linux Kernel 2.6).
391
392 Return -1 if something wrong. */
393
8a2e0e28
HZ
394static struct linux_record_tdep i386_linux_record_tdep;
395
77fcef51 396static int
ffdf6de5 397i386_linux_intx80_sysenter_syscall_record (struct regcache *regcache)
77fcef51
HZ
398{
399 int ret;
13b6d1d4
MS
400 LONGEST syscall_native;
401 enum gdb_syscall syscall_gdb;
402
403 regcache_raw_read_signed (regcache, I386_EAX_REGNUM, &syscall_native);
77fcef51 404
13b6d1d4 405 syscall_gdb = i386_canonicalize_syscall (syscall_native);
2c543fc4 406
13b6d1d4 407 if (syscall_gdb < 0)
2c543fc4
HZ
408 {
409 printf_unfiltered (_("Process record and replay target doesn't "
13b6d1d4
MS
410 "support syscall number %s\n"),
411 plongest (syscall_native));
2c543fc4
HZ
412 return -1;
413 }
77fcef51 414
8a2e0e28
HZ
415 if (syscall_gdb == gdb_sys_sigreturn
416 || syscall_gdb == gdb_sys_rt_sigreturn)
417 {
418 if (i386_all_but_ip_registers_record (regcache))
419 return -1;
420 return 0;
421 }
422
13b6d1d4 423 ret = record_linux_system_call (syscall_gdb, regcache,
77fcef51
HZ
424 &i386_linux_record_tdep);
425 if (ret)
426 return ret;
427
428 /* Record the return value of the system call. */
25ea693b 429 if (record_full_arch_list_add_reg (regcache, I386_EAX_REGNUM))
77fcef51
HZ
430 return -1;
431
432 return 0;
433}
8a2e0e28
HZ
434
435#define I386_LINUX_xstate 270
436#define I386_LINUX_frame_size 732
437
70221824 438static int
8a2e0e28
HZ
439i386_linux_record_signal (struct gdbarch *gdbarch,
440 struct regcache *regcache,
2ea28649 441 enum gdb_signal signal)
8a2e0e28
HZ
442{
443 ULONGEST esp;
444
445 if (i386_all_but_ip_registers_record (regcache))
446 return -1;
447
25ea693b 448 if (record_full_arch_list_add_reg (regcache, I386_EIP_REGNUM))
8a2e0e28
HZ
449 return -1;
450
451 /* Record the change in the stack. */
452 regcache_raw_read_unsigned (regcache, I386_ESP_REGNUM, &esp);
453 /* This is for xstate.
454 sp -= sizeof (struct _fpstate); */
455 esp -= I386_LINUX_xstate;
456 /* This is for frame_size.
457 sp -= sizeof (struct rt_sigframe); */
458 esp -= I386_LINUX_frame_size;
25ea693b
MM
459 if (record_full_arch_list_add_mem (esp,
460 I386_LINUX_xstate + I386_LINUX_frame_size))
8a2e0e28
HZ
461 return -1;
462
25ea693b 463 if (record_full_arch_list_add_end ())
8a2e0e28
HZ
464 return -1;
465
466 return 0;
467}
6441c4a0 468\f
8201327c 469
9a7f938f
JK
470/* Core of the implementation for gdbarch get_syscall_number. Get pending
471 syscall number from REGCACHE. If there is no pending syscall -1 will be
472 returned. Pending syscall means ptrace has stepped into the syscall but
473 another ptrace call will step out. PC is right after the int $0x80
474 / syscall / sysenter instruction in both cases, PC does not change during
475 the second ptrace step. */
476
a96d9b2e 477static LONGEST
9a7f938f 478i386_linux_get_syscall_number_from_regcache (struct regcache *regcache)
a96d9b2e 479{
9a7f938f 480 struct gdbarch *gdbarch = get_regcache_arch (regcache);
a96d9b2e
SDJ
481 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
482 /* The content of a register. */
483 gdb_byte buf[4];
484 /* The result. */
485 LONGEST ret;
486
487 /* Getting the system call number from the register.
488 When dealing with x86 architecture, this information
489 is stored at %eax register. */
490 regcache_cooked_read (regcache, I386_LINUX_ORIG_EAX_REGNUM, buf);
491
492 ret = extract_signed_integer (buf, 4, byte_order);
493
494 return ret;
495}
496
9a7f938f
JK
497/* Wrapper for i386_linux_get_syscall_number_from_regcache to make it
498 compatible with gdbarch get_syscall_number method prototype. */
499
500static LONGEST
501i386_linux_get_syscall_number (struct gdbarch *gdbarch,
502 ptid_t ptid)
503{
504 struct regcache *regcache = get_thread_regcache (ptid);
505
506 return i386_linux_get_syscall_number_from_regcache (regcache);
507}
508
e9f1aad5
MK
509/* The register sets used in GNU/Linux ELF core-dumps are identical to
510 the register sets in `struct user' that are used for a.out
511 core-dumps. These are also used by ptrace(2). The corresponding
512 types are `elf_gregset_t' for the general-purpose registers (with
513 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
514 for the floating-point registers.
515
516 Those types used to be available under the names `gregset_t' and
517 `fpregset_t' too, and GDB used those names in the past. But those
518 names are now used for the register sets used in the `mcontext_t'
519 type, which have a different size and layout. */
520
521/* Mapping between the general-purpose registers in `struct user'
522 format and GDB's register cache layout. */
523
524/* From <sys/reg.h>. */
be0d2954 525int i386_linux_gregset_reg_offset[] =
e9f1aad5
MK
526{
527 6 * 4, /* %eax */
528 1 * 4, /* %ecx */
529 2 * 4, /* %edx */
530 0 * 4, /* %ebx */
531 15 * 4, /* %esp */
532 5 * 4, /* %ebp */
533 3 * 4, /* %esi */
534 4 * 4, /* %edi */
535 12 * 4, /* %eip */
536 14 * 4, /* %eflags */
537 13 * 4, /* %cs */
538 16 * 4, /* %ss */
539 7 * 4, /* %ds */
540 8 * 4, /* %es */
541 9 * 4, /* %fs */
542 10 * 4, /* %gs */
543 -1, -1, -1, -1, -1, -1, -1, -1,
544 -1, -1, -1, -1, -1, -1, -1, -1,
545 -1, -1, -1, -1, -1, -1, -1, -1,
546 -1,
c131fcee 547 -1, -1, -1, -1, -1, -1, -1, -1,
01f9f808
MS
548 -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
549 -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
550 -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
551 -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
552 11 * 4, /* "orig_eax" */
e9f1aad5
MK
553};
554
555/* Mapping between the general-purpose registers in `struct
556 sigcontext' format and GDB's register cache layout. */
557
a3386186 558/* From <asm/sigcontext.h>. */
bb489b3c 559static int i386_linux_sc_reg_offset[] =
a3386186
MK
560{
561 11 * 4, /* %eax */
562 10 * 4, /* %ecx */
563 9 * 4, /* %edx */
564 8 * 4, /* %ebx */
565 7 * 4, /* %esp */
566 6 * 4, /* %ebp */
567 5 * 4, /* %esi */
568 4 * 4, /* %edi */
569 14 * 4, /* %eip */
570 16 * 4, /* %eflags */
571 15 * 4, /* %cs */
572 18 * 4, /* %ss */
573 3 * 4, /* %ds */
574 2 * 4, /* %es */
575 1 * 4, /* %fs */
576 0 * 4 /* %gs */
577};
578
c131fcee
L
579/* Get XSAVE extended state xcr0 from core dump. */
580
581uint64_t
6df81a63 582i386_linux_core_read_xcr0 (bfd *abfd)
c131fcee
L
583{
584 asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate");
585 uint64_t xcr0;
586
587 if (xstate)
588 {
589 size_t size = bfd_section_size (abfd, xstate);
590
591 /* Check extended state size. */
df7e5265
GB
592 if (size < X86_XSTATE_AVX_SIZE)
593 xcr0 = X86_XSTATE_SSE_MASK;
c131fcee
L
594 else
595 {
596 char contents[8];
597
598 if (! bfd_get_section_contents (abfd, xstate, contents,
599 I386_LINUX_XSAVE_XCR0_OFFSET,
600 8))
601 {
1777feb0
MS
602 warning (_("Couldn't read `xcr0' bytes from "
603 "`.reg-xstate' section in core file."));
c131fcee
L
604 return 0;
605 }
606
607 xcr0 = bfd_get_64 (abfd, contents);
608 }
609 }
610 else
f335d1b3 611 xcr0 = 0;
c131fcee
L
612
613 return xcr0;
614}
615
90884b2b
L
616/* Get Linux/x86 target description from core dump. */
617
618static const struct target_desc *
619i386_linux_core_read_description (struct gdbarch *gdbarch,
620 struct target_ops *target,
621 bfd *abfd)
622{
90884b2b 623 /* Linux/i386. */
6df81a63 624 uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
1dbcd68c 625
df7e5265 626 switch ((xcr0 & X86_XSTATE_ALL_MASK))
f335d1b3 627 {
df7e5265
GB
628 case X86_XSTATE_MPX_AVX512_MASK:
629 case X86_XSTATE_AVX512_MASK:
01f9f808 630 return tdesc_i386_avx512_linux;
df7e5265 631 case X86_XSTATE_MPX_MASK:
1dbcd68c 632 return tdesc_i386_mpx_linux;
df7e5265 633 case X86_XSTATE_AVX_MASK:
f335d1b3 634 return tdesc_i386_avx_linux;
df7e5265 635 case X86_XSTATE_SSE_MASK:
f335d1b3 636 return tdesc_i386_linux;
df7e5265 637 case X86_XSTATE_X87_MASK:
f335d1b3
L
638 return tdesc_i386_mmx_linux;
639 default:
640 break;
641 }
642
643 if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
c131fcee 644 return tdesc_i386_linux;
f335d1b3
L
645 else
646 return tdesc_i386_mmx_linux;
90884b2b
L
647}
648
8f0435f7
AA
649/* Similar to i386_supply_fpregset, but use XSAVE extended state. */
650
651static void
652i386_linux_supply_xstateregset (const struct regset *regset,
653 struct regcache *regcache, int regnum,
654 const void *xstateregs, size_t len)
655{
656 i387_supply_xsave (regcache, regnum, xstateregs);
657}
658
190b495d
WT
659struct type *
660x86_linux_get_siginfo_type (struct gdbarch *gdbarch)
661{
662 return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND);
663}
664
8f0435f7
AA
665/* Similar to i386_collect_fpregset, but use XSAVE extended state. */
666
667static void
668i386_linux_collect_xstateregset (const struct regset *regset,
669 const struct regcache *regcache,
670 int regnum, void *xstateregs, size_t len)
671{
672 i387_collect_xsave (regcache, regnum, xstateregs, 1);
673}
674
675/* Register set definitions. */
676
677static const struct regset i386_linux_xstateregset =
678 {
679 NULL,
680 i386_linux_supply_xstateregset,
681 i386_linux_collect_xstateregset
682 };
683
5aa82d05
AA
684/* Iterate over core file register note sections. */
685
686static void
687i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
688 iterate_over_regset_sections_cb *cb,
689 void *cb_data,
690 const struct regcache *regcache)
691{
692 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
693
8f0435f7 694 cb (".reg", 68, &i386_gregset, NULL, cb_data);
5aa82d05
AA
695
696 if (tdep->xcr0 & X86_XSTATE_AVX)
dde9acd6 697 cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0),
8f0435f7 698 &i386_linux_xstateregset, "XSAVE extended state", cb_data);
5aa82d05 699 else if (tdep->xcr0 & X86_XSTATE_SSE)
8f0435f7
AA
700 cb (".reg-xfp", 512, &i386_fpregset, "extended floating-point",
701 cb_data);
5aa82d05 702 else
8f0435f7 703 cb (".reg2", 108, &i386_fpregset, NULL, cb_data);
5aa82d05
AA
704}
705
9a7f938f
JK
706/* Linux kernel shows PC value after the 'int $0x80' instruction even if
707 inferior is still inside the syscall. On next PTRACE_SINGLESTEP it will
708 finish the syscall but PC will not change.
709
710 Some vDSOs contain 'int $0x80; ret' and during stepping out of the syscall
711 i386_displaced_step_fixup would keep PC at the displaced pad location.
712 As PC is pointing to the 'ret' instruction before the step
713 i386_displaced_step_fixup would expect inferior has just executed that 'ret'
714 and PC should not be adjusted. In reality it finished syscall instead and
715 PC should get relocated back to its vDSO address. Hide the 'ret'
716 instruction by 'nop' so that i386_displaced_step_fixup is not confused.
717
718 It is not fully correct as the bytes in struct displaced_step_closure will
719 not match the inferior code. But we would need some new flag in
720 displaced_step_closure otherwise to keep the state that syscall is finishing
721 for the later i386_displaced_step_fixup execution as the syscall execution
722 is already no longer detectable there. The new flag field would mean
723 i386-linux-tdep.c needs to wrap all the displacement methods of i386-tdep.c
724 which does not seem worth it. The same effect is achieved by patching that
725 'nop' instruction there instead. */
726
693be288 727static struct displaced_step_closure *
9a7f938f
JK
728i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
729 CORE_ADDR from, CORE_ADDR to,
730 struct regcache *regs)
731{
732 struct displaced_step_closure *closure;
733
734 closure = i386_displaced_step_copy_insn (gdbarch, from, to, regs);
735
736 if (i386_linux_get_syscall_number_from_regcache (regs) != -1)
737 {
738 /* Since we use simple_displaced_step_copy_insn, our closure is a
739 copy of the instruction. */
740 gdb_byte *insn = (gdb_byte *) closure;
741
742 /* Fake nop. */
743 insn[0] = 0x90;
744 }
745
746 return closure;
747}
748
8201327c
MK
749static void
750i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
751{
752 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
90884b2b 753 const struct target_desc *tdesc = info.target_desc;
9a3c8263
SM
754 struct tdesc_arch_data *tdesc_data
755 = (struct tdesc_arch_data *) info.tdep_info;
90884b2b
L
756 const struct tdesc_feature *feature;
757 int valid_p;
758
759 gdb_assert (tdesc_data);
8201327c 760
a5ee0f0c
PA
761 linux_init_abi (info, gdbarch);
762
8201327c
MK
763 /* GNU/Linux uses ELF. */
764 i386_elf_init_abi (info, gdbarch);
765
90884b2b
L
766 /* Reserve a number for orig_eax. */
767 set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
768
769 if (! tdesc_has_registers (tdesc))
770 tdesc = tdesc_i386_linux;
771 tdep->tdesc = tdesc;
772
773 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
774 if (feature == NULL)
775 return;
8201327c 776
90884b2b
L
777 valid_p = tdesc_numbered_register (feature, tdesc_data,
778 I386_LINUX_ORIG_EAX_REGNUM,
779 "orig_eax");
780 if (!valid_p)
781 return;
782
783 /* Add the %orig_eax register used for syscall restarting. */
8201327c 784 set_gdbarch_write_pc (gdbarch, i386_linux_write_pc);
90884b2b
L
785
786 tdep->register_reggroup_p = i386_linux_register_reggroup_p;
8201327c 787
e9f1aad5
MK
788 tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
789 tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
790 tdep->sizeof_gregset = 17 * 4;
791
8201327c
MK
792 tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
793
911bc6ee 794 tdep->sigtramp_p = i386_linux_sigtramp_p;
b7d15bf7 795 tdep->sigcontext_addr = i386_linux_sigcontext_addr;
a3386186 796 tdep->sc_reg_offset = i386_linux_sc_reg_offset;
bb489b3c 797 tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset);
8201327c 798
c131fcee
L
799 tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET;
800
a6b808b4 801 set_gdbarch_process_record (gdbarch, i386_process_record);
8a2e0e28 802 set_gdbarch_process_record_signal (gdbarch, i386_linux_record_signal);
a6b808b4 803
77fcef51 804 /* Initialize the i386_linux_record_tdep. */
5e31abdf
HZ
805 /* These values are the size of the type that will be used in a system
806 call. They are obtained from Linux Kernel source. */
2c543fc4
HZ
807 i386_linux_record_tdep.size_pointer
808 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
5e31abdf
HZ
809 i386_linux_record_tdep.size__old_kernel_stat = 32;
810 i386_linux_record_tdep.size_tms = 16;
811 i386_linux_record_tdep.size_loff_t = 8;
812 i386_linux_record_tdep.size_flock = 16;
813 i386_linux_record_tdep.size_oldold_utsname = 45;
814 i386_linux_record_tdep.size_ustat = 20;
7571f7f2
MK
815 i386_linux_record_tdep.size_old_sigaction = 16;
816 i386_linux_record_tdep.size_old_sigset_t = 4;
5e31abdf
HZ
817 i386_linux_record_tdep.size_rlimit = 8;
818 i386_linux_record_tdep.size_rusage = 72;
819 i386_linux_record_tdep.size_timeval = 8;
820 i386_linux_record_tdep.size_timezone = 8;
821 i386_linux_record_tdep.size_old_gid_t = 2;
822 i386_linux_record_tdep.size_old_uid_t = 2;
823 i386_linux_record_tdep.size_fd_set = 128;
72aded86 824 i386_linux_record_tdep.size_old_dirent = 268;
5e31abdf
HZ
825 i386_linux_record_tdep.size_statfs = 64;
826 i386_linux_record_tdep.size_statfs64 = 84;
827 i386_linux_record_tdep.size_sockaddr = 16;
2c543fc4
HZ
828 i386_linux_record_tdep.size_int
829 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
830 i386_linux_record_tdep.size_long
831 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
832 i386_linux_record_tdep.size_ulong
833 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
5e31abdf
HZ
834 i386_linux_record_tdep.size_msghdr = 28;
835 i386_linux_record_tdep.size_itimerval = 16;
836 i386_linux_record_tdep.size_stat = 88;
837 i386_linux_record_tdep.size_old_utsname = 325;
838 i386_linux_record_tdep.size_sysinfo = 64;
839 i386_linux_record_tdep.size_msqid_ds = 88;
840 i386_linux_record_tdep.size_shmid_ds = 84;
841 i386_linux_record_tdep.size_new_utsname = 390;
842 i386_linux_record_tdep.size_timex = 128;
843 i386_linux_record_tdep.size_mem_dqinfo = 24;
844 i386_linux_record_tdep.size_if_dqblk = 68;
845 i386_linux_record_tdep.size_fs_quota_stat = 68;
846 i386_linux_record_tdep.size_timespec = 8;
847 i386_linux_record_tdep.size_pollfd = 8;
848 i386_linux_record_tdep.size_NFS_FHSIZE = 32;
849 i386_linux_record_tdep.size_knfsd_fh = 132;
850 i386_linux_record_tdep.size_TASK_COMM_LEN = 16;
7571f7f2 851 i386_linux_record_tdep.size_sigaction = 20;
5e31abdf
HZ
852 i386_linux_record_tdep.size_sigset_t = 8;
853 i386_linux_record_tdep.size_siginfo_t = 128;
854 i386_linux_record_tdep.size_cap_user_data_t = 12;
855 i386_linux_record_tdep.size_stack_t = 12;
856 i386_linux_record_tdep.size_off_t = i386_linux_record_tdep.size_long;
857 i386_linux_record_tdep.size_stat64 = 96;
d625f9a9
MK
858 i386_linux_record_tdep.size_gid_t = 4;
859 i386_linux_record_tdep.size_uid_t = 4;
5e31abdf
HZ
860 i386_linux_record_tdep.size_PAGE_SIZE = 4096;
861 i386_linux_record_tdep.size_flock64 = 24;
862 i386_linux_record_tdep.size_user_desc = 16;
863 i386_linux_record_tdep.size_io_event = 32;
864 i386_linux_record_tdep.size_iocb = 64;
865 i386_linux_record_tdep.size_epoll_event = 12;
2c543fc4
HZ
866 i386_linux_record_tdep.size_itimerspec
867 = i386_linux_record_tdep.size_timespec * 2;
5e31abdf 868 i386_linux_record_tdep.size_mq_attr = 32;
5e31abdf
HZ
869 i386_linux_record_tdep.size_termios = 36;
870 i386_linux_record_tdep.size_termios2 = 44;
871 i386_linux_record_tdep.size_pid_t = 4;
872 i386_linux_record_tdep.size_winsize = 8;
873 i386_linux_record_tdep.size_serial_struct = 60;
874 i386_linux_record_tdep.size_serial_icounter_struct = 80;
875 i386_linux_record_tdep.size_hayes_esp_config = 12;
2c543fc4
HZ
876 i386_linux_record_tdep.size_size_t = 4;
877 i386_linux_record_tdep.size_iovec = 8;
b80d067f 878 i386_linux_record_tdep.size_time_t = 4;
5e31abdf
HZ
879
880 /* These values are the second argument of system call "sys_ioctl".
881 They are obtained from Linux Kernel source. */
882 i386_linux_record_tdep.ioctl_TCGETS = 0x5401;
883 i386_linux_record_tdep.ioctl_TCSETS = 0x5402;
884 i386_linux_record_tdep.ioctl_TCSETSW = 0x5403;
885 i386_linux_record_tdep.ioctl_TCSETSF = 0x5404;
886 i386_linux_record_tdep.ioctl_TCGETA = 0x5405;
887 i386_linux_record_tdep.ioctl_TCSETA = 0x5406;
888 i386_linux_record_tdep.ioctl_TCSETAW = 0x5407;
889 i386_linux_record_tdep.ioctl_TCSETAF = 0x5408;
890 i386_linux_record_tdep.ioctl_TCSBRK = 0x5409;
891 i386_linux_record_tdep.ioctl_TCXONC = 0x540A;
892 i386_linux_record_tdep.ioctl_TCFLSH = 0x540B;
893 i386_linux_record_tdep.ioctl_TIOCEXCL = 0x540C;
894 i386_linux_record_tdep.ioctl_TIOCNXCL = 0x540D;
895 i386_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E;
896 i386_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F;
897 i386_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410;
898 i386_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411;
899 i386_linux_record_tdep.ioctl_TIOCSTI = 0x5412;
900 i386_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413;
901 i386_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414;
902 i386_linux_record_tdep.ioctl_TIOCMGET = 0x5415;
903 i386_linux_record_tdep.ioctl_TIOCMBIS = 0x5416;
904 i386_linux_record_tdep.ioctl_TIOCMBIC = 0x5417;
905 i386_linux_record_tdep.ioctl_TIOCMSET = 0x5418;
906 i386_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419;
907 i386_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A;
908 i386_linux_record_tdep.ioctl_FIONREAD = 0x541B;
909 i386_linux_record_tdep.ioctl_TIOCINQ = i386_linux_record_tdep.ioctl_FIONREAD;
910 i386_linux_record_tdep.ioctl_TIOCLINUX = 0x541C;
911 i386_linux_record_tdep.ioctl_TIOCCONS = 0x541D;
912 i386_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E;
913 i386_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F;
914 i386_linux_record_tdep.ioctl_TIOCPKT = 0x5420;
915 i386_linux_record_tdep.ioctl_FIONBIO = 0x5421;
916 i386_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422;
917 i386_linux_record_tdep.ioctl_TIOCSETD = 0x5423;
918 i386_linux_record_tdep.ioctl_TIOCGETD = 0x5424;
919 i386_linux_record_tdep.ioctl_TCSBRKP = 0x5425;
920 i386_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426;
921 i386_linux_record_tdep.ioctl_TIOCSBRK = 0x5427;
922 i386_linux_record_tdep.ioctl_TIOCCBRK = 0x5428;
923 i386_linux_record_tdep.ioctl_TIOCGSID = 0x5429;
924 i386_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a;
925 i386_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b;
926 i386_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c;
927 i386_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d;
928 i386_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430;
929 i386_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431;
930 i386_linux_record_tdep.ioctl_FIONCLEX = 0x5450;
931 i386_linux_record_tdep.ioctl_FIOCLEX = 0x5451;
932 i386_linux_record_tdep.ioctl_FIOASYNC = 0x5452;
933 i386_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453;
934 i386_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454;
935 i386_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455;
936 i386_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456;
937 i386_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457;
938 i386_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458;
939 i386_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459;
940 i386_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A;
941 i386_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B;
942 i386_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C;
943 i386_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D;
944 i386_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E;
945 i386_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F;
946 i386_linux_record_tdep.ioctl_FIOQSIZE = 0x5460;
947
948 /* These values are the second argument of system call "sys_fcntl"
949 and "sys_fcntl64". They are obtained from Linux Kernel source. */
950 i386_linux_record_tdep.fcntl_F_GETLK = 5;
951 i386_linux_record_tdep.fcntl_F_GETLK64 = 12;
952 i386_linux_record_tdep.fcntl_F_SETLK64 = 13;
953 i386_linux_record_tdep.fcntl_F_SETLKW64 = 14;
50ef67b3 954
77fcef51
HZ
955 i386_linux_record_tdep.arg1 = I386_EBX_REGNUM;
956 i386_linux_record_tdep.arg2 = I386_ECX_REGNUM;
957 i386_linux_record_tdep.arg3 = I386_EDX_REGNUM;
958 i386_linux_record_tdep.arg4 = I386_ESI_REGNUM;
959 i386_linux_record_tdep.arg5 = I386_EDI_REGNUM;
2c543fc4 960 i386_linux_record_tdep.arg6 = I386_EBP_REGNUM;
77fcef51 961
ffdf6de5
JK
962 tdep->i386_intx80_record = i386_linux_intx80_sysenter_syscall_record;
963 tdep->i386_sysenter_record = i386_linux_intx80_sysenter_syscall_record;
964 tdep->i386_syscall_record = i386_linux_intx80_sysenter_syscall_record;
77fcef51 965
203c3895 966 /* N_FUN symbols in shared libaries have 0 for their values and need
1777feb0 967 to be relocated. */
203c3895
UW
968 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
969
871fbe6a 970 /* GNU/Linux uses SVR4-style shared libraries. */
982e9687 971 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
871fbe6a
MK
972 set_solib_svr4_fetch_link_map_offsets
973 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
974
975 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
bb41a796 976 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
12b8a2cb
DJ
977
978 dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
b2756930
KB
979
980 /* Enable TLS support. */
981 set_gdbarch_fetch_tls_load_module_address (gdbarch,
982 svr4_fetch_objfile_link_map);
237fc4c9 983
5aa82d05
AA
984 /* Core file support. */
985 set_gdbarch_iterate_over_regset_sections
986 (gdbarch, i386_linux_iterate_over_regset_sections);
90884b2b
L
987 set_gdbarch_core_read_description (gdbarch,
988 i386_linux_core_read_description);
989
237fc4c9
PA
990 /* Displaced stepping. */
991 set_gdbarch_displaced_step_copy_insn (gdbarch,
9a7f938f 992 i386_linux_displaced_step_copy_insn);
237fc4c9
PA
993 set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup);
994 set_gdbarch_displaced_step_free_closure (gdbarch,
995 simple_displaced_step_free_closure);
996 set_gdbarch_displaced_step_location (gdbarch,
906d60cf 997 linux_displaced_step_location);
4aa995e1 998
a96d9b2e 999 /* Functions for 'catch syscall'. */
458c8db8 1000 set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
a96d9b2e
SDJ
1001 set_gdbarch_get_syscall_number (gdbarch,
1002 i386_linux_get_syscall_number);
190b495d
WT
1003
1004 set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type);
8201327c
MK
1005}
1006
1007/* Provide a prototype to silence -Wmissing-prototypes. */
1008extern void _initialize_i386_linux_tdep (void);
1009
1010void
1011_initialize_i386_linux_tdep (void)
1012{
05816f70 1013 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
8201327c 1014 i386_linux_init_abi);
90884b2b 1015
1777feb0 1016 /* Initialize the Linux target description. */
90884b2b 1017 initialize_tdesc_i386_linux ();
3a13a53b 1018 initialize_tdesc_i386_mmx_linux ();
c131fcee 1019 initialize_tdesc_i386_avx_linux ();
1dbcd68c 1020 initialize_tdesc_i386_mpx_linux ();
01f9f808 1021 initialize_tdesc_i386_avx512_linux ();
8201327c 1022}
This page took 1.76008 seconds and 4 git commands to generate.