From patchwork Tue Mar 1 11:09:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pitchumani Sivanupandi X-Patchwork-Id: 11153 Received: (qmail 62897 invoked by alias); 1 Mar 2016 11:09:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 62852 invoked by uid 89); 1 Mar 2016 11:09:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=decreasing, Hx-languages-length:2666 X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.242) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 01 Mar 2016 11:09:48 +0000 Received: from HNOCHT02.corp.atmel.com (10.161.30.162) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Tue, 1 Mar 2016 12:09:42 +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; Tue, 1 Mar 2016 12:09:44 +0100 Date: Tue, 1 Mar 2016 16:39:37 +0530 From: Pitchumani Sivanupandi To: CC: , , , Subject: [patch, avr] Fix argument passing for call Message-ID: <20160301110937.GA3892@CHELT0346> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes When calling function with argument of size more than 8 bytes fails with an error "That operation is not available on integers of more than 8 bytes.". avr-gdb considers only 8 bytes (sizeof(long long)) in case of passing the argument in registers. When the argument is of size more than 8 byte then the utility function to extract bytes failed with the above error. Attached a patch fix this issue. This patch includes the fix discussed here: https://sourceware.org/ml/gdb-patches/2016-02/msg00884.html (Both fixes are in same function and the earlier is not committed) Ran the tests for avr-gdb with internal simulators. No new regressions. If ok, could someone commit please? I do not have commit access. Regards, Pitchumani gdb/ChangeLog 2016-03-01 Pitchumani Sivanupandi * avr-tdep.c (AVR_LAST_ARG_REGNUM): Define. (avr_push_dummy_call): Correct last needed argument register. Write MSB of argument into register and subsequent bytes into other registers in decreasing order. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 597cfb4..088fe51 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,23 +1299,24 @@ 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; - /* Skip a register for odd length args. */ if (len & 1) regnum--; - val = extract_unsigned_integer (contents, len, byte_order); + /* Write MSB of argument into register and subsequent bytes in + decreasing register numbers. */ for (j = 0; j < len; j++) regcache_cooked_write_unsigned - (regcache, regnum--, val >> (8 * (len - j - 1))); + (regcache, regnum--, contents[len - j - 1]); } /* No registers available, push the args onto the stack. */ else