[5/9] Restrict m68k_convert_register_p
Commit Message
Simon Marchi <simon.marchi@polymtl.ca> writes:
> Perhaps that can be replaced with a gdb_assert (TYPE_CODE (type) ==
> TYPE_CODE_FLT) ? Or maybe it would be more appropriate to put such
> asserts on convert_typed_floating ?
>
> Likewise in the following patches, the if (TYPE_LENGTH (valtype) == 4)
> check in alpha could be replaced with gdb_assert (TYPE_LENGTH
> (valtype) == 4).
The assert was in my code, but removed before I post the patches,
because I am not confident putting such strong assert to the code that I
am very familiar with. I am fine to add it back.
convert_typed_floating calls floatformat_from_type which asserts that
its type code is TYPE_CODE_FLT.
@@ -188,6 +188,8 @@ m68k_convert_register_p (struct gdbarch *gdbarch,
if (!gdbarch_tdep (gdbarch)->fpregs_present)
return 0;
return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
+ /* We only support floating-point values. */
+ && TYPE_CODE (type) == TYPE_CODE_FLT
&& type != register_type (gdbarch, M68K_FP0_REGNUM));
}
@@ -203,16 +205,7 @@ m68k_register_to_value (struct frame_info *frame, int regnum,
struct type *fpreg_type = register_type (get_frame_arch (frame),
M68K_FP0_REGNUM);
- /* We only support floating-point values. */
- if (TYPE_CODE (type) != TYPE_CODE_FLT)
- {
- warning (_("Cannot convert floating-point register value "
- "to non-floating-point type."));
- *optimizedp = *unavailablep = 0;
- return 0;
- }
-
- /* Convert to TYPE. */
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
/* Convert to TYPE. */
if (!get_frame_register_bytes (frame, regnum, 0, TYPE_LENGTH (type),