From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4808 invoked by alias); 18 Mar 2014 17:53:37 -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 4798 invoked by uid 89); 18 Mar 2014 17:53:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-wi0-f170.google.com Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 18 Mar 2014 17:53:34 +0000 Received: by mail-wi0-f170.google.com with SMTP id bs8so2985488wib.1 for ; Tue, 18 Mar 2014 10:53:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type; bh=CC3FDEuU2+Gg0Zw4eAY7X3U2zj4+Pgr5Y77JcgfY/UI=; b=Cs7hEBoJ9x54iAgaG4a3Ay+DuOs/IW4PnHRABfSYKVLXN3AhMvGtk2mUNT6vAP6WbI mSO0Px62XlPT5i8fM1DDSPcCBuMUFNY2N1vqpCAAP38ixVXSHhHrK2SuB8wnTgQDYW+e nCZoY3PcQ1h7oAk5NC/I91F3YhRI1FsH6Tlui+C0bXL2kcoWMftj9XXTVnXgkqj/dPan K1VspMzBrq1sRFZQLFKy6jHte/H9wS55PqrEU6gaLlYRXdOVp4Ru1OgIrCAH+Je+m2JM a2ZK5nkH9v508NkN5b9ayZYa5K9Td0t7VistdmXaTEo1w/9oA1rGGRUyj98lUmOlzG2a o/KQ== X-Gm-Message-State: ALoCoQnFq3VCsOBpZddrTg+fxTRDXaEGanDgM2iZFu7acU7RYDwpKTwNQ9me56VNOVZLAp4Hb2sy X-Received: by 10.194.9.99 with SMTP id y3mr2883492wja.60.1395165211767; Tue, 18 Mar 2014 10:53:31 -0700 (PDT) Received: from [192.168.0.134] (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by mx.google.com with ESMTPSA id t6sm36026939wix.4.2014.03.18.10.53.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 10:53:30 -0700 (PDT) Message-ID: <53288819.7080903@embecosm.com> Date: Tue, 18 Mar 2014 17:53:00 -0000 From: Pierre Langlois User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH][PR/backtrace 16721] Fix erroneous backtrace on AVR Content-Type: multipart/mixed; boundary="------------030809030506060702010500" X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00425.txt.bz2 This is a multi-part message in MIME format. --------------030809030506060702010500 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2585 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. Best, Pierre 2014-03-18 Pierre Langlois * 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 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: . 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=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) --------------030809030506060702010500 Content-Type: text/x-patch; name="pr-16721.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr-16721.patch" Content-length: 494 diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 6e58f04..7fb16d1 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -720,7 +720,7 @@ avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, info->size += gdbarch_tdep (gdbarch)->call_length; vpc += 2; } - else if (insn == 0x920f) /* push r0 */ + else if (insn == 0x920f || insn == 0x921f) /* push r0 or push r1 */ { info->size += 1; vpc += 2; --------------030809030506060702010500--