diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index d0328b677d5..ce2e980ad4e 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -85,6 +85,11 @@ static int amd64_linux_gregset32_reg_offset[] = -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */ -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */ -1, /* PKEYS register PKRU */ +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + FS_BASE * 8, GS_BASE * 8, /* fs_base and gs_base */ +#else + -1, -1, /* fs_base and gs_base */ +#endif ORIG_RAX * 8 /* "orig_eax" */ }; diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 7ec08c7fc49..918dbed617c 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -98,7 +98,11 @@ int amd64_linux_gregset_reg_offset[] = -1, /* PKEYS register pkru */ /* End of hardware registers */ +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE 21 * 8, 22 * 8, /* fs_base and gs_base. */ +#else + -1, -1, /* fs_base and gs_base. */ +#endif 15 * 8 /* "orig_rax" */ }; @@ -1593,9 +1597,15 @@ amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32) [(xcr0_features_bit & X86_XSTATE_PKRU) ? 1 : 0]; } +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + const bool segment = true; +#else + const bool segment = false; +#endif + if (*tdesc == NULL) *tdesc = amd64_create_target_description (xcr0_features_bit, is_x32, - true, true); + true, segment); return *tdesc; } diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 0f10686bc01..9cb2cd16e55 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -609,6 +609,7 @@ int i386_linux_gregset_reg_offset[] = -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */ -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */ -1, /* PKRU register */ + -1, -1, /* fs_base and gs_base. */ 11 * 4, /* "orig_eax" */ }; @@ -692,8 +693,14 @@ i386_linux_read_description (uint64_t xcr0) [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0] [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]; +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + const bool segment = true; +#else + const bool segment = false; +#endif + if (*tdesc == NULL) - *tdesc = i386_create_target_description (xcr0, true, false); + *tdesc = i386_create_target_description (xcr0, true, segment); return *tdesc; } diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h index 4842d216244..6b048c5ad44 100644 --- a/gdb/i386-linux-tdep.h +++ b/gdb/i386-linux-tdep.h @@ -29,7 +29,7 @@ /* Register number for the "orig_eax" pseudo-register. If this pseudo-register contains a value >= 0 it is interpreted as the system call number that the kernel is supposed to restart. */ -#define I386_LINUX_ORIG_EAX_REGNUM (I386_PKRU_REGNUM + 1) +#define I386_LINUX_ORIG_EAX_REGNUM (I386_GSBASE_REGNUM + 1) /* Total number of registers for GNU/Linux. */ #define I386_LINUX_NUM_REGS (I386_LINUX_ORIG_EAX_REGNUM + 1)