- Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2003-2018 Free Software Foundation, Inc.
/* The following bits of code help with implementing debugging 32-bit
code natively on AMD64. The idea is to define two mappings between
/* The following bits of code help with implementing debugging 32-bit
code natively on AMD64. The idea is to define two mappings between
{
int *reg_offset = amd64_native_gregset64_reg_offset;
int num_regs = amd64_native_gregset64_num_regs;
gdb_assert (regnum >= 0);
{
int *reg_offset = amd64_native_gregset64_reg_offset;
int num_regs = amd64_native_gregset64_num_regs;
gdb_assert (regnum >= 0);
- if (num_regs > gdbarch_num_regs (current_gdbarch))
- num_regs = gdbarch_num_regs (current_gdbarch);
+ if (num_regs > gdbarch_num_regs (gdbarch))
+ num_regs = gdbarch_num_regs (gdbarch);
+
+ if (regnum >= num_regs)
+ return -1;
- if (regnum < num_regs && regnum < gdbarch_num_regs (current_gdbarch))
- return reg_offset[regnum];
+ /* Kernels that predate Linux 2.6.25 don't provide access to
+ these segment registers in user_regs_struct. */
+#ifndef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
+ if (regnum == AMD64_FSBASE_REGNUM || regnum == AMD64_GSBASE_REGNUM)
+ return -1;
+#endif
amd64_supply_native_gregset (struct regcache *regcache,
const void *gregs, int regnum)
{
amd64_supply_native_gregset (struct regcache *regcache,
const void *gregs, int regnum)
{
- memset (regs + amd64_native_gregset_reg_offset (i), 0, 8);
+ memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), 0, 8);
}
/* Ditto for %cs, %ss, %ds, %es, %fs, and %gs. */
for (i = I386_CS_REGNUM; i <= I386_GS_REGNUM; i++)
{
if (regnum == -1 || regnum == i)
}
/* Ditto for %cs, %ss, %ds, %es, %fs, and %gs. */
for (i = I386_CS_REGNUM; i <= I386_GS_REGNUM; i++)
{
if (regnum == -1 || regnum == i)
- memset (regs + amd64_native_gregset_reg_offset (i), 0, 8);
+ memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), 0, 8);