Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* A problem about read / access watchpoint
@ 2006-01-15 11:21 Wu Zhou
  2006-01-16  7:17 ` Jim Blandy
  0 siblings, 1 reply; 4+ messages in thread
From: Wu Zhou @ 2006-01-15 11:21 UTC (permalink / raw)
  To: gdb; +Cc: anton, pgilliam

In the process of writing a testcase for read / access watchpoint, I find 
something very strange: read/access watchpoints don't always work as 
expected.  Here is a simplified example:

1 #include <stdio.h>
2
3 int var0 = 0;
4 
5 void subr (int *var1)
6 {
7   printf ("just to do sth\n");
8 }
9
10 void main (int argc, char **argv)
11 {
12  int var1 = 0;
13
14  subr (&var1);
15  var0 = var1;
16  printf ("var0 = %d, var1 = %d\n", var0, var1);
17 }

if I set read watchpoint on var1, it will only catch the watchpoint at the 
line 16 (for both x86 and ppc64).  In my opinion, it should stop at line 
15 as well.

if I set access watchpoint on var1, it will stop at line 12, 15, 16 on 
ppc64, and only stop line 12, 16 on x86. 

I did some tracing on that, and find that the kernel _did_ issue signal 
trap on line 15, and gdb could also get the stopped data address by 
ptrace. But when gdb call watchpoint_check to check if the value changed 
or not. It will reports WP_VALUE_CHANGED, which really confuse me.

I am now reading the code of watchpoint_check, but I don't understand why 
it will compare the new_val with b->val, and not bs->old_value.  The code 
following the comparison is also out of my understanding:

      struct value *mark = value_mark ();
      struct value *new_val = evaluate_expression (bs->breakpoint_at->exp);
      if (!value_equal (b->val, new_val))
	{
	  release_value (new_val);
	  value_free_to_mark (mark);
	  bs->old_val = b->val;
	  b->val = new_val;
	  /* We will stop here */
	  return WP_VALUE_CHANGED;
	}

Anyone can help me out of this question?  Thanks a lot.

Regards
- Wu Zhou


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-01-16 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-15 11:21 A problem about read / access watchpoint Wu Zhou
2006-01-16  7:17 ` Jim Blandy
2006-01-16  9:59   ` Wu Zhou
2006-01-16 10:12   ` Wu Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox