From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4908 invoked by alias); 17 Sep 2007 20:17:53 -0000 Received: (qmail 4899 invoked by uid 22791); 17 Sep 2007 20:17:52 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 17 Sep 2007 20:17:48 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C764D2AA18E for ; Mon, 17 Sep 2007 16:17:46 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ID9nYSjkuPQq for ; Mon, 17 Sep 2007 16:17:46 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 71A3D2A9ECD for ; Mon, 17 Sep 2007 16:17:46 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 62B69E7B58; Mon, 17 Sep 2007 13:17:44 -0700 (PDT) Date: Mon, 17 Sep 2007 20:17:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/ia64] Limit prologue scanning to end of function Message-ID: <20070917201744.GB2598@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OgqxwSJOaUobr8KG" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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 X-SW-Source: 2007-09/txt/msg00236.txt.bz2 --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2033 Hello, This is a local fix that we made a couple of years ago, which we forgot to submit for inclusion, somehow. Basically, it's kind of hard to determine the end of a function prologue on ia64 just by scanning the function code. So the examine_prologue routine in ia64-tdep.c often ends up scanning a bit more code than is necessary. As a consequence, this might cause us to go too far when trying to skip the prologue. To help in that task, we have a routine, called refine_prologue_limit, whose job is to try using the line number information to find a better limit for our function prologue. The problem is that this function needs to handle optimizations where the compiler intermingles the different lines: /* Handle the case in which compiler's optimizer/scheduler has moved instructions into the prologue. We scan ahead in the function looking for address ranges whose corresponding line number is less than or equal to the first one that we found for the function. (It can be less than when the scheduler puts a body instruction before the first prologue instruction.) */ for (i = 2 * max_skip_non_prologue_insns; i > 0 && (lim_pc == 0 || addr < lim_pc); i--) In some cases, the PC range given is larger than the function size. As a result, we end up testing some line numbers that are actually not part of the same routine, and sometimes selecting it (if the line number is smaller). The fix is simply to reduce the initial range to the function end address. 2007-09-17 Joel Brobecker * ia64-tdep.c (refine_prologue_limit): Make sure we don't scan the linetable past the function end. Tested on ia64-linux, no regression. OK to commit? I also suggest this fix for gdb-6.7, since it looks pretty safe. However, I think that the chances of a function whose associated lines are smaller, and yet have a higher PC are relatively small. So perhaps not worth the risk. Thanks, -- Joel --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="refine_limit.diff" Content-length: 724 Index: ia64-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ia64-tdep.c,v retrieving revision 1.159 diff -u -p -r1.159 ia64-tdep.c --- ia64-tdep.c 23 Aug 2007 18:08:35 -0000 1.159 +++ ia64-tdep.c 17 Sep 2007 19:15:51 -0000 @@ -967,6 +967,12 @@ refine_prologue_limit (CORE_ADDR pc, COR { struct symtab_and_line prologue_sal; CORE_ADDR start_pc = pc; + CORE_ADDR end_pc; + + /* The prologue can not possibly go past the function end itself, + so we can already adjust LIM_PC accordingly. */ + if (find_pc_partial_function (pc, NULL, NULL, &end_pc) && end_pc < lim_pc) + lim_pc = end_pc; /* Start off not trusting the limit. */ *trust_limit = 0; --OgqxwSJOaUobr8KG--