From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52221 invoked by alias); 26 Jun 2018 16:03:27 -0000 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 Received: (qmail 52124 invoked by uid 89); 26 Jun 2018 16:03:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=decides X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 16:03:24 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7895A79D36; Tue, 26 Jun 2018 16:03:23 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEFAA111763C; Tue, 26 Jun 2018 16:03:22 +0000 (UTC) Subject: Re: [PATCH 1/2] Minor reorganization of fetch_registers/store_registers in windows-nat.c To: Joel Brobecker , gdb-patches@sourceware.org References: <1529952947-48942-1-git-send-email-brobecker@adacore.com> <1529952947-48942-2-git-send-email-brobecker@adacore.com> From: Pedro Alves Message-ID: Date: Tue, 26 Jun 2018 16:03:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1529952947-48942-2-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00618.txt.bz2 On 06/25/2018 07:55 PM, Joel Brobecker wrote: > This patch is a small reorganizational patch that splits > do_windows_fetch_inferior_registers into two parts: > > (a) One part that first reloads the thread's context when needed, > and then decides based on the given register number whether > one register needs to be fetched or all of them. > > This part is moved to windows_nat_target::fetch_registers. > > (b) The rest of the code, which actually fetches the register value > and supplies it to the regcache. > > A similar treatment is applied to do_windows_store_inferior_registers. > > This change is preparation work for changing the way we calculate > the location of a given register in the thread context structure, > and should be a no op. > I agree this looks clearer without the recursion. LGTM. A couple nits on comments below. > diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c > index 620e25c..c51ef8f 100644 > --- a/gdb/windows-nat.c > +++ b/gdb/windows-nat.c > @@ -528,14 +528,59 @@ windows_delete_thread (const ptid_t &ptid, DWORD exit_code) > } > } > > +/* Fetches register number R from the given windows_thread_info, > + and supplies its value to the given regcache. > + > + This function assumes that R is either null or positive. A failed > + assertion is raised if that is not true. R is an integer, talking about "null" gave me pause. I'd suggest saying either "zero" instead of null, or say "assumes non-negative". > + > + This function assumes that TH->RELOAD_CONTEXT is not set, meaning > + that the windows_thread_info has an up-to-date context. A failed > + assertion is raised if that assumption is violated. */ > + > static void > -do_windows_fetch_inferior_registers (struct regcache *regcache, > - windows_thread_info *th, int r) > +windows_fetch_one_register (struct regcache *regcache, > + windows_thread_info *th, int r) > { > > static void > -do_windows_store_inferior_registers (const struct regcache *regcache, > - windows_thread_info *th, int r) > +windows_store_one_register (const struct regcache *regcache, > + windows_thread_info *th, int r) Add similar leading comment? Thanks, Pedro Alves