This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
A problem about read / access watchpoint
- From: Wu Zhou <woodzltc at cn dot ibm dot com>
- To: gdb at sources dot redhat dot com
- Cc: anton at au1 dot ibm dot com, pgilliam at us dot ibm dot com
- Date: Sun, 15 Jan 2006 19:21:21 +0800 (CST)
- Subject: A problem about read / access watchpoint
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