From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27300 invoked by alias); 13 Feb 2010 23:56:49 -0000 Received: (qmail 27289 invoked by uid 22791); 13 Feb 2010 23:56:48 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-ew0-f223.google.com (HELO mail-ew0-f223.google.com) (209.85.219.223) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Feb 2010 23:56:43 +0000 Received: by ewy23 with SMTP id 23so263847ewy.4 for ; Sat, 13 Feb 2010 15:56:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.213.58.138 with SMTP id g10mr2313697ebh.85.1266105401223; Sat, 13 Feb 2010 15:56:41 -0800 (PST) Date: Sat, 13 Feb 2010 23:56:00 -0000 Message-ID: <6a6f635a1002131556sc428adfu6033489930eca7b6@mail.gmail.com> Subject: a review and questions on avr_scan_prologue() From: =?UTF-8?B?UGV0ciBIbHV6w61u?= To: gdb@sourceware.org Cc: Tristan Gingold Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00107.txt.bz2 Hello I took a look at avr-tdep.c [1] and I found some places which are either bug or are not clear to me. Here it goes: else if (len >= sizeof (img) - 2 && memcmp (img + 2, prologue, sizeof (img) - 2) == 0) { info->prologue_type = AVR_PROLOGUE_SIG; vpc += sizeof (img) - 2; info->saved_regs[AVR_SREG_REGNUM].addr = 3; info->saved_regs[0].addr = 2; info->saved_regs[1].addr = 1; - info->size += 3; + info->size += 2; } Since the "img + 2" skips "push r1" I believe the scan should record smaller size. if (vpc >= AVR_MAX_PROLOGUE_SIZE) fprintf_unfiltered (gdb_stderr, _("Hit end of prologue while scanning pushes\n")); This condition is never true due to a way `len' is calculated and `vpc' always being less than `len'. (This is not a bug but per se but the author might expected something what is not true.) else if (insn == 0x920f) /* push r0 */ { info->size += 1; vpc += 2; } The condition is never true because of the preceding "Scan pushes (saved registers)" loop's exit condition. Also: The avr_scan_prologue()'s recognizes several well-known prologues. Is there a reason why it does not use the general prologue analysis algorithm as described in the documentation [2]? I think universal prologue analysis is quite easy with AVR arch. The code might be shorter (though less clear). I might try to write the code if you are interested. (The current prologue scan code chokes on hand-crafted assembly.) [1] http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/avr-tdep.c?cvsroot=src [2] http://sources.redhat.com/gdb/current/onlinedocs/gdbint/Algorithms.html -- Petr Hluzin