Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pitchumani Sivanupandi <pitchumani.s@atmel.com>
To: <gdb-patches@sourceware.org>
Subject: [patch, avr] Fix incorrect argument register for push dummy call
Date: Thu, 25 Feb 2016 12:35:00 -0000	[thread overview]
Message-ID: <20160225123448.GA10608@CHELT0346> (raw)

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

There are few failures for avr-gdb in callfuncs.exp. These failures are
due to the incorrect argument passing in case of push dummy call. The
last argument register is calculated incorrectly that caused this issue.

Attached patch fixes the calculation so that the push dummy call aligns
with the code generated by avr-gcc.

No new regressions found when tested with internal simulator.

If ok, could someone commit please?

Regards,
Pitchumani

gdb/ChangeLog

2016-02-25  Pitchumani Sivanupandi  <pitchumani.s@atmel.com>

	* avr-tdep.c (AVR_LAST_ARG_REGNUM): Define.
	(avr_push_dummy_call): Correct last needed argument register.

[-- Attachment #2: avr-last-argument-register-fix.patch --]
[-- Type: text/plain, Size: 1308 bytes --]

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 597cfb4..18ecfe4 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -111,6 +111,7 @@ enum
 
   AVR_ARG1_REGNUM = 24,         /* Single byte argument */
   AVR_ARGN_REGNUM = 25,         /* Multi byte argments */
+  AVR_LAST_ARG_REGNUM = 8,      /* Last argument register */
 
   AVR_RET1_REGNUM = 24,         /* Single byte return value */
   AVR_RETN_REGNUM = 25,         /* Multi byte return value */
@@ -1298,12 +1299,14 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       const bfd_byte *contents = value_contents (arg);
       int len = TYPE_LENGTH (type);
 
-      /* Calculate the potential last register needed.  */
-      last_regnum = regnum - (len + (len & 1));
+      /* Calculate the potential last register needed.
+         E.g. For length 2, registers regnum and regnum-1 (say 25 and 24)
+         shall be used. So, last needed register will be regnum-1(24).  */
+      last_regnum = regnum - (len + (len & 1)) + 1;
 
       /* If there are registers available, use them.  Once we start putting
          stuff on the stack, all subsequent args go on stack.  */
-      if ((si == NULL) && (last_regnum >= 8))
+      if ((si == NULL) && (last_regnum >= AVR_LAST_ARG_REGNUM))
         {
           ULONGEST val;
 

             reply	other threads:[~2016-02-25 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 12:35 Pitchumani Sivanupandi [this message]
2016-02-26 14:15 ` Luis Machado
2016-02-29  6:25   ` Sivanupandi, Pitchumani

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=20160225123448.GA10608@CHELT0346 \
    --to=pitchumani.s@atmel.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