From patchwork Fri Aug 21 22:47:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristiano X-Patchwork-Id: 8386 Received: (qmail 5573 invoked by alias); 21 Aug 2015 22:47:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 5557 invoked by uid 89); 21 Aug 2015 22:47:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=BAYES_05, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: BLU004-OMC2S24.hotmail.com Received: from blu004-omc2s24.hotmail.com (HELO BLU004-OMC2S24.hotmail.com) (65.55.111.99) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Fri, 21 Aug 2015 22:47:57 +0000 Received: from BLU436-SMTP243 ([65.55.111.71]) by BLU004-OMC2S24.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Fri, 21 Aug 2015 15:47:55 -0700 X-TMN: [taUeqmRM+Lj1cfYsnus5qwNCQCP66Pq1] Message-ID: Date: Sat, 22 Aug 2015 00:47:51 +0200 From: Cristiano User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] avr-tdep.c (avr_scan_prologue): minor fix in prologue scanning I use GDB from Eclipse with Avarice to debug AVR microcontrollers. While single stepping (stepi) through the instructions of a normal function prologue, stepping over the sbiw r28, 0x0f instruction, which is near the end of the prologue, causes the following change in the output of backtrace: Before: #0 0x000042b0 in HID_Device_USBTask (HIDInterfaceInfo=0x80b8b8) at ../../LUFA/Drivers/USB/Class/Device/HIDClassDevice.c:157 #1 0x000002e0 in main () at HIDRadio.c:83 After: #0 0x000042b2 in HID_Device_USBTask (HIDInterfaceInfo=0x8000ff) at ../../LUFA/Drivers/USB/Class/Device/HIDClassDevice.c:157 #1 0x00017170 in ?? () Note that the frame #1 is inconsistent. If you now return from frame #0 with the command finish, the target does not stop at the return address at main. Instead, the target starts running and it's necessary to stop it. This is not a big issue and I'm not an expert of the gdb internals but the fix seems easy enough. 2015-08-20 Cristiano De Alti * avr-tdep.c (avr_scan_prologue): minor fix in prologue scanning. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 3b99bd2..32a6540 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -832,25 +832,26 @@ avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, or signal handler functions, which is why we set the prologue type when we saw the beginning of the prologue previously. */ - if (vpc + sizeof (img_sig) < len + if (vpc + sizeof (img_sig) <= len && memcmp (prologue + vpc, img_sig, sizeof (img_sig)) == 0) { + info->size += locals_size; vpc += sizeof (img_sig); } - else if (vpc + sizeof (img_int) < len + else if (vpc + sizeof (img_int) <= len && memcmp (prologue + vpc, img_int, sizeof (img_int)) == 0) { + info->size += locals_size; vpc += sizeof (img_int); } - if (vpc + sizeof (img) < len + if (vpc + sizeof (img) <= len && memcmp (prologue + vpc, img, sizeof (img)) == 0) { + info->size += locals_size; info->prologue_type = AVR_PROLOGUE_NORMAL; vpc += sizeof (img); } - info->size += locals_size; - /* Fall through. */ }