From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Sl/1Cd0e9WLwDCUAWB0awg (envelope-from ) for ; Thu, 11 Aug 2022 11:23:09 -0400 Received: by simark.ca (Postfix, from userid 112) id 1BD721E5EA; Thu, 11 Aug 2022 11:23:09 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=evlbN1a3; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id ACE3F1E13B for ; Thu, 11 Aug 2022 11:23:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDF2A3856DD2 for ; Thu, 11 Aug 2022 15:23:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDF2A3856DD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660231388; bh=n4laS2GrsvwvV60nFZXY1Gx4aM6o18walM17EZnZJXQ=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=evlbN1a32dY9TTOax/6egIEoNUAFHoBCfrgLOXyCdgajOzf0D3MmRBzmlg91bBTg1 3sjLznDta6Pmg9BcIBpBSZEmF5e4w3E9hF80Zbsxc7ev1fLlfhvJyEdpMiG2Kr3HfM qBA7gWD32VQGPEQXT/7kYD+Bed/6zv+4Wy/lxCfM= Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A4EAA385AC2E for ; Thu, 11 Aug 2022 15:22:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4EAA385AC2E Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27BFFHjv024535 for ; Thu, 11 Aug 2022 15:22:48 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hw488885g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Aug 2022 15:22:48 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27BFLVdT021827 for ; Thu, 11 Aug 2022 15:22:47 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 3huwvkphsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Aug 2022 15:22:47 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27BFMker7340600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 15:22:46 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91C94B2068; Thu, 11 Aug 2022 15:22:46 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 144CEB2065; Thu, 11 Aug 2022 15:22:46 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.56.41]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 15:22:45 +0000 (GMT) Message-ID: Subject: Re: [PATCH] Fix hardware watchpoint check in test gdb.base/watchpoint-reuse-slot.exp To: will schmidt , "gdb-patches@sourceware.org" , Ulrich Weigand Date: Thu, 11 Aug 2022 08:22:45 -0700 In-Reply-To: <32842d73fc8b78df60cd4dc88b08a51ced20b45b.camel@vnet.ibm.com> References: <3783e7e44fe188af5ca1f2ddcfa4c7f5cb7a818e.camel@us.ibm.com> <20f1b450af2746c38b98e7e1d29805d35b475be1.camel@vnet.ibm.com> <5596a4dc585b51beea3ba1138262ab71014e7c89.camel@us.ibm.com> <5b7b2e287d29fc77aeb81c4c30b6aa8652e529d7.camel@us.ibm.com> <32842d73fc8b78df60cd4dc88b08a51ced20b45b.camel@vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mM_B4IuVEdUCaC78zIWrn24czOGekWpW X-Proofpoint-GUID: mM_B4IuVEdUCaC78zIWrn24czOGekWpW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_11,2022-08-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 clxscore=1015 malwarescore=0 spamscore=0 phishscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110051 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: , From: Carl Love via Gdb-patches Reply-To: Carl Love Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Thu, 2022-08-11 at 09:16 -0500, will schmidt wrote: > On Wed, 2022-08-10 at 12:17 -0700, Carl Love wrote: > > Will: > > > > On Wed, 2022-08-10 at 10:54 -0700, Carl Love wrote: > > > > > +if {[skip_hw_watchpoint_access_tests]} { > > > > > + set supports_hw_wp 0 > > > > > +} else { > > > > > + set supports_hw_wp 1 > > > > > +} > > > > > + > > > > > standard_testfile > > > > > > > > > > if {[prepare_for_testing "failed to prepare" $testfile > > > > > $srcfile > > > > > debug]} { > > > > > @@ -285,7 +297,7 @@ proc setup_and_run_watchpoints_tests { > > > > > hw_wp_p > > > > > } { > > > > > > > > > > # Run tests with hardware watchpoints disabled, then again > > > > > with > > > > > them > > > > > # enabled (if this target supports hardware watchpoints). > > > > > -if { ![target_info exists gdb,no_hardware_watchpoints]} { > > > > > +if { $supports_hw_wp } { > > > > > > > > So.. could this be simplified with a check against the existing > > > > cached > > > > has_hw_wp_support value? > > > > > > Yes, I hadn't thought about that. I updated the patch to just > > > check > > > the cached value. > > > > > # Run test with H/W enabled. > > > > > setup_and_run_watchpoints_tests 1 > > > > > } > > > > I updated the patch on Power to just check the has_hw_wp_support > > cached > > value. That works great. However, when I did my testing on x86-64 > > it > > doesn't work. The issue is the the runtime check is only done on > > PowerPC thus the variable has_hw_wp_support is not initialized on > > other > > platforms. Thus you do need to set a local variable and use > > that. > > Hmm, I don't see anything in has_hw_wp_support gdb.exp that limits > the > setting to only for powerpc.. why is that the case? > > The current usage > of the variable in skip_hw_watchpoint_tests does include an istarget > reference, is that making the difference here? > > || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support]) > The proc skip_hw_watchpoint_access_tests has the code: proc skip_hw_watchpoint_access_tests {} { if { [skip_hw_watchpoint_tests] } { return 1 } ... which calls proc skip_hw_watchpoint_access_tests which has the code which you referenced above: proc skip_hw_watchpoint_tests {} { # Skip tests if requested by the board if { [target_info exists gdb,no_hardware_watchpoints]} { return 1 } # These targets support hardware watchpoints natively # Note, not all Power 9 processors support hardware watchpoints due to a HW # bug. Use has_hw_wp_support to check do a runtime check for hardware # watchpoint support on Powerpc. if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] || [istarget "ia64-*-*"] || [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support]) || [istarget "s390*-*-*"] } { return 0 } ... so if the target is powerpc*-*-linux* we call proc has_hw_wp_support which has the code: gdb_caching_proc has_hw_wp_support { # Power 9, proc rev 2.2 does not support HW watchpoints due to HW bug. # Need to use a runtime test to determine if the Power processor has # support for HW watchpoints. global srcdir subdir gdb_prompt inferior_exited_re set compile_flags {debug nowarnings quiet} set me "has_hw_wp_support" # Compile a test program to test if HW watchpoints are supported set src { int main (void) { volatile int local; local = 1; if (local == 1) return 1; return 0; } ... gdb_exit remote_file build delete $obj verbose "$me: returning $has_hw_wp_support" 2 return $has_hw_wp_support } So here is where has_hw_wp_support is returned and then gets cached. Since none of the other targets call these proceedures, the value is never cached. In my case, I get the error on X86 that the variable has_hw_wp_support doesn't exist. Carl