This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] Interaction between HW watchpoints and 'set var'.
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: gdb-patches at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Wed, 25 Nov 2009 09:51:49 -0800 (PST)
- Subject: [RFC] Interaction between HW watchpoints and 'set var'.
Greetings,
Consider the following test case:
--- cut ---
int x;
int main()
{
int i, j;
for (i = 0; i < 500; ++i) {
j = 0; // break here
x = 42;
j = i; // expect HW watchpoint stop
}
return 0;
}
--- cut ---
gdb64-cvs -q ./a.out
Reading symbols from /tmp/a.out...done.
(gdb) b 7
Breakpoint 1 at 0x400455: file foo.c, line 7.
(gdb) r
Breakpoint 1, main () at foo.c:7
7 j = 0; // break here
(gdb) watch x
Hardware watchpoint 2: x
(gdb) c
Hardware watchpoint 2: x
Old value = 0
New value = 42
main () at foo.c:9
9 j = i; // expect HW watchpoint stop
(gdb) c
Breakpoint 1, main () at foo.c:7
7 j = 0; // break here
So far, everything is working just as one would expect.
(gdb) p x
$1 = 42
(gdb) set var x = 1
(gdb) print x
$2 = 1
(gdb) c
Breakpoint 1, main () at foo.c:7
7 j = 0; // break here
(gdb) print x
$3 = 42
Why didn't HW watchpoint fire? Clearly 'x' changed from 1 to 42.
Setting 'debug infrun' shows that the watchpoint does indeed fire,
but is ignored by watchpoint_check() because GDB thinks the old
value was 42 as well. And GDB believes that because value_assign()
does not update breakpoints.
Now, I can fix that by installing deprecated_memory_changed_hook,
but the deprecated part gives me pause.
Should I create a new memory_changed observer and remove
deprecated_memory_changed_hook instead?
Thanks,
--
Paul Pluzhnikov