From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24557 invoked by alias); 16 Jan 2006 10:12:35 -0000 Received: (qmail 24547 invoked by uid 22791); 16 Jan 2006 10:12:34 -0000 X-Spam-Check-By: sourceware.org Received: from ausmtp04.au.ibm.com (HELO ausmtp04.au.ibm.com) (202.81.18.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 16 Jan 2006 10:12:32 +0000 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp04.au.ibm.com (8.12.10/8.12.10) with ESMTP id k0GAHh1k058570 for ; Mon, 16 Jan 2006 21:17:44 +1100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.250.237]) by sd0112e0.au.ibm.com (8.12.10/NCO/VERS6.8) with ESMTP id k0GAFZHN233828 for ; Mon, 16 Jan 2006 21:15:35 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11/8.13.3) with ESMTP id k0GACRdI001853 for ; Mon, 16 Jan 2006 21:12:27 +1100 Received: from wks190239wss.cn.ibm.com (wks190239wss.cn.ibm.com [9.181.133.187] (may be forged)) by d23av04.au.ibm.com (8.12.11/8.12.11) with ESMTP id k0GACKLF001773; Mon, 16 Jan 2006 21:12:23 +1100 Date: Mon, 16 Jan 2006 10:12:00 -0000 From: Wu Zhou To: Jim Blandy cc: gdb@sources.redhat.com, anton@au1.ibm.com, pgilliam@us.ibm.com Subject: Re: A problem about read / access watchpoint In-Reply-To: <8f2776cb0601152317x5146926ard81b8ad36ba2d362@mail.gmail.com> Message-ID: References: <8f2776cb0601152317x5146926ard81b8ad36ba2d362@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00139.txt.bz2 On Sun, 15 Jan 2006, Jim Blandy wrote: > On 1/15/06, Wu Zhou 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 : push %ebp 0x08048381 : mov %esp,%ebp 0x08048383 : sub $0x8,%esp 0x08048386 : and $0xfffffff0,%esp 0x08048389 : mov $0x0,%eax 0x0804838e : add $0xf,%eax 0x08048391 : add $0xf,%eax 0x08048394 : shr $0x4,%eax 0x08048397 : shl $0x4,%eax 0x0804839a : sub %eax,%esp 0x0804839c : movl $0x0,0xfffffffc(%ebp) 0x080483a3 : sub $0xc,%esp 0x080483a6 : lea 0xfffffffc(%ebp),%eax 0x080483a9 : push %eax 0x080483aa : call 0x8048368 0x080483af : add $0x10,%esp 0x080483b2 : mov 0xfffffffc(%ebp),%eax ===> read var1? 0x080483b5 : mov %eax,0x80495e8 0x080483ba : sub $0x4,%esp 0x080483bd : pushl 0xfffffffc(%ebp) ===> read var1? 0x080483c0 : pushl 0x80495e8 0x080483c6 : push $0x80484c8 0x080483cb : call 0x80482b0 0x080483d0 : add $0x10,%esp 0x080483d3 : leave 0x080483d4 : 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 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