From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CC9DC3899019; Fri, 21 Jun 2024 14:45:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC9DC3899019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1718981151; bh=NV/ErjUfWqDmfaTj9OoRNswRbiRdaVCW7Wtm+oaJ4L4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qSRtoXt516CYBsU2e1RJjxg7o3REXDX0a+flkbNi1ZRPA3xYwPIzbZoEQZXvLam5t cbt7CMfdx8DbPmE2zPWRdoeVVri5Ekn8Br3fYqBsyYT3GBOKwTxKNz6vLpK3CBYuP7 MPVFPfIaxfXV7x4eEfxlQpQ+zCIjOxd33tTUfAiQ= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tdep/31705] gdb.base/watchpoint-running.exp fails on arm Date: Fri, 21 Jun 2024 14:45:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tdep X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31705 --- Comment #20 from Sourceware Commits --- The gdb-15-branch branch has been updated by Tom de Vries : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df33b87956ffa= 9d153d39caf625b35f29597f0326 commit f33b87956ffa9d153d39caf625b35f29597f0326 Author: Pedro Alves Date: Fri Jun 21 16:46:50 2024 +0200 [gdb/tdep] Fix gdb.base/watchpoint-running.exp on {arm,ppc64le}-linux When running test-case gdb.base/watchpoint-running on ppc64le-linux (and similar on arm-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 infer= ior is running, and that triggers the first call to ppc_linux_dreg_interface::detect. And because the detection failure is cached, subsequent attempts at set= ting hardware watchpoints will also fail, even if the tracee is ptrace-stopp= ed. The way to fix this is to make sure that ppc_linux_dreg_interface::dete= ct is called when we know that the thread is ptrace-stopped, which in the cur= rent setup is best addressed by using target-specific post_attach and post_startup_inferior overrides. However, as we can see in aarch64_linux_nat_target, that causes code duplication. Fix this by: - defining a new target hook low_init_process, called from linux_init_ptrace_procfs, which is called from both linux_nat_target::post_attach and linux_nat_target::post_startup_inferior, - adding implementations for ppc_linux_nat_target and arm_linux_nat_tar= get that detect the hardware watchpoint interface, - replacing the aarch64_linux_nat_target implementations of post_attach= and post_startup_inferior with a low_init_process implementation. Tested on ppc64le-linux, arm-linux, aarch64-linux and x86_64-linux. Co-Authored-By: Tom de Vries Approved-By: Luis Machado PR tdep/31834 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31834 PR tdep/31705 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31705 (cherry picked from commit 50de502a4f843310e231b3174804e95a9e7de4fc) --=20 You are receiving this mail because: You are on the CC list for the bug.=