From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1490 invoked by alias); 19 Mar 2014 08:00:49 -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 1478 invoked by uid 89); 19 Mar 2014 08:00:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 19 Mar 2014 08:00:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BFBDC2706C35; Wed, 19 Mar 2014 09:00:43 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xmp71WJJtmaZ; Wed, 19 Mar 2014 09:00:43 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 9EA282706C33; Wed, 19 Mar 2014 09:00:43 +0100 (CET) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: [PATCH][PR/backtrace 16721] Fix erroneous backtrace on AVR From: Tristan Gingold In-Reply-To: <53288819.7080903@embecosm.com> Date: Wed, 19 Mar 2014 08:00:00 -0000 Cc: gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <35ED47A4-C2C0-4F94-B86D-1D2A2DA38DD6@adacore.com> References: <53288819.7080903@embecosm.com> To: Pierre Langlois X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00440.txt.bz2 On 18 Mar 2014, at 18:53, Pierre Langlois wr= ote: > Hi all, >=20 > Looking at stack unwinding on AVR, I noticed the current frame was not al= ways correctly > detected from the function prologue. >=20 > This bug occurs only with the following prologue, referred to as "Method = 2: Adjust stack pointer" > in GCC: gcc/config/avr/avr.c (avr_prologue_setup_frame). >=20 > --> push the old frame pointer > push r28 > push r29 >=20 > --> allocate new space > rcall .+0 > push r1 >=20 > --> move fp <- sp > in r28, 0x3d > in r29, 0x3e >=20 > GCC uses "rcall .+0" and "push r1" to adjust the stack pointer, "rcall" p= ushing > automatically 2 or 3 bytes on the stack, depending on the target. >=20 > GDB should scan this prologue and find out the size of the frame but it i= s incorrect by one > because it expects "push r0" and not "push r1". >=20 > I believe this register was changed in GCC withcommit 915f904be. Looks good to me. Tristan (as former AVR maintainer) >=20 > Best, >=20 > Pierre >=20 > 2014-03-18 Pierre Langlois >=20 > * avr-tdep.c (avr_scan_prologue): Accept push r1 instruction for sma= ll > stack allocation. >=20 > -------------------------------------------------------------------------= ---------------- >=20 > GNU gdb (AVR 8-bit toolchain (built 20140310)) 7.7.50.20140318-cvs > Copyright (C) 2014 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "--host=3Dx86_64-unknown-linux-gnu --target=3D= avr". > Type "show configuration" for configuration details. > For bug reporting instructions, please see: > . > Find the GDB manual and other documentation resources online at: > . > For help, type "help". > Type "apropos word" to search for commands related to "word". > (gdb) file atmega-test.elf > Reading symbols from atmega-test.elf...done. > (gdb) target remote :51000 > Remote debugging using :51000 > 0x00000116 in multiply (a=3D25, b=3D8) at main.c:4 > 4 return a * b; > (gdb) monitor reset > (gdb) load > Loading section .text, size 0x1a4 lma 0x0 > Start address 0x0, load size 420 > Transfer rate: 3360 bits in <1 sec, 210 bytes/write. > (gdb) b multiply > Breakpoint 1 at 0x114: file main.c, line 4. > (gdb) c > Continuing. >=20 > Program received signal SIGTRAP, Trace/breakpoint trap. > 0x00000116 in multiply (a=3D25, b=3D8) at main.c:4 > 4 return a * b; > (gdb) bt > #0 0x00000116 in multiply (a=3D25, b=3D8) at main.c:4 > #1 0x01e00000 in ?? () > (gdb) q > A debugging session is active. >=20 > Inferior 1 [Remote target] will be killed. >=20 > Quit anyway? (y or n) >=20 >