From: Guinevere Larsen <blarsen@redhat.com>
To: Hannes Domani <ssbssa@yahoo.de>,
gdb-patches@sourceware.org, Pedro Alves <pedro@palves.net>
Subject: Re: [PATCH v2] Fix hardware watchpoints in replay mode
Date: Fri, 15 Sep 2023 12:09:36 +0200 [thread overview]
Message-ID: <2eb65a2d-aa80-5930-3033-bfd82baa2ed9@redhat.com> (raw)
In-Reply-To: <20230914162732.2077-1-ssbssa@yahoo.de>
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
next prev parent reply other threads:[~2023-09-15 10:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230914162732.2077-1-ssbssa.ref@yahoo.de>
2023-09-14 16:27 ` Hannes Domani
2023-09-15 10:09 ` Guinevere Larsen [this message]
2023-10-02 17:50 ` Hannes Domani
2023-11-01 13:57 ` Hannes Domani
2023-11-14 10:53 ` Hannes Domani
2023-11-20 13:09 ` Guinevere Larsen
2023-11-20 15:59 ` Hannes Domani
2023-11-21 12:52 ` Guinevere Larsen
2023-11-21 14:03 ` Hannes Domani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2eb65a2d-aa80-5930-3033-bfd82baa2ed9@redhat.com \
--to=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=ssbssa@yahoo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).