From: Tristan Gingold <gingold@adacore.com>
To: Pierre Langlois <pierre.langlois@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][PR/backtrace 16721] Fix erroneous backtrace on AVR
Date: Wed, 19 Mar 2014 08:00:00 -0000 [thread overview]
Message-ID: <35ED47A4-C2C0-4F94-B86D-1D2A2DA38DD6@adacore.com> (raw)
In-Reply-To: <53288819.7080903@embecosm.com>
On 18 Mar 2014, at 18:53, Pierre Langlois <pierre.langlois@embecosm.com> wrote:
> Hi all,
>
> Looking at stack unwinding on AVR, I noticed the current frame was not always correctly
> detected from the function prologue.
>
> 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).
>
> --> push the old frame pointer
> push r28
> push r29
>
> --> allocate new space
> rcall .+0
> push r1
>
> --> move fp <- sp
> in r28, 0x3d
> in r29, 0x3e
>
> GCC uses "rcall .+0" and "push r1" to adjust the stack pointer, "rcall" pushing
> automatically 2 or 3 bytes on the stack, depending on the target.
>
> GDB should scan this prologue and find out the size of the frame but it is incorrect by one
> because it expects "push r0" and not "push r1".
>
> I believe this register was changed in GCC withcommit 915f904be.
Looks good to me.
Tristan (as former AVR maintainer)
>
> Best,
>
> Pierre
>
> 2014-03-18 Pierre Langlois <pierre.langlois@embecosm.com>
>
> * avr-tdep.c (avr_scan_prologue): Accept push r1 instruction for small
> stack allocation.
>
> -----------------------------------------------------------------------------------------
>
> 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 <http://gnu.org/licenses/gpl.html>
> 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=x86_64-unknown-linux-gnu --target=avr".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.atmel.com>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> 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=25, b=8) 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.
>
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0x00000116 in multiply (a=25, b=8) at main.c:4
> 4 return a * b;
> (gdb) bt
> #0 0x00000116 in multiply (a=25, b=8) at main.c:4
> #1 0x01e00000 in ?? ()
> (gdb) q
> A debugging session is active.
>
> Inferior 1 [Remote target] will be killed.
>
> Quit anyway? (y or n)
>
> <pr-16721.patch>
next prev parent reply other threads:[~2014-03-19 8:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 17:53 Pierre Langlois
2014-03-19 8:00 ` Tristan Gingold [this message]
2014-03-19 12:34 ` Joel Brobecker
2014-03-21 13:23 ` Pierre Langlois
2014-03-21 17:20 ` Joel Brobecker
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=35ED47A4-C2C0-4F94-B86D-1D2A2DA38DD6@adacore.com \
--to=gingold@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=pierre.langlois@embecosm.com \
/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