From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81129 invoked by alias); 28 Mar 2018 04:53:44 -0000 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 Received: (qmail 81118 invoked by uid 89); 28 Mar 2018 04:53:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Mar 2018 04:53:40 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 6C1BD42592 for ; Tue, 27 Mar 2018 23:53:39 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 135ffCNcdz11g135ffmWQD; Tue, 27 Mar 2018 23:53:39 -0500 Received: from 174-29-48-109.hlrn.qwest.net ([174.29.48.109]:50402 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1f135e-002BJh-U2; Tue, 27 Mar 2018 23:53:39 -0500 From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , Simon Marchi , Subject: Re: [RFA 1/2] Make line tables independent of progspace References: <20180321171809.13115-1-tom@tromey.com> <20180321171809.13115-2-tom@tromey.com> <87zi2uw3uc.fsf@tromey.com> <87vadiw24a.fsf@tromey.com> Date: Wed, 28 Mar 2018 04:53:00 -0000 In-Reply-To: (Simon Marchi's message of "Tue, 27 Mar 2018 16:22:04 -0400") Message-ID: <87r2o4x0kw.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Source-L: No X-Exim-ID: 1f135e-002BJh-U2 X-Source-Sender: 174-29-48-109.hlrn.qwest.net (bapiya) [174.29.48.109]:50402 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-03/txt/msg00583.txt.bz2 >>>>> "Simon" == Simon Marchi writes: Simon> Here are two small comments I noted. Thank you. >> @@ -517,10 +522,12 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, >> first_le = NULL; >> >> /* Skip all the preceding functions. */ >> - for (i = 0; i < nlines && le[i].pc < low; i++) >> - continue; >> + for (i = 0; >> + i < nlines - 1 && le[i].address (main_symtab) < low; Simon> I don't understand why "i < nlines" becomes "i < nlines - 1" here. Bad change on my part. >> + if (lte1->raw_address () < lte2->raw_address ()) >> + return -1; >> + if (lte1->raw_address () > lte2->raw_address ()) >> + return -1; >> + return 0; Simon> Both branches return -1 here. Ugh, sorry. This got introduced during the changes to use member functions. Simon> I don't mind the "left - right", I see that often. Especially when you Simon> want to sort by multiple fields, it's short and clear (IMO) to do In this particular case I think it is a bit weird, because the addresses are unsigned, so this is relying on the implicit cast to make the value negative. But also, because the addresses are CORE_ADDR and the return type is int, it seems like underflow is possible as well (in theory, I suppose I wouldn't expect it in practice). So, I thought rather than being tricky here, it was more obviously correct to just write the longer form. Which would be true if it didn't introduce bugs. Tom