From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4947 invoked by alias); 26 Nov 2010 17:29:59 -0000 Received: (qmail 4759 invoked by uid 22791); 26 Nov 2010 17:29:58 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Nov 2010 17:29:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BEBA62BAC7A for ; Fri, 26 Nov 2010 12:29:51 -0500 (EST) 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 wuqZcEw7LQrB for ; Fri, 26 Nov 2010 12:29:51 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 8DE532BAAB2 for ; Fri, 26 Nov 2010 12:29:51 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id CA1221457E1; Fri, 26 Nov 2010 09:29:42 -0800 (PST) Date: Fri, 26 Nov 2010 17:29:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFA] unexpected multiple location for breakpoint Message-ID: <20101126172942.GK2634@adacore.com> References: <1290474625-1582-1-git-send-email-brobecker@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1290474625-1582-1-git-send-email-brobecker@adacore.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2010-11/txt/msg00460.txt.bz2 > + We start from last to first in our list of PCs, in order to take > + care of the case where 2 entries are associated to the same block: > + When we have one or more lines in the same block, we want to stop > + at the first instruction of that line, hence we want to eliminate > + the highest address. */ > + > + for (i = ret.nelts - 1; i >= 0; i--) > if (blocks[i] != NULL) > - for (j = i+1; j < ret.nelts; ++j) > - if (blocks[j] == blocks[i]) > + for (j = 0; j < ret.nelts; ++j) > + if (j != i && filter[j] && contained_in (blocks[i], blocks[j])) About this patch - Doug and I had a quick talk about on IRC, and one of the things I said was that the items in the SAL list should be ordered by ascending PC. I'm not sure that's true anymore. This is true within a linetable, but the array is a collection of entries for potentially more than 1 unit. So that assumption was wrong. However, I wonder if that makes any difference at all in our case: If we have a "contained-in" relationship between two entries, then the first of the two entries necessarily has a lower PC than the second one. The one scenario that Doug and I identified which my patch probably does not handle well is the following case: block1: block2: .line N end block2 .line N end block1 If the user tries to break on line N, what should we do? With the current approach, we expect GDB to select the second entry only. This is not optimal, because we probably should try to break on the entry with the lowest address if we can. But just breaking on the first one runs the risk of never stopping - this may happen if entry in block2 is conditional. So we determined that we should select both line entries in that case. This is achieved by reducing the iteration range for the inner for loop to [0, i[. I will work on submitting a patch with that change and additional comments ASAP. -- Joel