* x86-64-linux-nat.c (x86_64_fxsave_offset): New.
(supply_fpregset, fill_fpregset): Don't call i387_*_fxsave,
better do the things actually here.
* x86-64-tdep.c (x86_64_register_name2nr): New.
(x86_64_register_name): Renamed to x86_64_register_nr2name.
(x86_64_gdbarch_init): Respect the above change.
* x86-64-tdep.h (x86_64_register_name2nr)
(x86_64_register_nr2name): Add prototypes.
* config/i386/x86-64linux.mt (TDEPFILES): Remove i387-tdep.o.
+2002-06-07 Michal Ludvig <mludvig@suse.cz>
+
+ * x86-64-linux-nat.c (x86_64_fxsave_offset): New.
+ (supply_fpregset, fill_fpregset): Don't call i387_*_fxsave,
+ better do the things actually here.
+ * x86-64-tdep.c (x86_64_register_name2nr): New.
+ (x86_64_register_name): Renamed to x86_64_register_nr2name.
+ (x86_64_gdbarch_init): Respect the above change.
+ * x86-64-tdep.h (x86_64_register_name2nr)
+ (x86_64_register_nr2name): Add prototypes.
+ * config/i386/x86-64linux.mt (TDEPFILES): Remove i387-tdep.o.
+
2002-06-06 Michael Snyder <msnyder@redhat.com>
* d10v-tdep.c (d10v_push_arguments): Handle struct_return.
# Target: AMD x86-64 running GNU/Linux
-TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o i387-tdep.o dwarf2cfi.o \
+TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o dwarf2cfi.o \
solib.o solib-svr4.o solib-legacy.o
#include "inferior.h"
#include "gdbcore.h"
#include "regcache.h"
-#include "i387-tdep.h"
#include "gdb_assert.h"
#include "x86-64-tdep.h"
/* Transfering floating-point registers between GDB, inferiors and cores. */
-/* Fill GDB's register array with the floating-point register values in
- *FPREGSETP. */
+static void *
+x86_64_fxsave_offset (elf_fpregset_t * fxsave, int regnum)
+{
+ char *reg_name;
+ int reg_index;
+
+ gdb_assert (x86_64_num_gregs - 1 < regnum && regnum < x86_64_num_regs);
+
+ reg_name = x86_64_register_nr2name (regnum);
+
+ if (reg_name[0] == 's' && reg_name[1] == 't')
+ {
+ reg_index = reg_name[2] - '0';
+ return &fxsave->st_space[reg_index * 2];
+ }
+
+ if (reg_name[0] == 'x' && reg_name[1] == 'm' && reg_name[2] == 'm')
+ {
+ reg_index = reg_name[3] - '0';
+ return &fxsave->xmm_space[reg_index * 4];
+ }
+
+ if (strcmp (reg_name, "mxcsr") == 0)
+ return &fxsave->mxcsr;
+
+ return NULL;
+}
+
+/* Fill GDB's register array with the floating-point and SSE register
+ values in *FXSAVE. This function masks off any of the reserved
+ bits in *FXSAVE. */
void
-supply_fpregset (elf_fpregset_t * fpregsetp)
+supply_fpregset (elf_fpregset_t * fxsave)
{
- i387_supply_fxsave ((char *) fpregsetp);
+ int i, reg_st0, reg_mxcsr;
+
+ reg_st0 = x86_64_register_name2nr ("st0");
+ reg_mxcsr = x86_64_register_name2nr ("mxcsr");
+
+ gdb_assert (reg_st0 > 0 && reg_mxcsr > reg_st0);
+
+ for (i = reg_st0; i <= reg_mxcsr; i++)
+ supply_register (i, x86_64_fxsave_offset (fxsave, i));
}
-/* Fill register REGNO (if it is a floating-point register) in
- *FPREGSETP with the value in GDB's register array. If REGNO is -1,
- do this for all registers. */
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+ *FXSAVE with the value in GDB's register array. If REGNUM is -1, do
+ this for all registers. This function doesn't touch any of the
+ reserved bits in *FXSAVE. */
void
-fill_fpregset (elf_fpregset_t * fpregsetp, int regno)
+fill_fpregset (elf_fpregset_t * fxsave, int regnum)
{
- i387_fill_fxsave ((char *) fpregsetp, regno);
+ int i, last_regnum = MXCSR_REGNUM;
+ void *ptr;
+
+ if (gdbarch_tdep (current_gdbarch)->num_xmm_regs == 0)
+ last_regnum = FOP_REGNUM;
+
+ for (i = FP0_REGNUM; i <= last_regnum; i++)
+ if (regnum == -1 || regnum == i)
+ {
+ ptr = x86_64_fxsave_offset (fxsave, i);
+ if (ptr)
+ regcache_collect (i, ptr);
+ }
}
/* Fetch all floating-point registers from process/thread TID and store
{
int num = classify_argument (TYPE_FIELDS (type)[j].type,
subclasses,
- (TYPE_FIELDS (type)[j].loc.bitpos
- + bit_offset) % 256);
+ (TYPE_FIELDS (type)[j].loc.
+ bitpos + bit_offset) % 256);
if (!num)
return 0;
for (i = 0; i < num; i++)
{
int pos =
- (TYPE_FIELDS (type)[j].loc.bitpos + bit_offset) / 8 / 8;
+ (TYPE_FIELDS (type)[j].loc.bitpos +
+ bit_offset) / 8 / 8;
classes[i + pos] =
merge_classes (subclasses[i], classes[i + pos]);
}
}
case TYPE_CODE_VOID:
return 0;
- default: /* Avoid warning. */
+ default: /* Avoid warning. */
break;
}
internal_error (__FILE__, __LINE__,
}
\f
-static char *
-x86_64_register_name (int reg_nr)
+char *
+x86_64_register_nr2name (int reg_nr)
{
if (reg_nr < 0 || reg_nr >= X86_64_NUM_REGS)
return NULL;
return x86_64_register_info_table[reg_nr].name;
}
+
+int
+x86_64_register_name2nr (const char *name)
+{
+ int reg_nr;
+
+ for (reg_nr = 0; reg_nr < X86_64_NUM_REGS; reg_nr++)
+ if (strcmp (name, x86_64_register_info_table[reg_nr].name) == 0)
+ return reg_nr;
+ return -1;
+}
\f
/* First check, whether pc points to pushq %rbp, movq %rsp,%rbp. */
for (i = 0; i < PROLOG_BUFSIZE; i++)
if (prolog_expect[i] != prolog_buf[i])
- return pc; /* ... no, it doesn't. Nothing to skip. */
+ return pc; /* ... no, it doesn't. Nothing to skip. */
/* OK, we have found the prologue and want PC of the first
non-prologue instruction. */
set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
set_gdbarch_num_regs (gdbarch, X86_64_NUM_REGS);
- set_gdbarch_register_name (gdbarch, x86_64_register_name);
+ set_gdbarch_register_name (gdbarch, x86_64_register_nr2name);
set_gdbarch_register_size (gdbarch, 8);
set_gdbarch_register_raw_size (gdbarch, x86_64_register_raw_size);
set_gdbarch_max_register_raw_size (gdbarch, 16);
extern int x86_64_num_regs;
extern int x86_64_num_gregs;
+int x86_64_register_name2nr (const char *name);
+char *x86_64_register_nr2name (int reg_nr);
+
gdbarch_frame_saved_pc_ftype x86_64_linux_frame_saved_pc;
gdbarch_saved_pc_after_call_ftype x86_64_linux_saved_pc_after_call;