public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] PowerPC, function ppc64_sysv_abi_return_value add missing return value convention
@ 2022-11-14 21:23 Carl Love
  0 siblings, 0 replies; only message in thread
From: Carl Love @ 2022-11-14 21:23 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24b27e5e9b6bf5a37fb39dfca151722bb801cbaa

commit 24b27e5e9b6bf5a37fb39dfca151722bb801cbaa
Author: Carl Love <cel@us.ibm.com>
Date:   Mon Nov 14 16:22:11 2022 -0500

    PowerPC, function ppc64_sysv_abi_return_value add missing return value convention
    
    This patch address five testcase failures in gdb.cp/non-trivial-retval.exp.
    The following commit resulted in the five testcases failures on PowerPC.
    The value returned by the function is being reported incorrectly.
    
      commit b1718fcdd1d2a5c514f8ee504ba07fb3f42b8608
      Author: Andrew Burgess <aburgess@redhat.com>
      Date:   Mon Dec 13 16:56:16 2021 +0000
    
          gdb: on x86-64 non-trivial C++ objects are returned in memory
    
          Fixes PR gdb/28681.  It was observed that after using the `finish`
          command an incorrect value was displayed in some cases.  Specifically,
          this behaviour was observed on an x86-64 target.
    
    The function:
    
      enum return_value_convention
      ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
                                   struct type *valtype, struct regcache *regcache,
                                   gdb_byte *readbuf, const gdb_byte *writebuf)
    
    should return RETURN_VALUE_STRUCT_CONVENTION if the valtype->code() is
    TYPE_CODE_STRUCT and if the language_pass_by_reference is not
    trivially_copyable.
    
    This patch adds the needed code to return the value
    RETURN_VALUE_STRUCT_CONVENTION in this case.
    
    With this patch, the five test cases still fail but with the message "Value
    returned has type: A. Cannot determine contents".  The PowerPC ABI stores
    the address of the buffer containing the function return value in register
    r3 on entry to the function.  However, the PowerPC ABI does not guarentee
    that r3 will not be modified in the function.  So when the function returns,
    the return buffer address cannot be reliably obtained from register r3.
    Thus the message "Cannot determine contents" is appropriate in this case.

Diff:
---
 gdb/ppc-sysv-tdep.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index d7f05ddc6b4..450162dd46e 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -2099,6 +2099,10 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
       return RETURN_VALUE_REGISTER_CONVENTION;
     }
 
+  if (!language_pass_by_reference (valtype).trivially_copyable
+      && valtype->code () == TYPE_CODE_STRUCT)
+    return RETURN_VALUE_STRUCT_CONVENTION;
+
   /* In the ELFv2 ABI, aggregate types of up to 16 bytes are
      returned in registers r3:r4.  */
   if (tdep->elf_abi == POWERPC_ELF_V2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-14 21:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 21:23 [binutils-gdb] PowerPC, function ppc64_sysv_abi_return_value add missing return value convention Carl Love

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).