This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]