From: Joel Brobecker <brobecker@adacore.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org, Stephen.Kilbane@analog.com,
Stuart.Henderson@analog.com, David.Gibson@analog.com
Subject: Re: [PATCH] sim: add --map-info option
Date: Tue, 14 Dec 2010 07:36:00 -0000 [thread overview]
Message-ID: <20101214073558.GS2596@adacore.com> (raw)
In-Reply-To: <1291219863-18458-1-git-send-email-vapier@gentoo.org>
> 2010-12-01 Mike Frysinger <vapier@gentoo.org>
>
> * sim-memopt.c (OPTION_MAP_INFO): Define.
> (memory_options): Handle --map-info.
> (memory_option_handler): Handle OPTION_MAP_INFO.
Some questions...
> + for (memory = STATE_CORE (sd), nr_map = 0; nr_map < nr_maps; ++nr_map)
Wouldn't it make sense to hoist the assignment to memory out of
the for initial assignment? It's never changed during the loop...
> + if (nr_map <= io_map)
> + sim_io_printf (sd, "%s maps:\n",
> + (nr_map == read_map) ? "read" :
> + (nr_map == write_map) ? "write" :
> + (nr_map == exec_map) ? "exec" :
> + /*(nr_map == io_map) ?*/ "io");
> + else
> + sim_io_printf (sd, "??? (%u) maps:\n", nr_map);
I rather you used a case statement or series of if's, in this case
than assume that there are only 4 values <= io_map and thus if it's
not read_map or write_map or exec_map, then it's io_map. How about:
/* Return "read", or "write", or ... if valid nr_map.
Otherwise return null; */
char *
io_map_to_str (unsigned nr_map)
{
[...]
And then you can use that function to do:
map_str = io_map_to_str (nr_map);
if (map_str)
sim_io_printf ("%s maps:\n", map_str);
else
sim_io_printf ("??? (%u) maps:\n", nr_map);
> + do
> + {
> + unsigned modulo;
Empty line after local variable declarations.
> + sim_io_printf (sd, " map ");
> + if (mapping->space != 0)
> + sim_io_printf (sd, "0x%lx:", (long) mapping->space);
> + sim_io_printf (sd, "0x%08lx", (long) mapping->base);
> + if (mapping->level != 0)
> + sim_io_printf (sd, "@0x%lx", (long) mapping->level);
> + sim_io_printf (sd, ",0x%lx", (long) mapping->nr_bytes);
> + modulo = mapping->mask + 1;
> + if (modulo != 0)
> + sim_io_printf (sd, "%%0x%lx", (long) modulo);
I don't understand the necessity to cast everything to long. Can you
explain?
Thanks,
--
Joel
next prev parent reply other threads:[~2010-12-14 7:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 16:15 Mike Frysinger
2010-12-14 7:36 ` Joel Brobecker [this message]
2010-12-14 15:17 ` Mike Frysinger
2010-12-14 18:34 ` Mike Frysinger
2010-12-14 18:50 ` Pedro Alves
2010-12-14 19:03 ` Mike Frysinger
2010-12-14 19:12 ` Pedro Alves
2010-12-14 19:30 ` Mike Frysinger
2010-12-15 4:54 ` Joel Brobecker
2010-12-15 11:50 ` Mike Frysinger
2010-12-14 18:37 ` [PATCH v2] " Mike Frysinger
2010-12-15 5:02 ` Joel Brobecker
2010-12-15 11:21 ` Mike Frysinger
2010-12-15 11:48 ` Joel Brobecker
2010-12-15 12:02 ` [toolchain-devel] " Mike Frysinger
2010-12-15 13:16 ` Eli Zaretskii
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=20101214073558.GS2596@adacore.com \
--to=brobecker@adacore.com \
--cc=David.Gibson@analog.com \
--cc=Stephen.Kilbane@analog.com \
--cc=Stuart.Henderson@analog.com \
--cc=gdb-patches@sourceware.org \
--cc=vapier@gentoo.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