From: Vladimir Prus <vladimir@codesourcery.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sources.redhat.com
Subject: Re: m68k-elf return value registers
Date: Sat, 11 Jun 2011 18:50:00 -0000 [thread overview]
Message-ID: <201106112249.53362.vladimir@codesourcery.com> (raw)
In-Reply-To: <201104261537.17424.vladimir@codesourcery.com>
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;
> }
> \f
>
> @@ -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)
next prev parent reply other threads:[~2011-06-11 18:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 23:04 Vladimir Prus
2011-01-14 11:00 ` Mark Kettenis
2011-01-25 17:01 ` Vladimir Prus
2011-04-26 11:37 ` Vladimir Prus
2011-06-11 18:50 ` Vladimir Prus [this message]
2011-04-26 11:50 ` Vladimir Prus
2011-04-26 11:58 ` Vladimir Prus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201106112249.53362.vladimir@codesourcery.com \
--to=vladimir@codesourcery.com \
--cc=gdb-patches@sources.redhat.com \
--cc=mark.kettenis@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox