From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9201 invoked by alias); 27 Feb 2011 21:36:14 -0000 Received: (qmail 9133 invoked by uid 22791); 27 Feb 2011 21:36:13 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Feb 2011 21:36:06 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1RLa5PC005749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 27 Feb 2011 16:36:05 -0500 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1RLa2To026486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 27 Feb 2011 16:36:04 -0500 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p1RLa2Il021824; Sun, 27 Feb 2011 22:36:02 +0100 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id p1RLa1cs021822; Sun, 27 Feb 2011 22:36:01 +0100 Date: Sun, 27 Feb 2011 21:41:00 -0000 From: Jan Kratochvil To: Michael Snyder Cc: "gdb-patches@sourceware.org" , Doug Evans Subject: Re: [RFA] off by one array reference in i386-low.c/i386_show_dr Message-ID: <20110227213601.GA21759@host1.dyn.jankratochvil.net> References: <4D698427.2050301@vmware.com> <20110227164646.GA15468@host1.dyn.jankratochvil.net> <4D6AC1C3.10508@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D6AC1C3.10508@vmware.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00849.txt.bz2 On Sun, 27 Feb 2011 22:27:31 +0100, Michael Snyder wrote: > Jan Kratochvil wrote: > >Hi Michael, > >On Sat, 26 Feb 2011 23:52:23 +0100, Michael Snyder wrote: > >>--- i386-low.c 1 Jan 2011 15:33:24 -0000 1.5 > >>+++ i386-low.c 26 Feb 2011 22:48:38 -0000 > >/* A macro to loop over all debug registers. */ > >#define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++) > >>@@ -195,7 +195,7 @@ i386_show_dr (struct i386_debug_reg_stat > > ALL_DEBUG_REGISTERS(i) > > { > > printf_unfiltered ("\ > >> \tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n", > >> i, paddress (state->dr_mirror[i]), > >> state->dr_ref_count[i], > >>- i + 1, paddress (state->dr_mirror[i + 1]), > >>+ i + 1, paddress (state->dr_mirror[i]), > >> state->dr_ref_count[i + 1]); > >> i++; > >> } > > > >-> > > CONTROL (DR7): 0000000000090101 STATUS (DR6): 0000000000004000 > > DR0: addr=0x0000000001c31f30, ref.count=1 DR1: addr=0x0000000000000000, ref.count=0 > > DR2: addr=0x0000000000000000, ref.count=0 DR3: addr=0x0000000000000000, ref.count=0 > > > >I do not see a bug there; still it could be better commented. > > The bug is that when "i" is 3, "i + 1" is 4, and the array only runs > from 0 to 3. But "i" is never 3. "i" is 0 during the first cycle and 2 during the second cycle. And then the for cycle ends. There is no 1 and there is no 3. Regards, Jan