Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: Stephen.Kilbane@analog.com,	Stuart.Henderson@analog.com,
	David.Gibson@analog.com
Subject: [PATCH] sim: add --map-info option
Date: Wed, 01 Dec 2010 16:15:00 -0000	[thread overview]
Message-ID: <1291219863-18458-1-git-send-email-vapier@gentoo.org> (raw)

There are options for listing the current device/hw tree and memory
regions, but no way to find out at run time all the current mappings.
So add a new --map-info option akin to the --memory-info option which
displays all the current mappings.

Signed-off-by: Mike Frysinger <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.
---
 sim/common/sim-memopt.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c
index 47b6c9e..9f58ec5 100644
--- a/sim/common/sim-memopt.c
+++ b/sim/common/sim-memopt.c
@@ -67,7 +67,8 @@ enum {
   OPTION_MEMORY_ALIAS,
   OPTION_MEMORY_CLEAR,
   OPTION_MEMORY_FILL,
-  OPTION_MEMORY_MAPFILE
+  OPTION_MEMORY_MAPFILE,
+  OPTION_MAP_INFO
 };
 
 static DECLARE_OPTION_HANDLER (memory_option_handler);
@@ -113,6 +114,9 @@ static const OPTION memory_options[] =
   { {"info-memory", no_argument, NULL, OPTION_MEMORY_INFO },
       '\0', NULL, NULL,
       memory_option_handler },
+  { {"map-info", no_argument, NULL, OPTION_MAP_INFO },
+      '\0', NULL, "List mapped regions",
+      memory_option_handler },
 
   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL }
 };
@@ -520,6 +524,51 @@ memory_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
 	break;
       }
 
+    case OPTION_MAP_INFO:
+      {
+	sim_core *memory;
+	unsigned nr_map;
+
+	for (memory = STATE_CORE (sd), nr_map = 0; nr_map < nr_maps; ++nr_map)
+	  {
+	    sim_core_map *map = &memory->common.map[nr_map];
+	    sim_core_mapping *mapping = map->first;
+
+	    if (!mapping)
+	      continue;
+
+	    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);
+
+	    do
+	      {
+		unsigned modulo;
+		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);
+		sim_io_printf (sd, "\n");
+		mapping = mapping->next;
+	      }
+	    while (mapping);
+	  }
+
+	return SIM_RC_OK;
+	break;
+      }
+
     default:
       sim_io_eprintf (sd, "Unknown memory option %d\n", opt);
       return SIM_RC_FAIL;
-- 
1.7.3.1


             reply	other threads:[~2010-12-01 16:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-01 16:15 Mike Frysinger [this message]
2010-12-14  7:36 ` Joel Brobecker
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=1291219863-18458-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=David.Gibson@analog.com \
    --cc=Stephen.Kilbane@analog.com \
    --cc=Stuart.Henderson@analog.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