public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] Use entry values for 32-bit PPC struct return
Date: Tue, 14 Mar 2023 07:37:18 -0600	[thread overview]
Message-ID: <20230314-submit-ppc-finish-fixes-v1-3-5f2f461b52f8@adacore.com> (raw)
In-Reply-To: <20230314-submit-ppc-finish-fixes-v1-0-5f2f461b52f8@adacore.com>

AdaCore has a local patch for PPC "finish", but last year, Ulrich
Weigand pointed out that this patch was incorrect.  It may work for
simple functions like the one in the internal test, but nothing
guarantees that r3 will be preserved by the callee, so checking r3 on
exit is not always correct.

This patch fixes the problem using the same approach as PPC64: use the
entry value of r3, if available.  Ulrich confirmed this matches the
PPC32 ABI.
---
 gdb/ppc-sysv-tdep.c | 3 +--
 gdb/ppc-tdep.h      | 4 +++-
 gdb/rs6000-tdep.c   | 3 +--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index ab859fbe143..66630793e86 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -2159,8 +2159,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
 }
 
 CORE_ADDR
-ppc64_sysv_get_return_buf_addr (struct type *val_type,
-				frame_info_ptr cur_frame)
+ppc_sysv_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame)
 {
   /* The PowerPC ABI specifies aggregates that are not returned by value
      are returned in a storage buffer provided by the caller.  The
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index fe41baef149..3c7948cc4ba 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -175,7 +175,9 @@ extern void ppc_collect_vsxregset (const struct regset *regset,
 				  const struct regcache *regcache,
 				  int regnum, void *vsxregs, size_t len);
 
-extern CORE_ADDR ppc64_sysv_get_return_buf_addr (type*, frame_info_ptr);
+/* Implementation of the gdbarch get_return_buf_addr hook.  */
+
+extern CORE_ADDR ppc_sysv_get_return_buf_addr (type*, frame_info_ptr);
 
 /* Private data that this module attaches to struct gdbarch.  */
 
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index d1a16b3430b..16adefb9f9b 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -8265,12 +8265,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (wordsize == 8)
     {
       set_gdbarch_return_value (gdbarch, ppc64_sysv_abi_return_value);
-      set_gdbarch_get_return_buf_addr (gdbarch,
-				       ppc64_sysv_get_return_buf_addr);
       set_gdbarch_update_call_site_pc (gdbarch, ppc64_update_call_site_pc);
     }
   else
     set_gdbarch_return_value (gdbarch, ppc_sysv_abi_return_value);
+  set_gdbarch_get_return_buf_addr (gdbarch, ppc_sysv_get_return_buf_addr);
 
   /* Set lr_frame_offset.  */
   if (wordsize == 8)

-- 
2.39.1


  parent reply	other threads:[~2023-03-14 13:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 13:37 [PATCH 0/3] PPC/PPC64 "finish" fixes Tom Tromey
2023-03-14 13:37 ` [PATCH 1/3] Handle function descriptors in call_site_target Tom Tromey
2023-03-14 13:37 ` [PATCH 2/3] Handle erroneous DW_AT_call_return_pc Tom Tromey
2023-03-24 16:10   ` Tom Tromey
2023-03-14 13:37 ` Tom Tromey [this message]
2023-04-21 13:40 ` [PATCH 0/3] PPC/PPC64 "finish" fixes Tom Tromey

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=20230314-submit-ppc-finish-fixes-v1-3-5f2f461b52f8@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).