From patchwork Wed Dec 10 18:29:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 4151 Received: (qmail 5909 invoked by alias); 10 Dec 2014 18:29:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 5898 invoked by uid 89); 10 Dec 2014 18:29:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp17.uk.ibm.com Received: from e06smtp17.uk.ibm.com (HELO e06smtp17.uk.ibm.com) (195.75.94.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 18:29:57 +0000 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Dec 2014 18:29:54 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Dec 2014 18:29:52 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id D3FEB1B08040 for ; Wed, 10 Dec 2014 18:30:12 +0000 (GMT) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBAITpCV55443546 for ; Wed, 10 Dec 2014 18:29:51 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBAITp04006972 for ; Wed, 10 Dec 2014 11:29:51 -0700 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sBAIToSc006957; Wed, 10 Dec 2014 11:29:51 -0700 From: Andreas Arnez To: Doug Evans Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 1/2] Add new GDB command "maint print user-registers" References: <1418232159-15289-1-git-send-email-arnez@linux.vnet.ibm.com> <1418232159-15289-2-git-send-email-arnez@linux.vnet.ibm.com> Date: Wed, 10 Dec 2014 19:29:51 +0100 In-Reply-To: (Doug Evans's message of "Wed, 10 Dec 2014 09:37:44 -0800") Message-ID: <87oarbmk80.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121018-0029-0000-0000-000002232AD6 X-IsSubscribed: yes On Wed, Dec 10 2014, Doug Evans wrote: > Nit: I realize the rest of the file uses "nr" but > it's a horrible name. I hadn't read user-regs.c > in awhile, and was reading your patch absent that context. > I read "nr" and think "number of registers", > and that's the only thing that comes to mind > as a possible interpretation. > > I'm not asking you to change any other uses, > but can I ask that "nr" here be named "regnum" or some such. Yes, I agree that "nr" is a bad name. I will rename the variable to "regnum" instead. > In the column title you could use "Num" or some such. Hm, that would be inconsistent with "maint print registers", which uses "Nr" in the title as well. IMHO all user-visible interfaces should use the same title for this column. Maybe we can change that in a separate patch. > Also, I think the loop would be more readable thusly: > > + for (reg = regs->first; reg != NULL; reg = reg->next, regnum++) > > I have a slight preference for this instead: > > + for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum) > > but the rest of the file uses post-inc, so whatever. Right, this reduces code and improves clarity. Will change as suggested. Based on your suggestions, I will adjust the patch as indicated below. -- >8 -- Subject: Style improvements for maintenance_print_user_registers diff --git a/gdb/user-regs.c b/gdb/user-regs.c index 84ecf3a..b70dd45 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -223,21 +223,18 @@ maintenance_print_user_registers (char *args, int from_tty) struct gdbarch *gdbarch; struct gdb_user_regs *regs; struct user_reg *reg; - int nr; + int regnum; if (!target_has_registers) error (_("The program has no registers now.")); gdbarch = get_frame_arch (get_selected_frame (NULL)); regs = gdbarch_data (gdbarch, user_regs_data); - nr = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); + regnum = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); fprintf_unfiltered (gdb_stdout, " Nr Name\n"); - for (reg = regs->first; reg != NULL; reg = reg->next) - { - fprintf_unfiltered (gdb_stdout, "%3d %s\n", nr, reg->name); - nr++; - } + for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum) + fprintf_unfiltered (gdb_stdout, "%3d %s\n", regnum, reg->name); } extern initialize_file_ftype _initialize_user_regs; /* -Wmissing-prototypes */