From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Doug Evans <xdje42@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 1/2] Add new GDB command "maint print user-registers"
Date: Wed, 10 Dec 2014 18:29:00 -0000 [thread overview]
Message-ID: <87oarbmk80.fsf@br87z6lw.de.ibm.com> (raw)
In-Reply-To: <m3iohj4d93.fsf@sspiff.org> (Doug Evans's message of "Wed, 10 Dec 2014 09:37:44 -0800")
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 */
next prev parent reply other threads:[~2014-12-10 18:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 17:22 [PATCH v3 0/2] Provide useful completer for "info registers" Andreas Arnez
2014-12-10 17:22 ` [PATCH v3 2/2] Provide " Andreas Arnez
2014-12-10 17:22 ` [PATCH v3 1/2] Add new GDB command "maint print user-registers" Andreas Arnez
2014-12-10 17:38 ` Doug Evans
2014-12-10 18:29 ` Andreas Arnez [this message]
2014-12-11 18:35 ` Doug Evans
2014-12-10 18:14 ` Eli Zaretskii
2014-12-10 18:33 ` Andreas Arnez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oarbmk80.fsf@br87z6lw.de.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=xdje42@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox