From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23786 invoked by alias); 17 Mar 2004 22:11:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23746 invoked from network); 17 Mar 2004 22:11:19 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 17 Mar 2004 22:11:19 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id C722C2B92; Wed, 17 Mar 2004 15:07:02 -0500 (EST) Message-ID: <4058AFE6.8030609@gnu.org> Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa/mips] Stop backtraces when we've lost the PC References: <20040306231743.GA9379@nevyn.them.org> <404BC4B2.7000100@gnu.org> <20040308032324.GA1325@nevyn.them.org> <20040308154814.GA17012@nevyn.them.org> <20040308202557.GA28874@nevyn.them.org> In-Reply-To: <20040308202557.GA28874@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-03/txt/msg00411.txt.bz2 > { > int low, mid, high; > char *ptr; > + CORE_ADDR pdr_pc; > > low = 0; > high = priv->size / 32; > > + /* First, find the last .pdr entry starting at or before PC. */ A summary here of what the objective is and what / why the follow on code is doing. > do > { > - CORE_ADDR pdr_pc; > - > mid = (low + high) / 2; > > ptr = priv->contents + mid * 32; > pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr); > pdr_pc += ANOFFSET (sec->objfile->section_offsets, > SECT_OFF_TEXT (sec->objfile)); > - if (pdr_pc == startaddr) > + if (pdr_pc == pc) > break; > - if (pdr_pc > startaddr) > + if (pdr_pc > pc) > high = mid; > else > low = mid + 1; > } > while (low != high); Other than that, just an observation that the binary search is [already] pretty messed up. In all likelyhood the test: if (pdr_pc == pc) will never fire and having it gains little if anything (one less iteration VS logN extra compares). Eliminating it means cleaning up the binary search though. Can you attach a fixme to that test indicating that it should be eliminated. I also suspect that STARTADDR's computation can be delayed until it is needed (the latter reference that goes with the "pathological", should no longer occure, I think it has been moved into symbol reading. However, leave that for the moment. Otherwize ok, and way better than the original patch, thanks, Andrew From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23786 invoked by alias); 17 Mar 2004 22:11:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23746 invoked from network); 17 Mar 2004 22:11:19 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 17 Mar 2004 22:11:19 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id C722C2B92; Wed, 17 Mar 2004 15:07:02 -0500 (EST) Message-ID: <4058AFE6.8030609@gnu.org> Date: Wed, 17 Mar 2004 22:11:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa/mips] Stop backtraces when we've lost the PC References: <20040306231743.GA9379@nevyn.them.org> <404BC4B2.7000100@gnu.org> <20040308032324.GA1325@nevyn.them.org> <20040308154814.GA17012@nevyn.them.org> <20040308202557.GA28874@nevyn.them.org> In-Reply-To: <20040308202557.GA28874@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-03.o/txt/msg00411.txt Message-ID: <20040317221100.AzsJe8VGlEI7MQAGZ1_ORxGJDFEfQTkThsf7i8GlUuQ@z> > { > int low, mid, high; > char *ptr; > + CORE_ADDR pdr_pc; > > low = 0; > high = priv->size / 32; > > + /* First, find the last .pdr entry starting at or before PC. */ A summary here of what the objective is and what / why the follow on code is doing. > do > { > - CORE_ADDR pdr_pc; > - > mid = (low + high) / 2; > > ptr = priv->contents + mid * 32; > pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr); > pdr_pc += ANOFFSET (sec->objfile->section_offsets, > SECT_OFF_TEXT (sec->objfile)); > - if (pdr_pc == startaddr) > + if (pdr_pc == pc) > break; > - if (pdr_pc > startaddr) > + if (pdr_pc > pc) > high = mid; > else > low = mid + 1; > } > while (low != high); Other than that, just an observation that the binary search is [already] pretty messed up. In all likelyhood the test: if (pdr_pc == pc) will never fire and having it gains little if anything (one less iteration VS logN extra compares). Eliminating it means cleaning up the binary search though. Can you attach a fixme to that test indicating that it should be eliminated. I also suspect that STARTADDR's computation can be delayed until it is needed (the latter reference that goes with the "pathological", should no longer occure, I think it has been moved into symbol reading. However, leave that for the moment. Otherwize ok, and way better than the original patch, thanks, Andrew