From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4538 invoked by alias); 14 Dec 2010 18:37:02 -0000 Received: (qmail 4395 invoked by uid 22791); 14 Dec 2010 18:36:59 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Dec 2010 18:36:54 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 72C601B400D; Tue, 14 Dec 2010 18:36:52 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Cc: toolchain-devel@blackfin.uclinux.org Subject: [PATCH v2] sim: add --map-info option Date: Tue, 14 Dec 2010 18:37:00 -0000 Message-Id: <1292351771-16396-1-git-send-email-vapier@gentoo.org> In-Reply-To: <1291219863-18458-1-git-send-email-vapier@gentoo.org> References: <1291219863-18458-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes 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 X-SW-Source: 2010-12/txt/msg00255.txt.bz2 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 2010-12-14 Mike Frysinger * sim-memopt.c (OPTION_MAP_INFO): Define. (memory_options): Handle --map-info. (memory_option_handler): Handle OPTION_MAP_INFO. --- v2 - convert to map_to_str - drop long casts where unnecessary sim/common/sim-memopt.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 44 insertions(+), 1 deletions(-) diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c index 47b6c9e..26b57a5 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,45 @@ 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; + + sim_io_printf (sd, "%s maps:\n", map_to_str (nr_map)); + do + { + unsigned modulo; + + sim_io_printf (sd, " map "); + if (mapping->space != 0) + sim_io_printf (sd, "0x%x:", mapping->space); + sim_io_printf (sd, "0x%08lx", (long) mapping->base); + if (mapping->level != 0) + sim_io_printf (sd, "@0x%x", mapping->level); + sim_io_printf (sd, ",0x%lx", (long) mapping->nr_bytes); + modulo = mapping->mask + 1; + if (modulo != 0) + sim_io_printf (sd, "%%0x%x", 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