+/* Similar to i386_supply_fpregset, but use XSAVE extended state. */
+
+static void
+i386_linux_supply_xstateregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *xstateregs, size_t len)
+{
+ i387_supply_xsave (regcache, regnum, xstateregs);
+}
+
+struct type *
+x86_linux_get_siginfo_type (struct gdbarch *gdbarch)
+{
+ return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND);
+}
+
+/* Similar to i386_collect_fpregset, but use XSAVE extended state. */
+
+static void
+i386_linux_collect_xstateregset (const struct regset *regset,
+ const struct regcache *regcache,
+ int regnum, void *xstateregs, size_t len)
+{
+ i387_collect_xsave (regcache, regnum, xstateregs, 1);
+}
+
+/* Register set definitions. */
+
+static const struct regset i386_linux_xstateregset =
+ {
+ NULL,
+ i386_linux_supply_xstateregset,
+ i386_linux_collect_xstateregset
+ };
+
+/* Iterate over core file register note sections. */
+
+static void
+i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+ iterate_over_regset_sections_cb *cb,
+ void *cb_data,
+ const struct regcache *regcache)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ cb (".reg", 68, &i386_gregset, NULL, cb_data);
+
+ if (tdep->xcr0 & X86_XSTATE_AVX)
+ cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0),
+ &i386_linux_xstateregset, "XSAVE extended state", cb_data);
+ else if (tdep->xcr0 & X86_XSTATE_SSE)
+ cb (".reg-xfp", 512, &i386_fpregset, "extended floating-point",
+ cb_data);
+ else
+ cb (".reg2", 108, &i386_fpregset, NULL, cb_data);
+}
+
+/* Linux kernel shows PC value after the 'int $0x80' instruction even if
+ inferior is still inside the syscall. On next PTRACE_SINGLESTEP it will
+ finish the syscall but PC will not change.
+
+ Some vDSOs contain 'int $0x80; ret' and during stepping out of the syscall
+ i386_displaced_step_fixup would keep PC at the displaced pad location.
+ As PC is pointing to the 'ret' instruction before the step
+ i386_displaced_step_fixup would expect inferior has just executed that 'ret'
+ and PC should not be adjusted. In reality it finished syscall instead and
+ PC should get relocated back to its vDSO address. Hide the 'ret'
+ instruction by 'nop' so that i386_displaced_step_fixup is not confused.
+
+ It is not fully correct as the bytes in struct displaced_step_closure will
+ not match the inferior code. But we would need some new flag in
+ displaced_step_closure otherwise to keep the state that syscall is finishing
+ for the later i386_displaced_step_fixup execution as the syscall execution
+ is already no longer detectable there. The new flag field would mean
+ i386-linux-tdep.c needs to wrap all the displacement methods of i386-tdep.c
+ which does not seem worth it. The same effect is achieved by patching that
+ 'nop' instruction there instead. */
+
+static struct displaced_step_closure *
+i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
+ CORE_ADDR from, CORE_ADDR to,
+ struct regcache *regs)
+{
+ struct displaced_step_closure *closure;
+
+ closure = i386_displaced_step_copy_insn (gdbarch, from, to, regs);
+
+ if (i386_linux_get_syscall_number_from_regcache (regs) != -1)
+ {
+ /* Since we use simple_displaced_step_copy_insn, our closure is a
+ copy of the instruction. */
+ gdb_byte *insn = (gdb_byte *) closure;
+
+ /* Fake nop. */
+ insn[0] = 0x90;
+ }
+
+ return closure;
+}
+