From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by sourceware.org (Postfix) with ESMTPS id 0121A395CC89 for ; Thu, 18 Jun 2020 15:36:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0121A395CC89 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-ej1-x644.google.com with SMTP id l27so6920957ejc.1 for ; Thu, 18 Jun 2020 08:36:03 -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=RbVs1pxY+cKxwupzAqfe14Mv4e6aZ/riqMeVO1QBDJI=; b=huK+F6Ua6TiWljv8YKZBRsEbZSfC02cyz7JMs1WpWv8QWXBMjxI/CrtUNrGcimfIEj 3oCim3YrBehYbc6qpPsMfk1015YCm0jpy/tvtZvf87zeznyhjxrrjWEb+XFIL86fsMLc UkUwmKxlwQ1gEGN9RbpnrgIhMO6CMai/ygXJ9KBa3Jz+ahkPAHSTcezsE1GjdMlRh/W0 5WO8YUgyZYEERX368eC55gXhs0xtSDsb2YaQpY6hyS9j5uTTy6dqJHTnOQPrxX93cPGt nBxteBF2V6mFn2/komjd9kosXhny3+z8KjxfzJjpxz3CtzrnOwlVq20DVrf0so80S6HD nrlw== 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=RbVs1pxY+cKxwupzAqfe14Mv4e6aZ/riqMeVO1QBDJI=; b=XMGw5XHt/0jao5d2aC7Q+RLi1ksTSyboapIvwXnuoxvB/a2/uhnud7+sHOiELsnaju Y5dj3XDpk/r3LF5N/3yiKoth5knfBznvn5g3QlSO2LIrEqoGzzHM//Aw5X9hwErK3ekj etCbjyG2jX/pFDpTP272drItkVxvdmWaGEoEE9ZpEVOUdZW3CBXlPsyOSJ1W32axvONS lK8XXjgjDz8do33QxuXFsiz8Pd7Qd893+o5DGnMvLSEZLaJspqX2iufh0VgApKwXOpDS FtdilY85/wWtLWfu8KVH967MCZb+BngtP2Ra1Hefz7PloXCjRDC4UpRibiui5WD50zUh 49RQ== X-Gm-Message-State: AOAM5309lXH8X5ymf9xkCJd2vrWVdASBE6ZDgu87LsEdL1EWP5dpUrhk URwHbOgNY/yP0B0Niot4Z9/15sO1mpgYEoOgRP/33K63RBkrMw== X-Google-Smtp-Source: ABdhPJxscsgMQDaQCpxR9NN2IrWmBN4lA2HvS8xhSLZsoF2gQDsuIYNMYSHn2YVn8WfLtGwPewIqo5Zpd2nwGQYPu/g= X-Received: by 2002:a17:906:19c7:: with SMTP id h7mr4349750ejd.403.1592494563018; Thu, 18 Jun 2020 08:36:03 -0700 (PDT) MIME-Version: 1.0 References: <20200617161708.15710-1-r@hev.cc> <834kr91wc4.fsf@gnu.org> <83tuz8zed6.fsf@gnu.org> In-Reply-To: <83tuz8zed6.fsf@gnu.org> From: Hev Date: Thu, 18 Jun 2020 23:35:52 +0800 Message-ID: Subject: Re: [PATCH] Fix read and access watchpoint can't stop To: Eli Zaretskii Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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 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 15:36:06 -0000 Hello, On Thu, Jun 18, 2020 at 9:35 PM Eli Zaretskii wrote: > > > 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. I looked at the code again. Although this changes can keep bs->stop still equal 0 to make works, But it is not a right way. Thanks for review. -- Best regards! Hev https://hev.cc