From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1095D3858D1E for ; Fri, 15 Sep 2023 10:09:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1095D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694772580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7vLCJn8Ybjb6F77Es0YbsA5doYlYQBXWRMKdO3WPm5k=; b=hvwKlZKmO1WKbKax0Cp0oa6p2hNfUdlHnAudyy+GCQiGYO0mAug1OkYtRO8Td7cVx306RU RtCwVs1NtfHbx40ManSiopaQ+WCXzE2jKqH04WHFZWPvr3oGE2eeqx5bF1MDlWaOB9+TwO M4Xno/A8VRomOTjWcofD2Im7YfXITG0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-NKA4wU8mMCKB6p5_2V64lg-1; Fri, 15 Sep 2023 06:09:39 -0400 X-MC-Unique: NKA4wU8mMCKB6p5_2V64lg-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-521da4c99d4so1411617a12.1 for ; Fri, 15 Sep 2023 03:09:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694772578; x=1695377378; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7vLCJn8Ybjb6F77Es0YbsA5doYlYQBXWRMKdO3WPm5k=; b=GkY08opvTQNXRvvOM+lJQ4SQczaERo0W6QpQR6TKSwbGQEDc3xROBgYhExgiKFyMNB WkaR1F0i7dNmoOlbv9dMhIZ4V2ufFtnqvXd8dikANkqCx6MsUgSEwaY1Zm1+iRm5ai5b Q7dQhhRuxt1enX15Mjxg5Ahr7PaWWCzvN3TVAsNYNE2Bas10i46H3UmPttsBUz88k5Gz yu1GyOhRxHwx+l6aJdRSHTNGpIqhc5PDo0dffp8Cow58Zu2s8KDUoRu4oeeRdeE5Q/hz 917nOA9sEtuJ/Vc+CZcdFEr4wuiHRI63ITsv39jLJNCfyS7y/p96+/D4B1kH5BIUnca8 6l4Q== X-Gm-Message-State: AOJu0YxNnYcxxB9JdwCJon9vdzTqBm84xCI6tcvrv9pukSBvGATe4NOx /GeThSpyjLwUjsm3+puQ4EWVR5U3LVGvF+2NEntGW0XYwM3o2n1hBLfidhXczzVqEKzYx4i1peY 6Ya0FSQ/lCMT+2QHRIkyKU51LUWBjcw== X-Received: by 2002:a05:6402:1a54:b0:522:57d9:6553 with SMTP id bf20-20020a0564021a5400b0052257d96553mr1157046edb.1.1694772578216; Fri, 15 Sep 2023 03:09:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbXZWRBp/nAEa90JUFN8M7B+RhxfC9+u50FvR7jIkisy9Sl2xoNqRjgso/eNXPzoQBD+K0wQ== X-Received: by 2002:a05:6402:1a54:b0:522:57d9:6553 with SMTP id bf20-20020a0564021a5400b0052257d96553mr1157031edb.1.1694772577870; Fri, 15 Sep 2023 03:09:37 -0700 (PDT) Received: from [192.168.0.129] (ip-94-112-225-44.bb.vodafone.cz. [94.112.225.44]) by smtp.gmail.com with ESMTPSA id a3-20020aa7cf03000000b0052e1959db1csm2042313edy.20.2023.09.15.03.09.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 03:09:37 -0700 (PDT) Message-ID: <2eb65a2d-aa80-5930-3033-bfd82baa2ed9@redhat.com> Date: Fri, 15 Sep 2023 12:09:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] Fix hardware watchpoints in replay mode To: Hannes Domani , gdb-patches@sourceware.org, Pedro Alves References: <20230914162732.2077-1-ssbssa.ref@yahoo.de> <20230914162732.2077-1-ssbssa@yahoo.de> From: Guinevere Larsen In-Reply-To: <20230914162732.2077-1-ssbssa@yahoo.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 14/09/2023 18:27, Hannes Domani via Gdb-patches wrote: > Changes introduced by commit 9e8915c6cee5c37637521b424d723e990e06d597 > caused a regression that meant hardware watchpoint stops would not > trigger in reverse execution or replay mode. This was documented in > PR breakpoints/21969. > The problem is that record_check_stopped_by_breakpoint always overwrites > record_full_stop_reason, thus loosing the TARGET_STOPPED_BY_WATCHPOINT > value which would be checked afterwards. > > This commit fixes that by checking if record_full_stop_reason is > TARGET_STOPPED_BY_BREAKPOINT and, if so, not overriding it. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21969 > --- Hi! Thanks for the quick turn around for this patch! > gdb/record-full.c | 4 +++- > gdb/testsuite/gdb.reverse/watch-reverse.exp | 4 ++++ > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gdb/record-full.c b/gdb/record-full.c > index faf8b595d22..da785ef4b2a 100644 > --- a/gdb/record-full.c > +++ b/gdb/record-full.c > @@ -1382,7 +1382,9 @@ record_full_wait_1 (struct target_ops *ops, > > /* check breakpoint */ > tmp_pc = regcache_read_pc (regcache); > - if (record_check_stopped_by_breakpoint > + if (record_full_stop_reason > + != TARGET_STOPPED_BY_WATCHPOINT > + && record_check_stopped_by_breakpoint So I did some more digging on this, based on your response to the v1 email, copied here for convenience: I just tried this, with this change it suddenly shows SIGTRAP instead of hit watchpoints, so I will keep it as it is now. The reason it shows a SIGTRAP is that record_full_stop_reason ended up over-written anyway to stop_no_reason, so you are right that just flipping isn't enough. If you were to put this call in an "else if", instead of unrelated ifs, the issue stops happening. But I wonder if this is the right place to solve it anyway. I think record_check_stopped_by_breakpoint should just not overwrite record_full_stop_reason at all times. It seems that since record_check_stopped_by_breakpoint was introduced in 9e8915c6cee5c37637521b424d723e990e06d597 by Pedro (back in 2015), it was already indiscriminately overwriting the reason. I changed that locally and see no regressions and it also fixes this issue. Pedro, do you happen to remember why you added this back then? > (aspace, tmp_pc, &record_full_stop_reason)) > { > if (record_debug) > diff --git a/gdb/testsuite/gdb.reverse/watch-reverse.exp b/gdb/testsuite/gdb.reverse/watch-reverse.exp > index 6b81a6fdf88..a7126ac9b1d 100644 > --- a/gdb/testsuite/gdb.reverse/watch-reverse.exp > +++ b/gdb/testsuite/gdb.reverse/watch-reverse.exp > @@ -118,8 +118,12 @@ gdb_test "continue" \ > ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \ > "watchpoint hit in reverse, fifth time" > > +gdb_test_no_output "disable \$bpnum" "disable non-hw watchpoint" > + > gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints" > > +gdb_test_no_output "enable \$bpnum" "enable hw watchpoint" > + > ### > ### > ### This is a better solution! nice catch :) I did forget to mention in last email (sorry =/ ) but there is a second test to do with watchpoints, called watch-precsave.exp, that - from what I gather - should always be the same as watch-reverse, but it uses a pre-recorded execution instead. I tried the same trick of disabling and re-enabling the watchpoints, but it didn't trigger the bug on that one (and just blindly clean-restarting and redoing the start also didn't work), I think it needs some work too. Or at least some investigation about if the bug does trigger on that scenario. -- Cheers, Guinevere Larsen She/Her/Hers