From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19779 invoked by alias); 10 Dec 2014 17:38:38 -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 19768 invoked by uid 89); 10 Dec 2014 17:38:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f44.google.com Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 17:38:37 +0000 Received: by mail-pa0-f44.google.com with SMTP id et14so3221979pad.31 for ; Wed, 10 Dec 2014 09:38:35 -0800 (PST) X-Received: by 10.66.145.234 with SMTP id sx10mr9209939pab.130.1418233115267; Wed, 10 Dec 2014 09:38:35 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id ta9sm3621075pbc.50.2014.12.10.09.38.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Dec 2014 09:38:34 -0800 (PST) From: Doug Evans To: Andreas Arnez 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 17:38:00 -0000 In-Reply-To: <1418232159-15289-2-git-send-email-arnez@linux.vnet.ibm.com> (Andreas Arnez's message of "Wed, 10 Dec 2014 18:22:38 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00216.txt.bz2 Andreas Arnez writes: > [...] > @@ -215,10 +217,38 @@ value_of_user_reg (int regnum, struct frame_info *frame) > return reg->read (frame, reg->baton); > } > > +static void > +maintenance_print_user_registers (char *args, int from_tty) > +{ > + struct gdbarch *gdbarch; > + struct gdb_user_regs *regs; > + struct user_reg *reg; > + int nr; > + > + 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); > + > + 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++; > + } > +} > + > [...] Hi. 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. In the column title you could use "Num" or some such. 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.