From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16094 invoked by alias); 27 Feb 2011 21:42:56 -0000 Received: (qmail 16086 invoked by uid 22791); 27 Feb 2011 21:42:56 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Feb 2011 21:42:51 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id p1RLgVT1018116; Sun, 27 Feb 2011 22:42:31 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id p1RLgURF009060; Sun, 27 Feb 2011 22:42:30 +0100 (CET) Date: Sun, 27 Feb 2011 21:50:00 -0000 Message-Id: <201102272142.p1RLgURF009060@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: msnyder@vmware.com CC: jan.kratochvil@redhat.com, gdb-patches@sourceware.org, dje@google.com In-reply-to: <4D6AC1C3.10508@vmware.com> (message from Michael Snyder on Sun, 27 Feb 2011 13:27:31 -0800) Subject: Re: [RFA] off by one array reference in i386-low.c/i386_show_dr References: <4D698427.2050301@vmware.com> <20110227164646.GA15468@host1.dyn.jankratochvil.net> <4D6AC1C3.10508@vmware.com> 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/msg00851.txt.bz2 > Date: Sun, 27 Feb 2011 13:27:31 -0800 > From: Michael Snyder > > >> --- 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 can't be 3.