From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.206]) by sourceware.org (Postfix) with ESMTPS id A637B3857C40 for ; Wed, 12 Aug 2020 12:52:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A637B3857C40 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 0A0624A17 for ; Wed, 12 Aug 2020 07:52:20 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 5qEtkdnXvOIGp5qEukLeX7; Wed, 12 Aug 2020 07:52:20 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=u/RnQysPwcT0GfpmpAGUeDU1ADM4nkt4pUWlnI+yVVk=; b=Icy+f7WsBdD3VjSLoJlu/TuQ+a NLCOcXp+C3odsA3S/NCaRpijpQIkq7i/vox060tAMrNC/NZ5wIjmNv07QDeOvjs2mkvbFg/D8db7A I/ruhyMLCy9bDWIif87ECfCOy; Received: from 75-166-101-103.hlrn.qwest.net ([75.166.101.103]:53626 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1k5qEt-002UZC-MJ; Wed, 12 Aug 2020 06:52:19 -0600 From: Tom Tromey To: Simon Marchi via Gdb-patches Cc: Simon Marchi , Morichetti@sourceware.org, Laurent Subject: Re: [PATCH 4/4] gdb: change regcache list to be a map References: <20200720204101.2849535-1-simon.marchi@efficios.com> <20200720204101.2849535-5-simon.marchi@efficios.com> X-Attribution: Tom Date: Wed, 12 Aug 2020 06:52:18 -0600 In-Reply-To: <20200720204101.2849535-5-simon.marchi@efficios.com> (Simon Marchi via Gdb-patches's message of "Mon, 20 Jul 2020 16:41:01 -0400") Message-ID: <87tux8hvr1.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.101.103 X-Source-L: No X-Exim-ID: 1k5qEt-002UZC-MJ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-103.hlrn.qwest.net (murgatroyd) [75.166.101.103]:53626 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2020 12:52:22 -0000 >>>>> "Simon" == Simon Marchi via Gdb-patches writes: Simon> The function registers_changed_ptid deletes all regcaches related to a Simon> given (target, ptid). We must now handle the different cases Simon> separately: [...] Simon> - non-NULL target and non-minus_one_ptid: we delete all the entries Simon> associated to that tuple, this is done efficiently Simon> - a non-NULL target and minus_one_ptid: we delete all the entries Simon> associated to that target, whatever the ptid. This is the slightly Simon> annoying case, as we can't easily look up all items having this target Simon> in their key. I implemented it by walking the list, which is not Simon> ideal. This patch caused a regression for Ravenscar targets. I spent a bit of time tracking it down, and I think the issue is that there was a change in the semantics in registers_changed_ptid. Formerly it did this: Simon> - if ((target == nullptr || regcache->target () == target) Simon> - && regcache->ptid ().matches (ptid)) Simon> - { Simon> - delete regcache; Simon> - it = regcaches.erase_after (oit); But now it does: if (target == nullptr) ... else if (ptid != minus_one_ptid) { /* Non-NULL target and non-minus_one_ptid, delete all regcaches belonging to this (TARGET, PTID). */ auto ptid_regc_map_it = regcaches.find (target); if (ptid_regc_map_it != regcaches.end ()) { auto &ptid_regc_map = ptid_regc_map_it->second; ptid_regc_map.erase (ptid); } } else ... The difference being the call to ptid::matches. This method will return true if the ptid in question is a PID: || (filter.is_pid () && m_pid == filter.pid ()) ... but in the new code, no provision is made for the PID case. This comes up because, at least in the case I am debugging, target_resume is called with a PID and not -1. See user_visible_resume_ptid: else if (!sched_multi && target_supports_multi_process ()) { /* Resume all threads of the current process (and none of other processes). */ resume_ptid = ptid_t (inferior_ptid.pid ()); } At first I wasn't sure if this semantic change was really a bug; but now it seems to me that it must be. The non-stop and scheduler-locking cases are handled earlier in user_visible_resume_ptid, so at this point it intends to resume all the threads of the process. And, in this situation, I think the register caches for all threads in the process ought to be cleared by the registers_changed_ptid call in target_resume. A simple fix would be to fall back to iterating over the map in the is_pid case. I don't know whether this would reintroduce the performance issue that prompted the patch, though. I'd like to know whether you agree with this analysis ... if so, what should we do; and if not, what is incorrect? thanks, Tom