From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13467 invoked by alias); 17 Jan 2011 18:47:18 -0000 Received: (qmail 13457 invoked by uid 22791); 17 Jan 2011 18:47:17 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Jan 2011 18:47:12 +0000 Received: from mailhost3.vmware.com (mailhost3.vmware.com [10.16.27.45]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 0691C38001; Mon, 17 Jan 2011 10:47:09 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost3.vmware.com (Postfix) with ESMTP id C8218CD96B; Mon, 17 Jan 2011 10:47:07 -0800 (PST) Message-ID: <4D348EAB.5040304@vmware.com> Date: Mon, 17 Jan 2011 20:25:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: Joel Brobecker CC: "gdb-patches@sourceware.org" Subject: Re: [RFA/commit/powerpc] breakpoint inserted past function end References: <1294959871-12637-1-git-send-email-brobecker@adacore.com> In-Reply-To: <1294959871-12637-1-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2011-01/txt/msg00369.txt.bz2 This seems reasonable to me. Joel Brobecker wrote: > On powerpc, the prologue scanner reads instruction after instruction, > and just skips instructions that do not affect a frame. This means > that it does not stop if if finds and unexpected instruction (which > could possibly happen with optimization, I presume). To avoid scanning > too many instructions, it tries to establish an upper limit. > > The upper limit is first computed using the debugging (line) info, > but if that fails, it falls back on an arbitrary 100 bytes (or 25 > instructions). The problem is that, if the function is shorter than > those 25 instructions, we run the risk of skipping the entire function > and returning a PC that's outside our function. > > In the event where we can find a symbol for a given PC (and therefore > can determine function start and end addresses), but cannot find an > upper limit using skip_prologue_using_sal, then we can at least limit > make sure that the 25 instructions do not put us beyour our function. > If it does, then further reduce the upper-limit to the end of the function. > > gdb/ChangeLog: > > * rs6000-tdep.c (rs6000_skip_prologue): Make sure that the prologue > upper limit address is not greater than the function end address > when the upper limit could not be computed using the debugging > info. > > This seems fairly straightforward, but I couldn't run the testsuite > (only the AdaCore testsuite) because I don't have access to a powerpc > machine running an OS that we can run the testsuite on (I ran the AdaCore > testsuite on VxWorks). > > I'll commit in a few days, pending comments. > > --- > gdb/rs6000-tdep.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c > index c16e933..9832b5b 100644 > --- a/gdb/rs6000-tdep.c > +++ b/gdb/rs6000-tdep.c > @@ -2090,12 +2090,12 @@ static CORE_ADDR > rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > { > struct rs6000_framedata frame; > - CORE_ADDR limit_pc, func_addr; > + CORE_ADDR limit_pc, func_addr, func_end_addr = 0; > > /* See if we can determine the end of the prologue via the symbol table. > If so, then return either PC, or the PC after the prologue, whichever > is greater. */ > - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) > + if (find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr)) > { > CORE_ADDR post_prologue_pc > = skip_prologue_using_sal (gdbarch, func_addr); > @@ -2113,6 +2113,11 @@ rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > if (limit_pc == 0) > limit_pc = pc + 100; /* Magic. */ > > + /* Do not allow limit_pc to be past the function end, if we know > + where that end is... */ > + if (func_end_addr && limit_pc > func_end_addr) > + limit_pc = func_end_addr; > + > pc = skip_prologue (gdbarch, pc, limit_pc, &frame); > return pc; > }