From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69698 invoked by alias); 21 Oct 2018 21:26:43 -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 69228 invoked by uid 89); 21 Oct 2018 21:26:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=aside, simonmarchipolymtlca, simon.marchi@polymtl.ca, D*polymtl.ca X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 21 Oct 2018 21:26:41 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31C45C049D53 for ; Sun, 21 Oct 2018 21:26:40 +0000 (UTC) Received: from pinnacle.lan (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11A6F7C811 for ; Sun, 21 Oct 2018 21:26:40 +0000 (UTC) Date: Sun, 21 Oct 2018 21:26:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [PATCH] Introduce gdbarch_num_cooked_regs Message-ID: <20181021142638.31d9889e@pinnacle.lan> In-Reply-To: <20181021190133.10362-1-simon.marchi@polymtl.ca> References: <20181021190133.10362-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00467.txt.bz2 Hi Simon, On Sun, 21 Oct 2018 15:01:33 -0400 Simon Marchi wrote: > From: Simon Marchi > > This was part of another patchset I'm working on, but I thought it could > be a good cleanup on its own. > > The expression > > gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) > > is used quite often to find the number of cooked registers (raw + pseudo > registers). This patch introduces gdbarch_num_cooked_regs, which does > the equivalent. It substantially reduces required wrapping in some > places, so should improve readability. LGTM, aside from a question and one formatting problem... > diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c > index 1490ee28668a..b6e8f00a0ba1 100644 > --- a/gdb/m68hc11-tdep.c > +++ b/gdb/m68hc11-tdep.c > @@ -854,10 +854,7 @@ m68hc11_frame_unwind_cache (struct frame_info *this_frame, > > /* Adjust all the saved registers so that they contain addresses and not > offsets. */ > - for (i = 0; > - i < gdbarch_num_regs (gdbarch) > - + gdbarch_num_pseudo_regs (gdbarch) - 1; > - i++) > + for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++) > if (trad_frame_addr_p (info->saved_regs, i)) > { > info->saved_regs[i].addr += this_base; The " - 1" in the original expression was a mistake, right? (I spent a few minutes looking at the mc68hc11's pseudo register layout but can't find a reason for subtracting one.) > diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c > index 12382cddb357..9c34a070ae14 100644 > --- a/gdb/tui/tui-regs.c > +++ b/gdb/tui/tui-regs.c > @@ -206,10 +206,7 @@ tui_show_register_group (struct reggroup *group, > > /* See how many registers must be displayed. */ > nr_regs = 0; > - for (regnum = 0; > - regnum < gdbarch_num_regs (gdbarch) > - + gdbarch_num_pseudo_regs (gdbarch); > - regnum++) > + for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++) > { > const char *name; > > @@ -253,10 +250,7 @@ tui_show_register_group (struct reggroup *group, > > /* Now set the register names and values. */ > pos = 0; > - for (regnum = 0; > - regnum < gdbarch_num_regs (gdbarch) > - + gdbarch_num_pseudo_regs (gdbarch); > - regnum++) > + for (regnum = 0;regnum < gdbarch_num_cooked_regs (gdbarch); regnum++) Missing space between ; and "regnum". Kevin