diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-08-13 14:32:28 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-08-13 14:32:28 +0000 |
commit | 28fc67409494a8a33cb1a7826a896a054ca71dd3 (patch) | |
tree | 55b6296ba26a63f1c11e8d4d04e0131247553985 /gdb | |
parent | a378f4192681bdbeb5f7aa12ae3c6e9505cd14a7 (diff) | |
download | gdb-28fc67409494a8a33cb1a7826a896a054ca71dd3.zip gdb-28fc67409494a8a33cb1a7826a896a054ca71dd3.tar.gz gdb-28fc67409494a8a33cb1a7826a896a054ca71dd3.tar.bz2 |
2002-08-13 Andrew Cagney <cagney@redhat.com>
* i386-tdep.c (i386_register_name): Handle mmx registers.
(mmx_regnum_p): New function.
(i386_mmx_names): New array.
(mmx_num_regs): New variable.
(i386_pseudo_register_read): New function.
(i386_pseudo_register_write): New function.
(mmx_regnum_to_fp_regnum): New function. Code from Fernando Nasser.
* regcache.c (regcache_raw_read_unsigned): New function.
(regcache_raw_read_signed): New function.
* regcache.h (regcache_raw_read_unsigned): Declare.
(regcache_raw_read_signed): Declare.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 79 | ||||
-rw-r--r-- | gdb/regcache.c | 25 | ||||
-rw-r--r-- | gdb/regcache.h | 4 |
4 files changed, 123 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 97a5bab..766a796 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 2002-08-13 Andrew Cagney <cagney@redhat.com> + * i386-tdep.c (i386_register_name): Handle mmx registers. + (mmx_regnum_p): New function. + (i386_mmx_names): New array. + (mmx_num_regs): New variable. + (i386_pseudo_register_read): New function. + (i386_pseudo_register_write): New function. + (mmx_regnum_to_fp_regnum): New function. Code from Fernando Nasser. + + * regcache.c (regcache_raw_read_unsigned): New function. + (regcache_raw_read_signed): New function. + * regcache.h (regcache_raw_read_unsigned): Declare. + (regcache_raw_read_signed): Declare. + +2002-08-13 Andrew Cagney <cagney@redhat.com> + * regcache.c (regcache_raw_read_as_address): Delete function. (regcache_cooked_read_signed): New function. (regcache_cooked_read_unsigned): New function. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index ad19691..7a8d2de 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -56,6 +56,23 @@ static char *i386_register_names[] = "mxcsr" }; +/* MMX registers. */ + +static char *i386_mmx_names[] = +{ + "mm0", "mm1", "mm2", "mm3", + "mm4", "mm5", "mm6", "mm7" +}; +static const int mmx_num_regs = (sizeof (i386_mmx_names) + / sizeof (i386_mmx_names[0])); +#define MM0_REGNUM (NUM_REGS) + +static int +mmx_regnum_p (int reg) +{ + return (reg >= MM0_REGNUM && reg < MM0_REGNUM + mmx_num_regs); +} + /* Return the name of register REG. */ const char * @@ -63,6 +80,8 @@ i386_register_name (int reg) { if (reg < 0) return NULL; + if (mmx_regnum_p (reg)) + return i386_mmx_names[reg - MM0_REGNUM]; if (reg >= sizeof (i386_register_names) / sizeof (*i386_register_names)) return NULL; @@ -1090,9 +1109,64 @@ i386_register_virtual_type (int regnum) if (IS_SSE_REGNUM (regnum)) return builtin_type_vec128i; + if (mmx_regnum_p (regnum)) + return builtin_type_vec64i; + return builtin_type_int; } +/* Map a cooked register onto a raw register or memory. For the i386, + the MMX registers need to be mapped onto floating point registers. */ + +static int +mmx_regnum_to_fp_regnum (struct regcache *regcache, int regnum) +{ + int mmxi; + ULONGEST fstat; + int tos; + int fpi; + mmxi = regnum - MM0_REGNUM; + regcache_raw_read_unsigned (regcache, FSTAT_REGNUM, &fstat); + tos = (fstat >> 11) & 0x7; + fpi = (mmxi + tos) % 8; + return (FP0_REGNUM + fpi); +} + +static void +i386_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, + int regnum, void *buf) +{ + if (mmx_regnum_p (regnum)) + { + char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE); + int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum); + regcache_raw_read (regcache, fpnum, mmx_buf); + /* Extract (always little endian). */ + memcpy (buf, mmx_buf, REGISTER_RAW_SIZE (regnum)); + } + else + regcache_raw_read (regcache, regnum, buf); +} + +static void +i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int regnum, const void *buf) +{ + if (mmx_regnum_p (regnum)) + { + char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE); + int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum); + /* Read ... */ + regcache_raw_read (regcache, fpnum, mmx_buf); + /* ... Modify ... (always little endian). */ + memcpy (mmx_buf, buf, REGISTER_RAW_SIZE (regnum)); + /* ... Write. */ + regcache_raw_write (regcache, fpnum, mmx_buf); + } + else + regcache_raw_write (regcache, regnum, buf); +} + /* Return true iff register REGNUM's virtual format is different from its raw format. Note that this definition assumes that the host supports IEEE 32-bit floats, since it doesn't say that SSE @@ -1486,6 +1560,11 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_frame_num_args (gdbarch, i386_frame_num_args); set_gdbarch_pc_in_sigtramp (gdbarch, i386_pc_in_sigtramp); + /* Wire in the MMX registers. */ + set_gdbarch_num_pseudo_regs (gdbarch, mmx_num_regs); + set_gdbarch_pseudo_register_read (gdbarch, i386_pseudo_register_read); + set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write); + /* Hook in ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch, osabi); diff --git a/gdb/regcache.c b/gdb/regcache.c index 6878b52..85d96c9 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -661,6 +661,31 @@ regcache_raw_read (struct regcache *regcache, int regnum, void *buf) } void +regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val) +{ + char *buf; + gdb_assert (regcache != NULL); + gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); + buf = alloca (regcache->descr->sizeof_register[regnum]); + regcache_raw_read (regcache, regnum, buf); + (*val) = extract_signed_integer (buf, + regcache->descr->sizeof_register[regnum]); +} + +void +regcache_raw_read_unsigned (struct regcache *regcache, int regnum, + ULONGEST *val) +{ + char *buf; + gdb_assert (regcache != NULL); + gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); + buf = alloca (regcache->descr->sizeof_register[regnum]); + regcache_raw_read (regcache, regnum, buf); + (*val) = extract_unsigned_integer (buf, + regcache->descr->sizeof_register[regnum]); +} + +void read_register_gen (int regnum, char *buf) { gdb_assert (current_regcache != NULL); diff --git a/gdb/regcache.h b/gdb/regcache.h index 117b088..4f6a079 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -38,6 +38,10 @@ struct regcache *regcache_xmalloc (struct gdbarch *gdbarch); void regcache_raw_read (struct regcache *regcache, int rawnum, void *buf); void regcache_raw_write (struct regcache *regcache, int rawnum, const void *buf); +extern void regcache_raw_read_signed (struct regcache *regcache, + int regnum, LONGEST *val); +extern void regcache_raw_read_unsigned (struct regcache *regcache, + int regnum, ULONGEST *val); int regcache_valid_p (struct regcache *regcache, int regnum); /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ |