Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Wu Zhou <woodzltc@cn.ibm.com>
To: Jim Blandy <jimb@red-bean.com>
Cc: gdb@sources.redhat.com, anton@au1.ibm.com, pgilliam@us.ibm.com
Subject: Re: A problem about read / access watchpoint
Date: Mon, 16 Jan 2006 10:12:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0601161807400.10532@wks190239wss.cn.ibm.com> (raw)
In-Reply-To: <8f2776cb0601152317x5146926ard81b8ad36ba2d362@mail.gmail.com>


On Sun, 15 Jan 2006, Jim Blandy wrote:

> On 1/15/06, Wu Zhou <woodzltc@cn.ibm.com> wrote:
> > 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.
> 
> Just out of curiosity, could you post a disassembly of main?  The
> kernel is watching what the machine code version of the program does,
> and I wouldn't assume that it was the same as what the source code
> version does, even if you compile with -O0.
> 

This is the related debugging session on x86:

(gdb) p &var1
$1 = (int *) 0xbff312c4
(gdb) rwatch var1
Hardware read watchpoint 2: var1
(gdb) c
Continuing.
just to do sth
Hardware read watchpoint 2: var1

Value = 0
0x080483c0 in main (argc=1, argv=0xbff31354) at rwatch.c:17
17        printf ("var0 = %d, var1 = %d\n", var0, var1);
(gdb) disassemble main
Dump of assembler code for function main:
0x08048380 <main+0>:    push   %ebp
0x08048381 <main+1>:    mov    %esp,%ebp
0x08048383 <main+3>:    sub    $0x8,%esp
0x08048386 <main+6>:    and    $0xfffffff0,%esp
0x08048389 <main+9>:    mov    $0x0,%eax
0x0804838e <main+14>:   add    $0xf,%eax
0x08048391 <main+17>:   add    $0xf,%eax
0x08048394 <main+20>:   shr    $0x4,%eax
0x08048397 <main+23>:   shl    $0x4,%eax
0x0804839a <main+26>:   sub    %eax,%esp
0x0804839c <main+28>:   movl   $0x0,0xfffffffc(%ebp)
0x080483a3 <main+35>:   sub    $0xc,%esp
0x080483a6 <main+38>:   lea    0xfffffffc(%ebp),%eax
0x080483a9 <main+41>:   push   %eax
0x080483aa <main+42>:   call   0x8048368 <subr>
0x080483af <main+47>:   add    $0x10,%esp
0x080483b2 <main+50>:   mov    0xfffffffc(%ebp),%eax   ===> read var1?
0x080483b5 <main+53>:   mov    %eax,0x80495e8
0x080483ba <main+58>:   sub    $0x4,%esp
0x080483bd <main+61>:   pushl  0xfffffffc(%ebp)        ===> read var1?
0x080483c0 <main+64>:   pushl  0x80495e8
0x080483c6 <main+70>:   push   $0x80484c8
0x080483cb <main+75>:   call   0x80482b0 <printf@plt>
0x080483d0 <main+80>:   add    $0x10,%esp
0x080483d3 <main+83>:   leave
0x080483d4 <main+84>:   ret
End of assembler dump.
(gdb) bt
#0  0x080483c0 in main (argc=1, argv=0xbff31354) at rwatch.c:17
(gdb) info registers
eax            0x0      0
ecx            0x0      0
edx            0xf      15
ebx            0xaa7ff4 11173876
esp            0xbff312a8       0xbff312a8
ebp            0xbff312c8       0xbff312c8         (== &var - 4)
esi            0xbff31354       -1074588844
edi            0xbff312e0       -1074588960
eip            0x80483c0        0x80483c0 <main+64>
eflags         0x296    662
cs             0x73     115
ss             0x7b     123
ds             0x7b     123
es             0x7b     123
fs             0x0      0
gs             0x33     51 


I am not that comfortable with x86 assembly. But it seems that I am 
correct on the guess, right?

Regards
- Wu Zhou


      parent reply	other threads:[~2006-01-16 10:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-15 11:21 Wu Zhou
2006-01-16  7:17 ` Jim Blandy
2006-01-16  9:59   ` Wu Zhou
2006-01-16 10:12   ` Wu Zhou [this message]

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.0601161807400.10532@wks190239wss.cn.ibm.com \
    --to=woodzltc@cn.ibm.com \
    --cc=anton@au1.ibm.com \
    --cc=gdb@sources.redhat.com \
    --cc=jimb@red-bean.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