public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/29603] New: Python Watchpoints are not deleted
@ 2022-09-23 8:02 j3.soon777 at gmail dot com
2022-09-23 8:03 ` [Bug python/29603] " j3.soon777 at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2022-09-23 8:02 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
Bug ID: 29603
Summary: Python Watchpoints are not deleted
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: j3.soon777 at gmail dot com
Target Milestone: ---
In Python, if we register a local software watchpoint and set the
`Breakpoint.stop' function to always return `False', the watchpoint will not be
deleted when going out of scope.
This cause gdb to incorrectly trigger the `Breakpoint.stop' function many more
times than it should.
This issue is reproduced in:
- GCC 7.5.0 & GDB 10.2 on Ubuntu 18.04,
- GCC 9.3.0 & GDB 9.2 on Ubuntu 20.04 (WSL on Windows),
- GCC 11.2.0 & GDB 12.0.90 on Ubuntu 22.04,
- and on current GDB HEAD (commit 8e037eae6823caf5b9cb5b4feb3de838abb25956).
Please see the attachment for the testing files.
Commands to reproduce:
gcc -g test.c
gdb a.out
(gdb) set can-use-hw-watchpoints 0
(gdb) b main
(gdb) r
(gdb) source test.py
(gdb) c
Continuing.
Watchpoint Hit: 1
Watchpoint Hit: 2
Watchpoint Hit: 3
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 4
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 5
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 6
...
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 1201
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 1202
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
Watchpoint Hit: 1203
[Inferior 1 (process 17119) exited normally]
Please note that the Watchpoint in the test file should only be hit 4 times.
I'm currently working on a patch to fix this bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
@ 2022-09-23 8:03 ` j3.soon777 at gmail dot com
2022-09-23 8:04 ` j3.soon777 at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2022-09-23 8:03 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
Johnson Sun <j3.soon777 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |j3.soon777 at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
2022-09-23 8:03 ` [Bug python/29603] " j3.soon777 at gmail dot com
@ 2022-09-23 8:04 ` j3.soon777 at gmail dot com
2022-09-23 8:04 ` j3.soon777 at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2022-09-23 8:04 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
--- Comment #1 from Johnson Sun <j3.soon777 at gmail dot com> ---
Created attachment 14352
--> https://sourceware.org/bugzilla/attachment.cgi?id=14352&action=edit
Test C code
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
2022-09-23 8:03 ` [Bug python/29603] " j3.soon777 at gmail dot com
2022-09-23 8:04 ` j3.soon777 at gmail dot com
@ 2022-09-23 8:04 ` j3.soon777 at gmail dot com
2022-09-25 5:36 ` j3.soon777 at gmail dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2022-09-23 8:04 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
--- Comment #2 from Johnson Sun <j3.soon777 at gmail dot com> ---
Created attachment 14353
--> https://sourceware.org/bugzilla/attachment.cgi?id=14353&action=edit
Test Python code
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
` (2 preceding siblings ...)
2022-09-23 8:04 ` j3.soon777 at gmail dot com
@ 2022-09-25 5:36 ` j3.soon777 at gmail dot com
2023-05-11 16:10 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2022-09-25 5:36 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
--- Comment #3 from Johnson Sun <j3.soon777 at gmail dot com> ---
Just send a patch to fix this issue. Please refer to:
https://sourceware.org/pipermail/gdb-patches/2022-September/192098.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
` (3 preceding siblings ...)
2022-09-25 5:36 ` j3.soon777 at gmail dot com
@ 2023-05-11 16:10 ` cvs-commit at gcc dot gnu.org
2024-01-14 14:26 ` ssbssa at sourceware dot org
2024-01-24 14:04 ` j3.soon777 at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-11 16:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
commit 6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
Author: Johnson Sun <j3.soon777@gmail.com>
Date: Thu May 11 23:46:20 2023 +0800
Disable out-of-scope watchpoints
Currently, when a local software watchpoint goes out of scope, GDB sets
the watchpoint's disposition to `delete at next stop' and then normal
stops (i.e., stop and wait for the next GDB command). When GDB normal
stops, it automatically deletes the breakpoints with their disposition
set to `delete at next stop'.
Suppose a Python script decides not to normal stop when a local
software watchpoint goes out of scope, the watchpoint will not be
automatically deleted even when its disposition is set to
`delete at next stop'.
Since GDB single-steps the program and tests the watched expression
after each instruction, not deleting the watchpoint causes the
watchpoint to be hit many more times than it should, as reported in
PR python/29603.
This was happening because the watchpoint is not deleted or disabled
when going out of scope.
This commit fixes this issue by disabling the watchpoint when going out
of scope. It also adds a test to ensure this feature isn't regressed in
the future.
Calling `breakpoint_auto_delete' on all kinds of stops (in
`fetch_inferior_event') seem to solve this issue, but is in fact
inappropriate, since `breakpoint_auto_delete' goes over all breakpoints
instead of just going through the bpstat chain (which only contains the
breakpoints that were hit right now).
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29603
Change-Id: Ia85e670b2bcba2799219abe4b6be3b582387e383
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
` (4 preceding siblings ...)
2023-05-11 16:10 ` cvs-commit at gcc dot gnu.org
@ 2024-01-14 14:26 ` ssbssa at sourceware dot org
2024-01-24 14:04 ` j3.soon777 at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-14 14:26 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--- Comment #5 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Sourceware Commits from comment #4)
> The master branch has been updated by Simon Marchi <simark@sourceware.org>:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
>
> commit 6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
> Author: Johnson Sun <j3.soon777@gmail.com>
> Date: Thu May 11 23:46:20 2023 +0800
>
> Disable out-of-scope watchpoints
>
> Currently, when a local software watchpoint goes out of scope, GDB sets
> the watchpoint's disposition to `delete at next stop' and then normal
> stops (i.e., stop and wait for the next GDB command). When GDB normal
> stops, it automatically deletes the breakpoints with their disposition
> set to `delete at next stop'.
>
> Suppose a Python script decides not to normal stop when a local
> software watchpoint goes out of scope, the watchpoint will not be
> automatically deleted even when its disposition is set to
> `delete at next stop'.
>
> Since GDB single-steps the program and tests the watched expression
> after each instruction, not deleting the watchpoint causes the
> watchpoint to be hit many more times than it should, as reported in
> PR python/29603.
>
> This was happening because the watchpoint is not deleted or disabled
> when going out of scope.
>
> This commit fixes this issue by disabling the watchpoint when going out
> of scope. It also adds a test to ensure this feature isn't regressed in
> the future.
>
> Calling `breakpoint_auto_delete' on all kinds of stops (in
> `fetch_inferior_event') seem to solve this issue, but is in fact
> inappropriate, since `breakpoint_auto_delete' goes over all breakpoints
> instead of just going through the bpstat chain (which only contains the
> breakpoints that were hit right now).
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29603
> Change-Id: Ia85e670b2bcba2799219abe4b6be3b582387e383
Can this be closed?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/29603] Python Watchpoints are not deleted
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
` (5 preceding siblings ...)
2024-01-14 14:26 ` ssbssa at sourceware dot org
@ 2024-01-24 14:04 ` j3.soon777 at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: j3.soon777 at gmail dot com @ 2024-01-24 14:04 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29603
Johnson Sun <j3.soon777 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #6 from Johnson Sun <j3.soon777 at gmail dot com> ---
(In reply to Hannes Domani from comment #5)
> (In reply to Sourceware Commits from comment #4)
> > The master branch has been updated by Simon Marchi <simark@sourceware.org>:
> >
> > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> > h=6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
> >
> > commit 6e96d8a9702d1fef3eb6de47bb84bdea578eb1bb
> > Author: Johnson Sun <j3.soon777@gmail.com>
> > Date: Thu May 11 23:46:20 2023 +0800
> >
> > Disable out-of-scope watchpoints
> >
> > Currently, when a local software watchpoint goes out of scope, GDB sets
> > the watchpoint's disposition to `delete at next stop' and then normal
> > stops (i.e., stop and wait for the next GDB command). When GDB normal
> > stops, it automatically deletes the breakpoints with their disposition
> > set to `delete at next stop'.
> >
> > Suppose a Python script decides not to normal stop when a local
> > software watchpoint goes out of scope, the watchpoint will not be
> > automatically deleted even when its disposition is set to
> > `delete at next stop'.
> >
> > Since GDB single-steps the program and tests the watched expression
> > after each instruction, not deleting the watchpoint causes the
> > watchpoint to be hit many more times than it should, as reported in
> > PR python/29603.
> >
> > This was happening because the watchpoint is not deleted or disabled
> > when going out of scope.
> >
> > This commit fixes this issue by disabling the watchpoint when going out
> > of scope. It also adds a test to ensure this feature isn't regressed in
> > the future.
> >
> > Calling `breakpoint_auto_delete' on all kinds of stops (in
> > `fetch_inferior_event') seem to solve this issue, but is in fact
> > inappropriate, since `breakpoint_auto_delete' goes over all breakpoints
> > instead of just going through the bpstat chain (which only contains the
> > breakpoints that were hit right now).
> >
> > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29603
> > Change-Id: Ia85e670b2bcba2799219abe4b6be3b582387e383
>
> Can this be closed?
Yes, this can be closed. Thank you for the reminder.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-24 14:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 8:02 [Bug python/29603] New: Python Watchpoints are not deleted j3.soon777 at gmail dot com
2022-09-23 8:03 ` [Bug python/29603] " j3.soon777 at gmail dot com
2022-09-23 8:04 ` j3.soon777 at gmail dot com
2022-09-23 8:04 ` j3.soon777 at gmail dot com
2022-09-25 5:36 ` j3.soon777 at gmail dot com
2023-05-11 16:10 ` cvs-commit at gcc dot gnu.org
2024-01-14 14:26 ` ssbssa at sourceware dot org
2024-01-24 14:04 ` j3.soon777 at gmail dot com
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).