m68k-elf return value registers
Vladimir Prus
vladimir@codesourcery.com
Sat Jun 11 18:50:00 GMT 2011
On Tuesday, April 26, 2011 15:37:17 Vladimir Prus wrote:
> On Tuesday, January 25, 2011 19:49:15 Vladimir Prus wrote:
> > How about this split:
> >
> >
> > - Register used to return structures
> > - Logic used to decide whether a structure is returned in register
> > - Adjusting register used for returning pointers
>
> Here's a patch to adjust the register for returning pointers.
> Comments? Note that I still not able to test on classic m68k,
> therefore eye inspection or testing there would be still required.
Mark,
were you able to take a look at this patch, as well as two others,
into which my original patch has been split?
Thanks,
--
Vladimir Prus
CodeSourcery / Mentor Graphics
+7 (812) 677-68-40
> --
> Vladimir Prus
> Mentor Graphics
> +7 (812) 677-68-40
> ptr_value_regnum.diff
> commit 607918e383bd3ba7f84ce5f3a1255da5ac5ee401
> Author: Vladimir Prus <vladimir@codesourcery.com>
> Date: Tue Apr 26 15:31:18 2011 +0400
>
> Make pointer return value be right on bare metal.
>
> * m68k-tdep.h (struct gdbarch_tdep): New field
> ptr_value_regnum.
> * m68k-tdep.c (m68k_svr4_extract_return_value): Use
> tdep->ptr_value_regnum.
> (m68k_svr4_store_return_value): Likewise.
> (m68k_svr4_init_abi): Set ptr_value_regnum to %a0.
> (m68k_gdbarch_init): Set ptr_value_regnum to %d0.
> * m68kbsd-tdep.c (m68kbsd_aout_init_abi): Set ptr_value_regnum
> to %a0.
>
> diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
> index 6d7a824..c6ae36d 100644
> --- a/gdb/m68k-tdep.c
> +++ b/gdb/m68k-tdep.c
> @@ -329,7 +329,7 @@ m68k_svr4_extract_return_value (struct type *type,
> struct regcache *regcache, convert_typed_floating (buf, fpreg_type,
> valbuf, type);
> }
> else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
> - regcache_raw_read (regcache, M68K_A0_REGNUM, valbuf);
> + regcache_raw_read (regcache, tdep->ptr_value_regnum, valbuf);
> else
> m68k_extract_return_value (type, regcache, valbuf);
> }
> @@ -371,10 +371,7 @@ m68k_svr4_store_return_value (struct type *type,
> struct regcache *regcache, regcache_raw_write (regcache, M68K_FP0_REGNUM,
> buf);
> }
> else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
> - {
> - regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf);
> - regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf);
> - }
> + regcache_raw_write (regcache, tdep->ptr_value_regnum, valbuf);
> else
> m68k_store_return_value (type, regcache, valbuf);
> }
> @@ -1065,6 +1062,8 @@ m68k_svr4_init_abi (struct gdbarch_info info, struct
> gdbarch *gdbarch)
> /* SVR4 uses %a0 instead of %a1. */
> tdep->struct_value_regnum = M68K_A0_REGNUM;
> +
> + tdep->ptr_value_regnum = M68K_A0_REGNUM;
> }
>
>
> @@ -1239,6 +1238,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches) set_gdbarch_push_dummy_call (gdbarch,
> m68k_push_dummy_call);
> set_gdbarch_return_value (gdbarch, m68k_return_value);
>
> + tdep->ptr_value_regnum = M68K_D0_REGNUM;
>
> /* Disassembler. */
> set_gdbarch_print_insn (gdbarch, print_insn_m68k);
> diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h
> index 596a8cb..3ea7f24 100644
> --- a/gdb/m68k-tdep.h
> +++ b/gdb/m68k-tdep.h
> @@ -83,6 +83,9 @@ struct gdbarch_tdep
> /* Convention for returning structures. */
> enum struct_return struct_return;
>
> + /* Register in which pointers are returned. */
> + int ptr_value_regnum;
> +
> /* Convention for returning floats. zero in int regs, non-zero in
> float. */ int float_return;
>
> diff --git a/gdb/m68kbsd-tdep.c b/gdb/m68kbsd-tdep.c
> index 81e34e9..3b5f5e0 100644
> --- a/gdb/m68kbsd-tdep.c
> +++ b/gdb/m68kbsd-tdep.c
> @@ -213,11 +213,12 @@ m68kbsd_aout_init_abi (struct gdbarch_info info,
> struct gdbarch *gdbarch) m68kbsd_init_abi (info, gdbarch);
>
> tdep->struct_return = reg_struct_return;
> + tdep->ptr_value_regnum = M68K_A0_REGNUM;
>
> tramp_frame_prepend_unwinder (gdbarch, &m68kobsd_sigtramp);
> }
>
> -/* NetBSD ELF. */
> +/* OpenBSD and NetBSD ELF. */
>
> static void
> m68kbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
More information about the Gdb-patches
mailing list