From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 295CB387086A for ; Thu, 18 Jun 2020 13:35:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 295CB387086A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eliz@gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]:40346) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jluhP-0008LD-H7; Thu, 18 Jun 2020 09:35:23 -0400 Received: from [176.228.60.248] (port=2724 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jluhI-0004AW-0I; Thu, 18 Jun 2020 09:35:21 -0400 Date: Thu, 18 Jun 2020 16:35:01 +0300 Message-Id: <83tuz8zed6.fsf@gnu.org> From: Eli Zaretskii To: Hev Cc: gdb-patches@sourceware.org In-Reply-To: (message from Hev on Thu, 18 Jun 2020 10:05:14 +0800) Subject: Re: [PATCH] Fix read and access watchpoint can't stop References: <20200617161708.15710-1-r@hev.cc> <834kr91wc4.fsf@gnu.org> X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 18 Jun 2020 13:35:25 -0000 > From: Hev > Date: Thu, 18 Jun 2020 10:05:14 +0800 > Cc: gdb-patches@sourceware.org > > > > /* We were stopped by a hardware watchpoint, but the target could > > > not report the data address. We must check the watchpoint's > > > value. Access and read watchpoints are out of luck; without > > > > The comment below the line you suggest to modify explains why we don't > > handle access and read watchpoints here. So I don't understand the > > rationale for this change (it might be a good idea to explain it in > > more detail in the log message). What am I missing? > > > > Thanks. > > This problem only occurs on the target that target_stopped_data_address() returns false, and > b->watchpoint_triggered is set to watch_triggered_unknown when watchpoint is triggered. so, In > bpstat_check_watchpoint(), the last branch needs to be hit to enable check value: > > 4961 int must_check_value = 0; > 4962 > 4963 if (b->type == bp_watchpoint) > 4964 /* For a software watchpoint, we must always check the > 4965 watched value. */ > 4966 must_check_value = 1; > 4967 else if (b->watchpoint_triggered == watch_triggered_yes) > 4968 /* We have a hardware watchpoint (read, write, or access) > 4969 and the target earlier reported an address watched by > 4970 this watchpoint. */ > 4971 must_check_value = 1; > 4972 else if (b->watchpoint_triggered == watch_triggered_unknown > 4973 && b->type == bp_hardware_watchpoint) > 4974 /* We were stopped by a hardware watchpoint, but the target could > 4975 not report the data address. We must check the watchpoint's > 4976 value. Access and read watchpoints are out of luck; without > 4977 a data address, we can't figure it out. */ > 4978 must_check_value = 1; > > However, the b->type is the actual watchpoint type, bp_hardware_watchpoint for write-only, > bp_read_watchpoint for read-only, and bp_access_watchpoint for read-write, so it will not hit when read-only > and read-write watching. > > On mips we don't know the low order 3 bits of the data address, so we must return false in > stopped_data_address(). This is why we have not found the problem on other platforms (x86/Aarch64/...). I understand, but how will this work on MIPS, given that is_hardware_watchpoint allows any type of watchpoints? How will GDB know which watchpoint triggered if there's no address? And what is the value of bs->breakpoint_at, and how is it different from b->type? Thanks.