From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sUhRNjMzdGaT4AAAWB0awg (envelope-from ) for ; Thu, 20 Jun 2024 09:48:35 -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=A3ROdJv8; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=itrvm6ze; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=A3ROdJv8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=itrvm6ze; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D23671E0C1; Thu, 20 Jun 2024 09:48:35 -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 9AB0C1E030 for ; Thu, 20 Jun 2024 09:48:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B11263893663 for ; Thu, 20 Jun 2024 13:48:32 +0000 (GMT) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 70FFB389245F for ; Thu, 20 Jun 2024 13:48:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70FFB389245F 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 70FFB389245F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718891291; cv=none; b=wp4zxcbiGATxywwBegmEUoLWpVRmlhequ9dAz/f/cNzE+3+EpYipIy4jqrFvxXDL4OlSEQdhqvNS5Mtu4SMYAxSXLtY9HJdyZ9GGgheegjtxD/suX9o7tOtmRBayDGf0or3rYr9hyOtJdkI2nIDkEHGHd72kWAD3QsvcOFfuFLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718891291; c=relaxed/simple; bh=xUsRL08ZAa2MvJVR5KNqBIEKEAlvDLyO4XA70WzD8hs=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=UkVkUJ25P+pDnOIPFry4+dE2aRX7hioHRswPT8GE5MYdDDaC/jX/uuEYvfRuNFvQ1uwMrwEldYtwglluC/wofgZfHa2hNSGh9J2kGxG4uXsanSlxbdOOobzDItYaecK+tz3yFMijExGgHMcoKBFqm5KLe2cnW9PGmtn7t9MKnZA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 609D91F8A3; Thu, 20 Jun 2024 13:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718891284; 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=yGT+2Pyk0ZinoElxttd36jBS0nzhQz1lZiujYf36Xws=; b=A3ROdJv8oivZmeFXLZ7+DEHu0vujm58+hWs6AJVfCQGLbK4txb2RiCWW9r32SIykbYrg4W M9GhJGHze8nlo5pQY0MCaS+X8+X6HaQ/P/Q5cVoEfF/ont9rwczt8GJ7VVdqPuL5lc7lcZ nfM63DUTjfPpACXEuxdzTN+BDD19ccw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718891284; 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=yGT+2Pyk0ZinoElxttd36jBS0nzhQz1lZiujYf36Xws=; b=itrvm6zerlNvcjPIp4qK/PPZfvYn5dlLvRQjKrpLFyPsQ+RB95ujqf1X1KVv8KYyve+cyi r2PHSsvQKJmdHxCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=A3ROdJv8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=itrvm6ze DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718891284; 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=yGT+2Pyk0ZinoElxttd36jBS0nzhQz1lZiujYf36Xws=; b=A3ROdJv8oivZmeFXLZ7+DEHu0vujm58+hWs6AJVfCQGLbK4txb2RiCWW9r32SIykbYrg4W M9GhJGHze8nlo5pQY0MCaS+X8+X6HaQ/P/Q5cVoEfF/ont9rwczt8GJ7VVdqPuL5lc7lcZ nfM63DUTjfPpACXEuxdzTN+BDD19ccw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718891284; 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=yGT+2Pyk0ZinoElxttd36jBS0nzhQz1lZiujYf36Xws=; b=itrvm6zerlNvcjPIp4qK/PPZfvYn5dlLvRQjKrpLFyPsQ+RB95ujqf1X1KVv8KYyve+cyi r2PHSsvQKJmdHxCA== 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 3A89913AC1; Thu, 20 Jun 2024 13:48:04 +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 6DyADBQzdGZ5UQAAD6G6ig (envelope-from ); Thu, 20 Jun 2024 13:48:04 +0000 Message-ID: <72f9ecd8-c53f-4f33-a97b-02ab79738fa0@suse.de> Date: Thu, 20 Jun 2024 15:49:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tdep] Fix gdb.base/watchpoint-running on {arm, ppc64le}-linux From: Tom de Vries 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 In-Reply-To: <88e14e37-9fbd-4dfb-ac37-6bee23eff372@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.50 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 609D91F8A3 X-Spam-Score: -4.50 X-Spam-Level: X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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/17/24 20:22, Tom de Vries wrote: > On 6/14/24 18:49, Pedro Alves wrote: >> Hi! >> >> Sorry for the delay.  I've been super swamped.  :-/ >> > > Hi Pedro, > > thanks for the review. > >> On 2024-06-07 07:35, Tom de Vries wrote: >> >>> PR tdep/31834 >>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31834 >>> PR tdep/31705 >>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31705 >>> --- >>>   gdb/linux-nat.c | 12 ++++++++++++ >>>   1 file changed, 12 insertions(+) >>> >>> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c >>> index c95d420d416..d8b5a99269b 100644 >>> --- a/gdb/linux-nat.c >>> +++ b/gdb/linux-nat.c >>> @@ -454,6 +454,18 @@ linux_init_ptrace_procfs (pid_t pid, int attached) >>>     linux_ptrace_init_warnings (); >>>     linux_proc_init_warnings (); >>>     proc_mem_file_is_writable (); >>> + >>> +  /* Some targets (for instance ppc and arm) may call ptrace to >>> answer a >>> +     target_can_use_hardware_watchpoint query, and cache the >>> result.  However, >>> +     the ptrace call will fail with errno ESRCH if the tracee is not >>> +     ptrace-stopped, making the query fail.  And if the caching >>> mechanism does >>> +     not disregard an ESRCH result, all subsequent queries will also >>> fail. >>> +     Call it now, where we known the tracee is ptrace-stopped. >>> + >>> +     Other targets (for instance aarch64) do the relevant ptrace >>> call and >>> +     caching in their implementation of post_attach and >>> post_startup_inferior, >>> +     in which case this call is expected to have no effect.  */ >>> +  target_can_use_hardware_watchpoint (bp_hardware_watchpoint, 1, 0); >> >> To be honest, I kind of preferred the other version of the patch. >> This is a single call, >> yes, but then you have to explain details about the different backend >> implementations, >> anyhow, and it raises questions like, what if bp_hardware_watchpoint >> is the right >> type?  What if some architecture caches the resources for >> bp_hardware_breakpoint >> differently? >> > > I did think about that, and as a solution considered looping over all > types of breakpoints.  But it seemed somewhat of an overkill, so I went > with just bp_hardware_watchpoint. > > Of course, if your specific concern is bp_hardware_breakpoint, then this: > ... >   target_can_use_hardware_watchpoint (bp_hardware_watchpoint, 1, 0); >   target_can_use_hardware_watchpoint (bp_hardware_breakpoint, 1, 0); > ... > addresses that. > >> 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.  There might be other targets that needs such a > fallback, but that we don't know about. > > So, I don't mind your patch, it's certainly cleaner, but I don't mind a > functional default implementation either.  So, I'd move the > target_can_use_hardware_watchpoint call to the default implementation of > low_init_process. > > We should consider fixing things in a way that minimizes efforts for > target maintainers. > >> I guess the wart with the other approach would be that you have to handle >> this from both post_startup_inferior and post_attach?  I think we can fix >> that -- add a new low_init_process method that is called in both >> scenarios, >> where the backend can do what it needs to. >> >> I was going to write small draft patch that just adds the method in >> question, >> for discussion, but then as I was already looking at the code, I ended up >> implementing the arm, aarch64, ppc backend versions of it.  I noticed >> that all the m_dreg_interface.detect and m_dreg_interface.detected_p >> calls throughout ppc-linux-nat.c could be removed, since we now >> always call m_dreg_interface.detect() early. >> >> I only build-tested this on x86_64, which of course is not sufficient >> testing. >> >> Overall it's a net reduction of code, which seems nice to me. >> > > I ran into trouble building the patch due to type of pid parameter > mismatches. > > After fixing that, I ran into trouble on ppc64le, because > low_prepare_to_resume is called before low_init_process.  I fixed that > by sinking this code in the function a bit: > ... >   if (m_dreg_interface.unavailable_p ()) >     return; > ... > > And after fixing this, I still ran into failures and identified at least > two more locations that needed fixing due to the cleanup, at which point > I decided that the cleanup part is out-of-scope for the patch fixing the > PR. > > So, this is what I have tested on x86_64-linux, aarch64-linux, arm-linux > and ppc64le-linux. > Hi Pedro, does the tested patch look acceptable? If so, I can do an actual submission. I'm on vacation for three weeks starting coming Saturday, so I might have time for that tomorrow. I'd like this fix to be in gdb 15, I'm not sure what the time-line is on that though. Thanks, - Tom