Re: SH patch 2 (was Re: [RFA] SH: Deprecate deprecated functions, use new frame interface)

Corinna Vinschen
2003-09-24T11:28:19Z

On Wed, Sep 24, 2003 at 10:43:11AM +0200, Corinna Vinschen wrote:
> On Tue, Sep 23, 2003 at 04:26:15PM -0400, Elena Zannoni wrote:
> > I think so too. But I'd like to see if something can be done for SH
> > similar to the i386_convert_register_p method.
>
> Is that necessary before the patch gets approval or could that be added
> in a follow up step?

I've tested the below patch and the effect is absolut zero with respect to
the store.exp results. What am I doing wrong? It doesn't matter if I
diable the dwarf2 sniffer or not, btw.

Corinna

--- sh-tdep.c.NEW 2003-09-24 12:24:10.000000000 +0200
+++ sh-tdep.c 2003-09-24 13:25:30.000000000 +0200
@@ -2111,6 +2111,58 @@ sh_in_function_epilogue_p (struct gdbarc
return 0;
}

+/* Return nonzero if a value of type TYPE stored in register REGNUM
+ needs any special handling. */
+static int
+sh_convert_register_p (int regnum, struct type *type)
+{
+ if (TYPE_CODE (type) == TYPE_CODE_FLT)
+ return TYPE_LENGTH (type) > 4 && regnum < DR0_REGNUM;
+ return TYPE_LENGTH (type) > 4;
+}
+
+/* Read a value of type TYPE from register REGNUM in frame FRAME, and
+ return its contents in TO. */
+static void
+sh_register_to_value (struct frame_info *frame, int regnum,
+ struct type *type, void *to)
+{
+ int len = TYPE_LENGTH (type);
+ char *buf = to;
+
+ while (len > 0)
+ {
+ get_frame_register (frame, regnum++, buf);
+ if (regnum == 16) /* Normal register overflow */
+ break;
+ if (regnum == 41) /* FP register overflow */
+ break;
+ len -= 4;
+ buf += 4;
+ }
+}
+
+/* Write the contents FROM of a value of type TYPE into register
+ REGNUM in frame FRAME. */
+static void
+sh_value_to_register (struct frame_info *frame, int regnum,
+ struct type *type, const void *from)
+{
+ int len = TYPE_LENGTH (type);
+ const char *buf = from;
+
+ while (len > 0)
+ {
+ put_frame_register (frame, regnum, buf);
+ if (regnum == 16) /* Normal register overflow */
+ break;
+ if (regnum == 41) /* FP register overflow */
+ break;
+ len -= 4;
+ buf += 4;
+ }
+}
+
static gdbarch_init_ftype sh_gdbarch_init;

static struct gdbarch *
@@ -2213,6 +2265,10 @@ sh_gdbarch_init (struct gdbarch_info inf
set_gdbarch_in_function_epilogue_p (gdbarch,
sh_in_function_epilogue_p);

+ set_gdbarch_convert_register_p (gdbarch, sh_convert_register_p);
+ set_gdbarch_register_to_value (gdbarch, sh_register_to_value);
+ set_gdbarch_value_to_register (gdbarch, sh_value_to_register);
+
switch (info.bfd_arch_info->mach)
{