From: Wu Zhou <woodzltc@cn.ibm.com>
To: gdb@sources.redhat.com
Cc: anton@au1.ibm.com, pgilliam@us.ibm.com
Subject: A problem about read / access watchpoint
Date: Sun, 15 Jan 2006 11:21:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.64.0601151901120.15022@wks190239wss.cn.ibm.com> (raw)
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
next reply other threads:[~2006-01-15 11:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-15 11:21 Wu Zhou [this message]
2006-01-16 7:17 ` Jim Blandy
2006-01-16 9:59 ` Wu Zhou
2006-01-16 10:12 ` Wu Zhou
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=Pine.LNX.4.64.0601151901120.15022@wks190239wss.cn.ibm.com \
--to=woodzltc@cn.ibm.com \
--cc=anton@au1.ibm.com \
--cc=gdb@sources.redhat.com \
--cc=pgilliam@us.ibm.com \
/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