public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/29480] New: [gdb] watchpoint condition on specific value change
@ 2022-08-12 11:42 vries at gcc dot gnu.org
2022-08-12 17:02 ` [Bug breakpoints/29480] " tromey at sourceware dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2022-08-12 11:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29480
Bug ID: 29480
Summary: [gdb] watchpoint condition on specific value change
Product: gdb
Version: HEAD
Status: NEW
Severity: enhancement
Priority: P2
Component: breakpoints
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Somebody asked on IRC:
...
is it possible to setup a watchpoint that fires off when the value of a memory
location changes from one specific value to another?
...
I wrote this test example:
...
$ cat test.c
int v = 0;
int
main (void)
{
v = 1;
v = 2;
v = 3;
v = 2;
return 0;
}
$ gcc -g test.c
...
and decided I wanted to set a watchpoint on the change from 3 to 2.
I suppose it's possible to do this in python somehow, but I decided to try
something more simple.
I wrote this patch that introduces two new convenience variables:
...
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 37f70a77721..90ec605aeeb 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5062,7 +5062,10 @@ watchpoint_check (bpstat *bs)
new_val)))
{
bs->old_val = b->val;
+ set_internalvar (lookup_internalvar ("_wp_old_val"),
+ bs->old_val.get ());
b->val = release_value (new_val);
+ set_internalvar (lookup_internalvar ("_wp_val"), b->val.get ());
b->val_valid = true;
if (new_val != NULL)
value_free_to_mark (mark);
...
and managed to do:
...
$ gdb -q -batch a.out -ex "watch v" -ex "cond 1 \$_wp_old_val == 3 && \$_wp_val
== 2" -ex run
Hardware watchpoint 1: v
Hardware watchpoint 1: v
Old value = 3
New value = 2
main () at test.c:12
12 return 0;
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug breakpoints/29480] [gdb] watchpoint condition on specific value change
2022-08-12 11:42 [Bug breakpoints/29480] New: [gdb] watchpoint condition on specific value change vries at gcc dot gnu.org
@ 2022-08-12 17:02 ` tromey at sourceware dot org
2022-08-12 17:35 ` vries at gcc dot gnu.org
2022-09-30 9:16 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2022-08-12 17:02 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29480
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
There's another bug somewhere, I think, about wanting
access to the previous value.
Seems like a good idea.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug breakpoints/29480] [gdb] watchpoint condition on specific value change
2022-08-12 11:42 [Bug breakpoints/29480] New: [gdb] watchpoint condition on specific value change vries at gcc dot gnu.org
2022-08-12 17:02 ` [Bug breakpoints/29480] " tromey at sourceware dot org
@ 2022-08-12 17:35 ` vries at gcc dot gnu.org
2022-09-30 9:16 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2022-08-12 17:35 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29480
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> There's another bug somewhere, I think, about wanting
> access to the previous value.
> Seems like a good idea.
Maybe this ( https://sourceware.org/bugzilla/show_bug.cgi?id=7349 ) one ?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug breakpoints/29480] [gdb] watchpoint condition on specific value change
2022-08-12 11:42 [Bug breakpoints/29480] New: [gdb] watchpoint condition on specific value change vries at gcc dot gnu.org
2022-08-12 17:02 ` [Bug breakpoints/29480] " tromey at sourceware dot org
2022-08-12 17:35 ` vries at gcc dot gnu.org
@ 2022-09-30 9:16 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2022-09-30 9:16 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29480
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |UNCONFIRMED
Ever confirmed|1 |0
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2022-September/192213.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-30 9:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 11:42 [Bug breakpoints/29480] New: [gdb] watchpoint condition on specific value change vries at gcc dot gnu.org
2022-08-12 17:02 ` [Bug breakpoints/29480] " tromey at sourceware dot org
2022-08-12 17:35 ` vries at gcc dot gnu.org
2022-09-30 9:16 ` vries at gcc dot gnu.org
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).