From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id d4+zG2v3YmbQxSkAWB0awg (envelope-from ) for ; Fri, 07 Jun 2024 08:04:59 -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=SlbpB0PG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1FhYSL+w; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=SlbpB0PG; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1FhYSL+w; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5F45F1E0C1; Fri, 7 Jun 2024 08:04:59 -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 249811E092 for ; Fri, 7 Jun 2024 08:04:57 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7071839CC29B for ; Fri, 7 Jun 2024 12:04:56 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 49DC339CC280 for ; Fri, 7 Jun 2024 12:04:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49DC339CC280 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 49DC339CC280 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717761877; cv=none; b=rza8uM49vHt4Im35svbGSFII69WIN9i36aI84loH8Xb5PeF8z2QIWPJ3DMuf5gI4sR03utFJfvNORpyHa/cyAxOaA+vQEb6xgv2SrYh5UOKHlhljb9EZUVXCa26y//6y1JgbW9ZqSFNUoFeNwkZvOqt86GdbaxIRb8wvKYP6wJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717761877; c=relaxed/simple; bh=pmE9kICMJoHPnnDIuoKskAxg7EA5guq8UY8CqgejxwE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=r+Oub68VybfcGOAwgkHG9n7fGsjtiYurLnracnLOM1bVAyXWikAoJU4/22RsFCsudHNw1tXL6bHIcO7phmvZyf0vjWgcKkR9sVTTwZIo184VvboWrK54MAw/VLGn6vaosgFi0EcFf2cFirqqZlQryIcB0dSb5cR3zN2i/z9MSyA= 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 4474321990; Fri, 7 Jun 2024 12:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1717761874; 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=pLTVw91z8/THe4tdoJ038yHygoCy4Ioe1oMH75UMHS4=; b=SlbpB0PGqGip5bBIJyYSEiFMJndclVObPq6+Hq/vV5fW1bWP/2RdWoZCtpVCIfmX+IDuQk Hjc7uiopnrdx3dySQQna3xwiaMY1y1mmXy6JgxPF3+aS8KldXefQXy5KVwQRPr2dDfoCJ4 BoFT/UIjCiTDttQG647fTAXz7lxyro8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1717761874; 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=pLTVw91z8/THe4tdoJ038yHygoCy4Ioe1oMH75UMHS4=; b=1FhYSL+wNmpkjbtDpXwJNnhBqT4wpfygDZ26HW/jbq7vCI9REhMQrAeqc8TV6jBRCEElr9 lTN6rp21ys9yRMAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1717761874; 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=pLTVw91z8/THe4tdoJ038yHygoCy4Ioe1oMH75UMHS4=; b=SlbpB0PGqGip5bBIJyYSEiFMJndclVObPq6+Hq/vV5fW1bWP/2RdWoZCtpVCIfmX+IDuQk Hjc7uiopnrdx3dySQQna3xwiaMY1y1mmXy6JgxPF3+aS8KldXefQXy5KVwQRPr2dDfoCJ4 BoFT/UIjCiTDttQG647fTAXz7lxyro8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1717761874; 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=pLTVw91z8/THe4tdoJ038yHygoCy4Ioe1oMH75UMHS4=; b=1FhYSL+wNmpkjbtDpXwJNnhBqT4wpfygDZ26HW/jbq7vCI9REhMQrAeqc8TV6jBRCEElr9 lTN6rp21ys9yRMAA== 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 257FE133F3; Fri, 7 Jun 2024 12:04:34 +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 0YK2B1L3YmZ5VgAAD6G6ig (envelope-from ); Fri, 07 Jun 2024 12:04:34 +0000 Message-ID: <93d12a77-ad21-4e67-ba82-3205ba923c01@suse.de> Date: Fri, 7 Jun 2024 14:05:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tdep] Fix gdb.base/watchpoint-running on {arm, ppc64le}-linux To: Luis Machado , gdb-patches@sourceware.org, Pedro Alves References: <20240607063525.9887-1-tdevries@suse.de> <702876d8-e2e4-4962-83fe-2cce2195b4a0@arm.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <702876d8-e2e4-4962-83fe-2cce2195b4a0@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(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)[]; RCPT_COUNT_THREE(0.00)[3]; 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, sourceware.org:url] X-Spam-Score: -4.29 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, 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/7/24 12:18, Luis Machado wrote: > On 6/7/24 07:35, Tom de Vries wrote: >> When running test-case gdb.base/watchpoint-running on ppc64le-linux, we get: >> ... >> (gdb) watch global_var^M >> warning: Error when detecting the debug register interface. \ >> Debug registers will be unavailable.^M >> Watchpoint 2: global_var^M >> (gdb) FAIL: $exp: all-stop: hardware: watch global_var >> FAIL: $exp: all-stop: hardware: watchpoint hit (timeout) >> ... >> >> The problem is that ppc_linux_dreg_interface::detect fails to detect the >> hardware watchpoint interface, because the calls to ptrace return with errno >> set to ESRCH. >> >> This is a feature of ptrace: if a call is done while the tracee is not >> ptrace-stopped, it returns ESRCH. >> >> Indeed, in the test-case "watch global_var" is executed while the inferior is >> running, and that triggers the first call to ppc_linux_dreg_interface::detect. >> >> And because the detection failure is cached, subsequent attempts at setting >> hardware watchpoints will also fail, even if the tracee is ptrace-stopped. >> >> Fix this by calling target_can_use_hardware_watchpoint from >> linux_init_ptrace_procfs, which is called from both: >> - linux_nat_target::post_attach, and >> - linux_nat_target::post_startup_inferior. >> >> By fixing this here, we also fix the same problem for arm-linux. >> >> Tested on ppc64le-linux and arm-linux. >> >> 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); >> } >> >> linux_nat_target::~linux_nat_target () >> >> base-commit: f9478936896ada7786e8d68622f6e6ff78b97b0d > > Looks good from arm-linux's side. Thanks! > > Reviewed-By: Luis Machado > Tested-By: Luis Machado Luis, thanks for the review and the testing. Pedro, since you reviewed a target-specific patch for the arm PR, any comments? Thanks, - Tom