Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: ppluzhnikov@google.com (Paul Pluzhnikov)
To: gdb-patches@sourceware.org
Cc: ppluzhnikov@google.com
Subject: [RFC] Interaction between HW watchpoints and 'set var'.
Date: Wed, 25 Nov 2009 17:52:00 -0000	[thread overview]
Message-ID: <20091125175149.BB89D76D99@ppluzhnikov.mtv.corp.google.com> (raw)

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


             reply	other threads:[~2009-11-25 17:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 17:52 Paul Pluzhnikov [this message]
2009-11-25 18:06 ` Joel Brobecker

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=20091125175149.BB89D76D99@ppluzhnikov.mtv.corp.google.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    /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