From: Doug Evans <xdje42@gmail.com>
To: Andreas Arnez <arnez@linux.vnet.ibm.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 17:38:00 -0000 [thread overview]
Message-ID: <m3iohj4d93.fsf@sspiff.org> (raw)
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")
Andreas Arnez <arnez@linux.vnet.ibm.com> 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.
next prev parent reply other threads:[~2014-12-10 17:38 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 [this message]
2014-12-10 18:29 ` Andreas Arnez
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=m3iohj4d93.fsf@sspiff.org \
--to=xdje42@gmail.com \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).