Bug 16832 - Erroneous backtrace on avrxmega architectures
Summary: Erroneous backtrace on avrxmega architectures
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: backtrace (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: ---
Assignee: Pierre Langlois
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-11 08:44 UTC by Pierre Langlois
Modified: 2014-04-11 09:34 UTC (History)
0 users

See Also:
Host:
Target: avr
Build:
Last reconfirmed:


Attachments
Simple test program (52.79 KB, application/x-gzip)
2014-04-11 08:44 UTC, Pierre Langlois
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Langlois 2014-04-11 08:44:14 UTC
Created attachment 7548 [details]
Simple test program

Stack unwinding does not work properly for avrxmega architectures with more than 128k of flash memory.

This is due to GDB not being aware of avrxmega architectures, and defaulting having 2 bytes on the stack for the program counter when devices with more than 128k of memory store it in 3 bytes.

This GDB session was done with the axtenge256a3bu chip, debugged with AVaRice.

~~~
GNU gdb (AVR 8-bit toolchain (built 20140310)) 7.7.50.20140408-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 atxmega-test.elf 
Reading symbols from atxmega-test.elf...done.
(gdb) target remote :4242
Remote debugging using :4242
0x00000000 in __vectors ()
(gdb) b multiply 
Breakpoint 1 at 0x21a: file main.c, line 8.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, multiply (a=3, b=6) at main.c:8
8	  return a * b;
(gdb) bt
#0  multiply (a=3, b=6) at main.c:8
#1  0x0001f000 in ?? ()
(gdb) q
A debugging session is active.

	Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) 
~~~
Comment 1 Pierre Langlois 2014-04-11 08:46:52 UTC
Fixed by commit 9c97a0704e03c662b6afd92032c171fe6714b42d

https://sourceware.org/ml/gdb-patches/2014-04/msg00097.html
Comment 2 Sourceware Commits 2014-04-11 09:34:59 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, gdb-7.7-branch has been updated
       via  999686dbc169a7beb0e7e88f5c76dca12174fdbf (commit)
      from  7456303a042711adee7c0ab3ec76df6e29616c88 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=999686dbc169a7beb0e7e88f5c76dca12174fdbf

commit 999686dbc169a7beb0e7e88f5c76dca12174fdbf
Author: Pierre Langlois <pierre.langlois@embecosm.com>
Date:   Fri Mar 21 19:46:07 2014 +0000

    Erroneous backtrace on AVR.
    
    	PR backtrace/16721
    	PR backtrace/16832
    	* avr-tdep.c (struct gdbarch_tdep): Mention avrxmega in the comment.
    	(avr_gdbarch_init): Add xmega architectures given by bfd_architecture
    	when setting the size of call_length.
    	(avr_scan_prologue): Accept push r1 instruction for small stack
    	allocation.
    	* MAINTAINERS (Write After Approval): Add "Pierre Langlois".

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog   |   11 +++++++++++
 gdb/MAINTAINERS |    1 +
 gdb/avr-tdep.c  |   11 +++++++++--
 3 files changed, 21 insertions(+), 2 deletions(-)