+Tue Nov 2 13:42:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * findvar.c (value_of_register, value_from_register),
+ hppa-tdep.c (pa_print_fp_reg), infcmd.c (do_registers_info),
+ valops.c (value_assign): Use REGISTER_CONVERT_TO_* only if
+ REGISTER_CONVERTIBLE is defined, otherwise just copy the content.
+ Pass desired type to REGISTER_CONVERT_TO_*.
+
+ * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*):
+ Pass length of desired type to store/extract_floating.
+ * config/i386/tm-arm.h, config/i386/tm-i386aix.h,
+ config/i386/tm-sun386.h, config/i386/tm-symmetry.h,
+ config/m88k/tm-m88k.h config/rs6000/tm-rs6000.h (REGISTER_CONVERT_*):
+ Use extract_floating and store_floating with length of desired type.
+ * config/m68k/tm-news.h (STORE,EXTRACT_RETURN_VALUE): Add type
+ parameter to REGISTER_CONVERT_*.
+
+ * config/a29k/tm-a29k.h, config/convex/tm-convex.h,
+ config/gould/tm-np1.h, config/gould/tm-pn.h, config/h8300/tm-h8300.h,
+ config/h8500/tm-h8500.h, config/i386/tm-i386v.h,
+ config/mips/tm-mips.h, config/ns32k/tm-merlin.h,
+ config/ns32k/tm-umax.h, config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
+ config/sh/tm-sh.h, config/sparc/tm-sparc.h, config/tahoe/tm-tahoe.h,
+ config/vax/tm-vax.h, config/z8k/tm-z8k.h (REGISTER_CONVERTIBLE,
+ REGISTER_CONVERT_TO_RAW, REGISTER_CONVERT_TO_VIRTUAL): Remove
+ versions for which REGISTER_CONVERTIBLE is always false.
+ * z8k-tdep.c (register_convert_to_virtual, register_convert_to_raw):
+ Remove, no longer used.
+
+ * alpha-tdep.c (alpha_register_convert_to_raw,
+ alpha_register_convert_to_virtual): New routines to handle
+ the different raw formats in alpha floating point registers.
+ * config/alpha/tm-alpha.h (REGISTER_CONVERTIBLE,
+ REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Use them.
+
Mon Nov 1 09:40:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* symtab.c, symtab.h, source.c: Change find_line_pc_range to take
return pc >= startaddr && pc < end_prologue;
}
+/* The alpha needs a conversion between register and memory format if
+ the register is a floating point register and
+ memory format is float, as the register format must be double
+ or
+ memory format is an integer with 4 bytes or less, as the representation
+ of integers in floating point registers is different. */
+void
+alpha_register_convert_to_virtual (regnum, valtype, raw_buffer, virtual_buffer)
+ int regnum;
+ struct type *valtype;
+ char *raw_buffer;
+ char *virtual_buffer;
+{
+ if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
+ {
+ memcpy (virtual_buffer, raw_buffer, REGISTER_VIRTUAL_SIZE (regnum));
+ return;
+ }
+
+ if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
+ {
+ double d = extract_floating (raw_buffer, REGISTER_RAW_SIZE (regnum));
+ store_floating (virtual_buffer, TYPE_LENGTH (valtype), d);
+ }
+ else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
+ {
+ unsigned LONGEST l;
+ l = extract_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum));
+ l = ((l >> 32) & 0xc0000000) | ((l >> 29) & 0x3fffffff);
+ store_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype), l);
+ }
+ else
+ error ("Cannot retrieve value from floating point register");
+}
+
+void
+alpha_register_convert_to_raw (valtype, regnum, virtual_buffer, raw_buffer)
+ struct type *valtype;
+ int regnum;
+ char *virtual_buffer;
+ char *raw_buffer;
+{
+ if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
+ {
+ memcpy (raw_buffer, virtual_buffer, REGISTER_RAW_SIZE (regnum));
+ return;
+ }
+
+ if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
+ {
+ double d = extract_floating (virtual_buffer, TYPE_LENGTH (valtype));
+ store_floating (raw_buffer, REGISTER_RAW_SIZE (regnum), d);
+ }
+ else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
+ {
+ unsigned LONGEST l;
+ if (TYPE_UNSIGNED (valtype))
+ l = extract_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype));
+ else
+ l = extract_signed_integer (virtual_buffer, TYPE_LENGTH (valtype));
+ l = ((l & 0xc0000000) << 32) | ((l & 0x3fffffff) << 29);
+ store_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum), l);
+ }
+ else
+ error ("Cannot store value in floating point register");
+}
+
/* Given a return value in `regbuf' with a type `valtype',
extract and copy its value into `valbuf'. */
void
#define MAX_REGISTER_VIRTUAL_SIZE (4)
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), 4); }
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), 4); }
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ memcpy((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); }
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ memcpy((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); }
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), 4); }
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), 4); }
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define REGISTER_CONVERTIBLE(N) \
((N < FP0_REGNUM) ? 0 : 1)
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
+
#undef REGISTER_CONVERT_TO_VIRTUAL
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- ((REGNUM < FP0_REGNUM) ? memcpy ((TO), (FROM), 4) : \
- i387_to_double((FROM), (TO)))
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
+{ \
+ double val; \
+ i387_to_double ((FROM), (char *)&val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
+}
+extern void
+i387_to_double PARAMS ((char *, char *));
+
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
#undef REGISTER_CONVERT_TO_RAW
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- ((REGNUM < FP0_REGNUM) ? memcpy ((TO), (FROM), 4) : \
- double_to_i387((FROM), (TO)))
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
+{ \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_i387((char *)&val, (TO)))
+}
+extern void
+double_to_i387 PARAMS ((char *, char *));
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- {memcpy ((TO), (FROM), 4);}
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- {memcpy ((TO), (FROM), 4);}
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
/* Perhaps si and di should go here, but potentially they could be
#define REGISTER_CONVERTIBLE(N) (((unsigned)((N) - FP0_REGNUM)) < 8)
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- i387_to_double ((FROM), (TO)); \
- else \
- memcpy ((TO), (FROM), 4); }
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
+{ \
+ double val; \
+ i387_to_double ((FROM), (char *)&val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
+}
extern void
i387_to_double PARAMS ((char *, char *));
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- double_to_i387 ((FROM), (TO)); \
- else \
- memcpy ((TO), (FROM), 4); }
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
+{ \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_i387((char *)&val, (TO)))
+}
extern void
double_to_i387 PARAMS ((char *, char *));
(N < 14) ? 1 : \
0)
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
#undef REGISTER_CONVERT_TO_VIRTUAL
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \
-(REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
-(REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \
-(REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
- memcpy ((TO), (FROM), 4))
-
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
+{ \
+ double val; \
+ i387_to_double ((FROM), (char *)&val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
+}
extern void
i387_to_double PARAMS ((char *, char *));
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
#undef REGISTER_CONVERT_TO_RAW
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \
-(REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
-(REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \
-(REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
- memcpy ((TO), (FROM), 4))
-
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
+{ \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_i387((char *)&val, (TO)))
+}
extern void
double_to_i387 PARAMS ((char *, char *));
#define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM)
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
extern struct ext_format ext_format_i960;
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
{ \
double val; \
- if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- { \
- ieee_extended_to_double (&ext_format_i960, (FROM), &val); \
- store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \
- } \
- else \
- memcpy ((TO), (FROM), 4); \
+ ieee_extended_to_double (&ext_format_i960, (FROM), &val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
}
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
{ \
- if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- { \
- double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \
- double_to_ieee_extended (&ext_format_i960, &val, (TO)); \
- } \
- else \
- memcpy ((TO), (FROM), 4); \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_ieee_extended (&ext_format_i960, &val, (TO)); \
}
/* Return the GDB type object for the "standard" data type
will complain. */
extern const struct ext_format ext_format_68881;
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
{ \
double val; \
- if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- { \
- ieee_extended_to_double (&ext_format_68881, (FROM), &val); \
- store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \
- } \
- else \
- memcpy ((TO), (FROM), 4); \
+ ieee_extended_to_double (&ext_format_68881, (FROM), &val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
}
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
{ \
- if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \
- { \
- double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \
- double_to_ieee_extended (&ext_format_68881, &val, (TO)); \
- } \
- else \
- memcpy ((TO), (FROM), 4); \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_ieee_extended (&ext_format_68881, &val, (TO)); \
}
/* Return the GDB type object for the "standard" data type
{ if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
{ \
REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \
- ®BUF[REGISTER_BYTE (FP0_REGNUM)], VALBUF); \
+ REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \
+ ®BUF[REGISTER_BYTE (FP0_REGNUM)], \
+ VALBUF); \
} \
else \
memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE)); }
{ if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
{ \
char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \
- REGISTER_CONVERT_TO_RAW (FP0_REGNUM, VALBUF, raw_buf); \
+ REGISTER_CONVERT_TO_RAW (REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \
+ FP0_REGNUM, VALBUF, raw_buf); \
write_register_bytes (FP0_REGNUM, \
raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \
} \
extern const struct ext_format ext_format_m88110;
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
+/* Convert data from raw format for register REGNUM in buffer FROM
+ to virtual format with type TYPE in buffer TO. */
-/* FIXME: Use store_floating like tm-m68k.h. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
{ \
- if ((REGNUM) < XFP_REGNUM) \
- memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \
- else ieee_extended_to_double(&ext_format_m88110, \
- (FROM), (double *)(TO)); \
+ double val; \
+ ieee_extended_to_double (&ext_format_m88110, (FROM), &val); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
}
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-/* FIXME: Use extract_floating like tm-m68k.h. */
+/* Convert data from virtual format with type TYPE in buffer FROM
+ to raw format for register REGNUM in buffer TO. */
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
{ \
- if ((REGNUM) < XFP_REGNUM) \
- memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \
- else double_to_ieee_extended (&ext_format_m88110, \
- (double *)(FROM), (TO)); \
+ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ double_to_ieee_extended (&ext_format_m88110, &val, (TO)); \
}
/* Return the GDB type object for the "standard" data type
#define MAX_REGISTER_VIRTUAL_SIZE 8
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), 4);
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), 4);
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 8
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 8
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- { memcpy ((TO), (FROM), 4); }
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- { memcpy ((TO), (FROM), 4); }
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 8
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); }
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); }
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), 4);
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- memcpy ((TO), (FROM), 4);
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
#define MAX_REGISTER_VIRTUAL_SIZE 4
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) 0
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
- register_convert_to_virtual(REGNUM, FROM, TO)
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
- register_convert_to_raw(REGNUM, FROM, TO)
-
/* Return the GDB type object for the "standard" data type
of data in register N. */
store_unsigned_integer (addr, len, (LONGEST)val);
}
\f
+/* Swap LEN bytes at BUFFER between target and host byte-order. This is
+ the wrong way to do byte-swapping because it assumes that you have a way
+ to have a host variable of exactly the right size. Once extract_floating
+ and store_floating have been fixed, this can go away. */
+#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
+#define SWAP_TARGET_AND_HOST(buffer,len)
+#else /* Target and host byte order differ. */
+#define SWAP_TARGET_AND_HOST(buffer,len) \
+ { \
+ char tmp; \
+ char *p = (char *)(buffer); \
+ char *q = ((char *)(buffer)) + len - 1; \
+ for (; p < q; p++, q--) \
+ { \
+ tmp = *q; \
+ *q = *p; \
+ *p = tmp; \
+ } \
+ }
+#endif /* Target and host byte order differ. */
+
+/* There are many problems with floating point cross-debugging.
+
+ 1. These routines only handle byte-swapping, not conversion of
+ formats. So if host is IEEE floating and target is VAX floating,
+ or vice-versa, it loses. This means that we can't (yet) use these
+ routines for extendeds. Extendeds are handled by
+ REGISTER_CONVERTIBLE. What we want is a fixed version of
+ ieee-float.c (the current version can't deal with single or double,
+ and I suspect it is probably broken for some extendeds too).
+
+ 2. We can't deal with it if there is more than one floating point
+ format in use. This has to be fixed at the unpack_double level.
+
+ 3. We probably should have a LONGEST_DOUBLE or DOUBLEST or whatever
+ we want to call it which is long double where available. */
+
+double
+extract_floating (addr, len)
+ PTR addr;
+ int len;
+{
+ if (len == sizeof (float))
+ {
+ float retval;
+ memcpy (&retval, addr, sizeof (retval));
+ SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
+ return retval;
+ }
+ else if (len == sizeof (double))
+ {
+ double retval;
+ memcpy (&retval, addr, sizeof (retval));
+ SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
+ return retval;
+ }
+ else
+ {
+ error ("Can't deal with a floating point number of %d bytes.", len);
+ }
+}
+
+void
+store_floating (addr, len, val)
+ PTR addr;
+ int len;
+ double val;
+{
+ if (len == sizeof (float))
+ {
+ float floatval = val;
+ SWAP_TARGET_AND_HOST (&floatval, sizeof (floatval));
+ memcpy (addr, &floatval, sizeof (floatval));
+ }
+ else if (len == sizeof (double))
+ {
+ SWAP_TARGET_AND_HOST (&val, sizeof (val));
+ memcpy (addr, &val, sizeof (val));
+ }
+ else
+ {
+ error ("Can't deal with a floating point number of %d bytes.", len);
+ }
+}
+\f
#if !defined (GET_SAVED_REGISTER)
/* Return the address in which frame FRAME's value of register REGNUM
int optim;
register value val;
char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
enum lval_type lval;
get_saved_register (raw_buffer, &optim, &addr,
selected_frame, regnum, &lval);
- REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer);
val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- memcpy (VALUE_CONTENTS_RAW (val), virtual_buffer,
- REGISTER_VIRTUAL_SIZE (regnum));
+
+ /* Convert raw data to virtual format if necessary. */
+
+#ifdef REGISTER_CONVERTIBLE
+ if (REGISTER_CONVERTIBLE (regnum))
+ {
+ REGISTER_CONVERT_TO_VIRTUAL (regnum, REGISTER_VIRTUAL_TYPE (regnum),
+ raw_buffer, VALUE_CONTENTS_RAW (val));
+ }
+ else
+#endif
+ memcpy (VALUE_CONTENTS_RAW (val), raw_buffer,
+ REGISTER_RAW_SIZE (regnum));
VALUE_LVAL (val) = lval;
VALUE_ADDRESS (val) = addr;
VALUE_REGNO (val) = regnum;
FRAME frame;
{
char raw_buffer [MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
CORE_ADDR addr;
int optim;
value v = allocate_value (type);
VALUE_OPTIMIZED_OUT (v) = optim;
VALUE_LVAL (v) = lval;
VALUE_ADDRESS (v) = addr;
+
+ /* Convert raw data to virtual format if necessary. */
- /* Convert the raw contents to virtual contents.
- (Just copy them if the formats are the same.) */
-
- REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer);
-
+#ifdef REGISTER_CONVERTIBLE
if (REGISTER_CONVERTIBLE (regnum))
{
- /* When the raw and virtual formats differ, the virtual format
- corresponds to a specific data type. If we want that type,
- copy the data into the value.
- Otherwise, do a type-conversion. */
-
- if (type != REGISTER_VIRTUAL_TYPE (regnum))
- {
- /* eg a variable of type `float' in a 68881 register
- with raw type `extended' and virtual type `double'.
- Fetch it as a `double' and then convert to `float'. */
- /* FIXME: This value will be not_lval, which means we can't assign
- to it. Probably the right fix is to do the cast on a temporary
- value, and just copy the VALUE_CONTENTS over. */
- v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer,
- REGISTER_VIRTUAL_SIZE (regnum));
- v = value_cast (type, v);
- }
- else
- memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len);
+ REGISTER_CONVERT_TO_VIRTUAL (regnum, type,
+ raw_buffer, VALUE_CONTENTS_RAW (v));
}
else
+#endif
{
/* Raw and virtual formats are the same for this register. */
}
#endif
- memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer + VALUE_OFFSET (v), len);
+ memcpy (VALUE_CONTENTS_RAW (v), raw_buffer + VALUE_OFFSET (v), len);
}
return v;
unsigned char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
REGISTER_TYPE val;
- /* Get the data in raw format, then convert also to virtual format. */
+ /* Get the data in raw format. */
read_relative_register_raw_bytes (i, raw_buffer);
- REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer);
+
+ /* Convert raw data to virtual format if necessary. */
+#ifdef REGISTER_CONVERTIBLE
+ if (REGISTER_CONVERTIBLE (i))
+ {
+ REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
+ raw_buffer, virtual_buffer);
+ }
+ else
+#endif
+ memcpy (virtual_buffer, raw_buffer,
+ REGISTER_VIRTUAL_SIZE (i));
fputs_filtered (reg_names[i], gdb_stdout);
print_spaces_filtered (15 - strlen (reg_names[i]), gdb_stdout);
register struct type *type = VALUE_TYPE (toval);
register value val;
char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
int use_buffer = 0;
COERCE_ARRAY (fromval);
convert FROMVAL's contents now, with result in `raw_buffer',
and set USE_BUFFER to the number of bytes to write. */
+#ifdef REGISTER_CONVERTIBLE
if (VALUE_REGNO (toval) >= 0
&& REGISTER_CONVERTIBLE (VALUE_REGNO (toval)))
{
int regno = VALUE_REGNO (toval);
- if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno))
- fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval);
- memcpy (virtual_buffer, VALUE_CONTENTS (fromval),
- REGISTER_VIRTUAL_SIZE (regno));
- REGISTER_CONVERT_TO_RAW (regno, virtual_buffer, raw_buffer);
- use_buffer = REGISTER_RAW_SIZE (regno);
+ if (REGISTER_CONVERTIBLE (regno))
+ {
+ REGISTER_CONVERT_TO_RAW (VALUE_TYPE (fromval), regno,
+ VALUE_CONTENTS (fromval), raw_buffer);
+ use_buffer = REGISTER_RAW_SIZE (regno);
+ }
}
+#endif
switch (VALUE_LVAL (toval))
{
+ VALUE_BITSIZE (toval)
+ HOST_CHAR_BIT - 1)
/ HOST_CHAR_BIT;
- /* If bigger than a LONGEST, we don't handle it correctly,
- but at least avoid corrupting memory. */
+
if (len > sizeof (LONGEST))
- len = sizeof (LONGEST);
+ error ("Can't handle bitfields which don't fit in a %d bit word.",
+ sizeof (LONGEST) * HOST_CHAR_BIT);
read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
buffer, len);
case lval_register:
if (VALUE_BITSIZE (toval))
{
- char buffer[MAX_REGISTER_RAW_SIZE];
+ char buffer[sizeof (LONGEST)];
int len = REGISTER_RAW_SIZE (VALUE_REGNO (toval));
+
+ if (len > sizeof (LONGEST))
+ error ("Can't handle bitfields in registers larger than %d bits.",
+ sizeof (LONGEST) * HOST_CHAR_BIT);
+
+ if (VALUE_BITPOS (toval) + VALUE_BITSIZE (toval)
+ > len * HOST_CHAR_BIT)
+ /* Getting this right would involve being very careful about
+ byte order. */
+ error ("\
+Can't handle bitfield which doesn't fit in a single register.");
+
read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
buffer, len);
modify_field (buffer, value_as_long (fromval),
type = VALUE_TYPE (fromval);
}
- /* FIXME: This loses if fromval is a different size than toval, for
- example because fromval got cast in the REGISTER_CONVERTIBLE case
- above. */
val = allocate_value (type);
memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val);
memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
}
-void
-register_convert_to_virtual (regnum, from, to)
- unsigned char *from;
- unsigned char *to;
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
-}
-
-void
-register_convert_to_raw (regnum, to, from)
- char *to;
- char *from;
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
-}
-
void
z8k_pop_frame ()
{