public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ulrich Weigand <uweigand@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix call functions command bug in 64 bits programs for AIX
Date: Thu, 17 Nov 2022 12:51:52 +0000 (GMT)	[thread overview]
Message-ID: <20221117125152.9B4E139960C0@sourceware.org> (raw)

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

commit 7aae1a86b30185224554d450e233ca967359b75d
Author: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date:   Thu Nov 17 13:50:35 2022 +0100

    Fix call functions command bug in 64 bits programs for AIX
    
    In AIX for 64 bit programs we need to zero extend variables
    of integer or enum or char data type.
    
    Otherwise a zero will get dumped in the register as we memset
    our word to 0 and we copy non zero extended contents to the cache.

Diff:
---
 gdb/rs6000-aix-tdep.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index d47974b51d1..3efafbd10ab 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -400,7 +400,15 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	  gdb_byte word[PPC_MAX_REGISTER_SIZE];
 
 	  memset (word, 0, reg_size);
-	  memcpy (word, value_contents (arg).data (), len);
+	  if (type->code () == TYPE_CODE_INT
+	     || type->code () == TYPE_CODE_ENUM
+	     || type->code () == TYPE_CODE_BOOL
+	     || type->code () == TYPE_CODE_CHAR)
+	    /* Sign or zero extend the "int" into a "word".  */
+	    store_unsigned_integer (word, reg_size, byte_order,
+				    unpack_long (type, value_contents (arg).data ()));
+	  else
+	    memcpy (word, value_contents (arg).data (), len);
 	  regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word);
 	}
       ++argno;

                 reply	other threads:[~2022-11-17 12:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221117125152.9B4E139960C0@sourceware.org \
    --to=uweigand@sourceware.org \
    --cc=gdb-cvs@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).