From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12755 invoked by alias); 23 Oct 2009 15:16:49 -0000 Received: (qmail 12637 invoked by uid 22791); 23 Oct 2009 15:16:48 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Oct 2009 15:16:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 7E774290020 for ; Fri, 23 Oct 2009 17:16:40 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ONYSQKS6zRie for ; Fri, 23 Oct 2009 17:16:39 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id D9A7129001F for ; Fri, 23 Oct 2009 17:16:39 +0200 (CEST) From: Tristan Gingold Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Subject: [RFA] fix inferior call for avr Date: Fri, 23 Oct 2009 15:16:00 -0000 Message-Id: <559B017A-7962-4C1E-ABD2-3958DA847906@adacore.com> To: gdb-patches ml Mime-Version: 1.0 (Apple Message framework v1076) X-IsSubscribed: yes 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 X-SW-Source: 2009-10/txt/msg00582.txt.bz2 Hi, there are two issues in avr_push_dummy_call: * avr6 architecture (were PC size is 3 bytes instead of 2) was not correctly handled * the returned value was not correct, which made gdb assertions failed. Ok for trunk ? Tristan. 2009-10-23 Tristan Gingold * avr-tdep.c (avr_push_dummy_call): Handle avr6 architecture. Fix the returned value. Fix style. --- avr-tdep.c 2 Jul 2009 17:25:52 -0000 1.115 +++ avr-tdep.c 23 Oct 2009 15:13:35 -0000 @@ -1181,7 +1181,8 @@ { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int i; - unsigned char buf[2]; + unsigned char buf[3]; + int call_length = gdbarch_tdep (gdbarch)->call_length; CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr); int regnum = AVR_ARGN_REGNUM; struct stack_item *si = NULL; @@ -1219,11 +1220,9 @@ regnum--; val = extract_unsigned_integer (contents, len, byte_order); - for (j=0; j> (8*(len-j-1))); - } + for (j = 0; j < len; j++) + regcache_cooked_write_unsigned + (regcache, regnum--, val >> (8 * (len - j - 1))); } /* No registers available, push the args onto the stack. */ else @@ -1245,17 +1244,23 @@ /* Set the return address. For the avr, the return address is the BP_ADDR. Need to push the return address onto the stack noting that it needs to be in big-endian order on the stack. */ - buf[0] = (return_pc >> 8) & 0xff; - buf[1] = return_pc & 0xff; + for (i = 1; i <= call_length; i++) + { + buf[call_length - i] = return_pc & 0xff; + return_pc >>= 8; + } - sp -= 2; - write_memory (sp + 1, buf, 2); /* Add one since pushes are post decr ops. */ + sp -= call_length; + /* Use 'sp + 1' since pushes are post decr ops. */ + write_memory (sp + 1, buf, call_length); /* Finally, update the SP register. */ regcache_cooked_write_unsigned (regcache, AVR_SP_REGNUM, avr_convert_saddr_to_raw (sp)); - return sp; + /* Return SP value for the dummy frame, where the return address hasn't been + pushed. */ + return sp + call_length; } /* Initialize the gdbarch structure for the AVR's. */