From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QDd3Kl+TdWZOnwMAWB0awg (envelope-from ) for ; Fri, 21 Jun 2024 10:51:11 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vKuh08Uj; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=xMoYABge; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vKuh08Uj; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=xMoYABge; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AA6A01E0C1; Fri, 21 Jun 2024 10:51:11 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 990C11E030 for ; Fri, 21 Jun 2024 10:51:09 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16DAB389901D for ; Fri, 21 Jun 2024 14:51:09 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 8FE7A3896C3A for ; Fri, 21 Jun 2024 14:50:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FE7A3896C3A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8FE7A3896C3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718981449; cv=none; b=ucyy1SfwwcZvQqV6DspPUexKavmXbMiFx9xg2T2m/9r+V9ocMbzPS90xjWPTKGEdFGujQuXFSRI51Tu7VOG+41eXZR0jWaQuTP3/93lJ+GSKH9jyu0Gb/yfPaCaAaJ26h5A/JUdx/fVvvYh8od1xWTgIf+UFCI/xhz9y9mYzQUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718981449; c=relaxed/simple; bh=fzv0DDlbFx3F8pEOrcleqAP164kgWMbGEzAoofpxm30=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=MxdlrzBxptBekpn57kEra4x6xAFq/oqSoZ5+C2piiYIe5X2faTEe+1e3H7wIx4WoWy8GenYxwx/PxpFOx5J3RdWWhDEa3Z64M5CZlk3qilG5FkhywcJaZOAUgT9cbfcggvnkuYlzZ7H3yFc3aFyWoCWOapXYsyS5+AQDh70Qml0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 454E021A49; Fri, 21 Jun 2024 14:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718981446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snuAPnwgUvHAnFaoUUwYnZpOlKqIPPxkQQ9lHLiBLKM=; b=vKuh08Uj0oiHLxM4aH28JOneOxZuys2psk8FNcrWqoijsbczDI1QfPZHdYjLdZzvhOPsVd HqPnZ7GoX8KMai3fdnMQV5ZzmGqNTM7itQubL674f7lVt0jTHN8V5K5PqEp44AFcn9Jf9s t2/KZoeCIXRGNhz+I6lWt7v+hYQFFO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718981446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snuAPnwgUvHAnFaoUUwYnZpOlKqIPPxkQQ9lHLiBLKM=; b=xMoYABgeM1z+lCAzWjYX47rT/Humk22o8QMNCf5ZoIK1gKx/LVy+7jauD/QOcM3dKQHeC0 lb9IKSoHhxdWX4Cg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718981446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snuAPnwgUvHAnFaoUUwYnZpOlKqIPPxkQQ9lHLiBLKM=; b=vKuh08Uj0oiHLxM4aH28JOneOxZuys2psk8FNcrWqoijsbczDI1QfPZHdYjLdZzvhOPsVd HqPnZ7GoX8KMai3fdnMQV5ZzmGqNTM7itQubL674f7lVt0jTHN8V5K5PqEp44AFcn9Jf9s t2/KZoeCIXRGNhz+I6lWt7v+hYQFFO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718981446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snuAPnwgUvHAnFaoUUwYnZpOlKqIPPxkQQ9lHLiBLKM=; b=xMoYABgeM1z+lCAzWjYX47rT/Humk22o8QMNCf5ZoIK1gKx/LVy+7jauD/QOcM3dKQHeC0 lb9IKSoHhxdWX4Cg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2AAC513ABD; Fri, 21 Jun 2024 14:50:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 9bbKCEaTdWbnMAAAD6G6ig (envelope-from ); Fri, 21 Jun 2024 14:50:46 +0000 Message-ID: <53959256-fac1-4938-b0e0-7f93b891fd4b@suse.de> Date: Fri, 21 Jun 2024 16:51:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tdep] Fix gdb.base/watchpoint-running on {arm, ppc64le}-linux To: Pedro Alves , gdb-patches@sourceware.org References: <20240607063525.9887-1-tdevries@suse.de> <9c0d2050-3555-47c9-bec8-1f2548eba9c6@palves.net> <88e14e37-9fbd-4dfb-ac37-6bee23eff372@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.29 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.29 X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 6/21/24 14:44, Pedro Alves wrote: > Hi Tom, > > On 2024-06-21 10:43, Tom de Vries wrote: >> On 6/20/24 20:15, Pedro Alves wrote: >>> On 2024-06-17 19:22, Tom de Vries wrote: >>>> On 6/14/24 18:49, Pedro Alves wrote: >>> >>>>> And, from another angle, why isn't aarch64 doing the same, why two mechanisms? >>>> >>>> Well, the patch adds a fallback, that aarch64 doesn't need, but that powerpc and arm do need. >>>> >>> >>> Aarch64 absolutely needs it, it's just that it already has the fix in place (by checking early in >>> post_startup_inferior/post_attach).  We're adding code to the other backends to handle it too, but using a >>> somewhat different solution.  If arm / ppc were being adjusted to use the same approach as aarch64 (like in a >>> previous patch in bugzilla), then I wouldn't have asked that question.  I see no good reason for multiple ways >>> of doing the same thing. >>> >> >> To formulate it a bit differently: the fallback implementation enables only lazy implementations.  Aarch64 doesn't have a lazy implementation, so it doesn't need the fallback.  Both arm and ppc do have lazy implementations, which is why the fallback works for those. > > Yes, but with the fix, the arm and ppc backends aren't really lazy anymore, as in, the code makes it look like it, but they aren't, > as we do the check always even with no watchpoints. The lazy-support support code could be removed in the line of Aarch64, as being > unnecessary, which is what I was doing on ppc. > >> >> If we'd drop the calls to aarch64_linux_get_debug_reg_capacity from both aarch64_linux_nat_target::post_startup_inferior and aarch64_linux_nat_target::post_attach, the fallback wouldn't help, we'd have to a add a call to aarch64_linux_get_debug_reg_capacity in probably an override of can_use_hw_breakpoint.  In which case I prefer the current solution for aarch64. >> >>>> There might be other targets that needs such a fallback, but that we don't know about. >>> >>> We have a testcase that will show us if so. >>> >> >> To which my first thought is: And why not have a trivial fix that might work for some of those targets and make that test-case pass. >> >> I suppose we're weighing a trade-off between: >> - reducing complexity by ensuring to do things in one way only, and >> - catering for an unknown subset of target implementations in a common >>   implementation. >> >> I don't see a good way or principle to decide between those, my preference is clearly on the latter but I do understand the importance of the former. > > I'm not against a fallback in principle. I am more against the fallback being to call a higher level function and assuming that it works because > some other functions in the backend do things in a specific way (the lazy checking). It's crossing abstractions boundaries, calling into the target stack, > assuming the right inferior is the current one, and overall more than what is needed. We have a hook at the low level to do low level things > that only concern the architecture, and it seems to me way cleaner and future-design-proof to let it do the strict things that > are specific to the architecture. That even allows getting rid of most of the now unnecessary lazy code as I was doing on ppc (ok, it needs > some tweaks). Baking assumptions into the default kind of masks such things. > Ok, this makes sense to me now, thank you for the explanation. - Tom >> >> Anyway, since this is a point of contention, I didn't include it in the tested patch, so ... moving on. > > Thank you. > >>>> So, this is what I have tested on x86_64-linux, aarch64-linux, arm-linux and ppc64le-linux. >>> >>> OK, let's go with this, then.  Thank for testing! >> >> I've submitted a v2 ( https://sourceware.org/pipermail/gdb-patches/2024-June/210138.html ), with comments a bit expanded, and commit log copied from v1 and updated. > > I will take a look now. Thanks again!