From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18015 invoked by alias); 25 Feb 2016 12:35:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17997 invoked by uid 89); 25 Feb 2016 12:35:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50,SPF_PASS autolearn=ham version=3.3.2 spammy=callfuncsexp, callfuncs.exp, UD:callfuncs.exp, bfd_byte X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.243) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 25 Feb 2016 12:34:59 +0000 Received: from HNOCHT02.corp.atmel.com (10.161.30.162) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 25 Feb 2016 13:34:49 +0100 Received: from CHELT0346 (10.161.30.18) by HNOCHT02.corp.atmel.com (10.161.30.162) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 25 Feb 2016 13:34:54 +0100 Date: Thu, 25 Feb 2016 12:35:00 -0000 From: Pitchumani Sivanupandi To: Subject: [patch, avr] Fix incorrect argument register for push dummy call Message-ID: <20160225123448.GA10608@CHELT0346> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00780.txt.bz2 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Content-length: 631 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 * avr-tdep.c (AVR_LAST_ARG_REGNUM): Define. (avr_push_dummy_call): Correct last needed argument register. --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="avr-last-argument-register-fix.patch" Content-length: 1308 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; --HlL+5n6rz5pIUxbD--