From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by sourceware.org (Postfix) with ESMTPS id 33D9A386EC79 for ; Thu, 18 Jun 2020 02:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 33D9A386EC79 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hev.cc Authentication-Results: sourceware.org; spf=none smtp.mailfrom=r@hev.cc Received: by mail-ed1-x544.google.com with SMTP id e12so3653734eds.2 for ; Wed, 17 Jun 2020 19:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hev-cc.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q5FA38LVREMb90KWxyLg7DQV0qwrow8pF5kSBA3w5U4=; b=XJo9ydY2/rfbdRz0NqLk5FbqJUV5mzYj8bdj75K2fJBqcy/+aJt1nMGOjo78YSK8M1 y7q169jRMYn9jz9VcVE+ocrGFNfrrJ7wkdl51ZTKL1xgmHU/J/KzmtcLy2HAMhrRjLpC FquQ2EK5+RHRKsUxMVDousm963hm+/zbh7RFKXKaAeT8Gyea7bbNet/ojLbZ5ckDLu17 VR5aYbRouN7bq61oiZXBpS1a6vYN3xyHNioWgg4Nopf/9FXETH2twJLjEtG5A0evSHph wNLCiBGrCRnwHHlG399n73waiF0YRoh05JfKgOoldnvW8nQwLrCLASsmrQHlX0sWBD+g 4UdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q5FA38LVREMb90KWxyLg7DQV0qwrow8pF5kSBA3w5U4=; b=WLwqpC22j6q9p2jX5g67WxKQOqWJlt0wF89V/hX1ZZthDLpjPbZkGfIvEDW5oHxYMJ h6oXEpffrz4Jt2CmJr9N7NxN5dJHKtXP51XwVLLzb0urI9zexbFVyQgHAWpUUzVvjBQ4 S73LnlVvIA4O13l0gMrgo/NORPBO/pBBawir0X7AZHCvXwRkt105P2ff91mCl2U7h6cp 7ILU1idZtIQhT6x6De2Jniagnhk9zjOjYZ/XId5MWUrVtATX69Z804Gz0qUdWi8xKxAs GGcLMRNoxsW2snNa4waTU9KtgWSqH7r6r2ehJEyVglRCyxiD8w3YLjvKDXkLvWUi5YlT xszQ== X-Gm-Message-State: AOAM532GD4hc0Ak/TXa/dco8gvLK18q3ZZ+VFLnPzeS0fdTJWhA0UtM8 tPTRa5ivQWVlagSehEF1+1lboy/KiZmnC75SCEHh9Q== X-Google-Smtp-Source: ABdhPJy8hfh7gFe+stH8lbKMIlDp4GXQl/01tnPTNM6kMpPJ7W7iWrgv2wpxhwVjr+q4Tv62GsK7PKqjLLkrKfgJ6iE= X-Received: by 2002:a05:6402:1486:: with SMTP id e6mr1826910edv.99.1592445925177; Wed, 17 Jun 2020 19:05:25 -0700 (PDT) MIME-Version: 1.0 References: <20200617161708.15710-1-r@hev.cc> <834kr91wc4.fsf@gnu.org> In-Reply-To: <834kr91wc4.fsf@gnu.org> From: Hev Date: Thu, 18 Jun 2020 10:05:14 +0800 Message-ID: Subject: Re: [PATCH] Fix read and access watchpoint can't stop To: Eli Zaretskii Cc: gdb-patches@sourceware.org X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 02:05:27 -0000 Hello, On Thu, Jun 18, 2020 at 12:38 AM Eli Zaretskii wrote: > > > From: Heiher > > Date: Thu, 18 Jun 2020 00:17:08 +0800 > > Cc: Heiher > > > > --- a/gdb/breakpoint.c > > +++ b/gdb/breakpoint.c > > @@ -4952,7 +4952,7 @@ bpstat_check_watchpoint (bpstat bs) > > this watchpoint. */ > > must_check_value = 1; > > else if (b->watchpoint_triggered == watch_triggered_unknown > > - && b->type == bp_hardware_watchpoint) > > + && is_hardware_watchpoint (bs->breakpoint_at)) > > /* 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/...). -- Best regards! Hev https://hev.cc