From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8349 invoked by alias); 14 Dec 2010 07:36:20 -0000 Received: (qmail 8185 invoked by uid 22791); 14 Dec 2010 07:36:18 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Dec 2010 07:36:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7BA962BABDB; Tue, 14 Dec 2010 02:36:10 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id FmGa06IYWtVa; Tue, 14 Dec 2010 02:36:10 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id F422B2BAB3D; Tue, 14 Dec 2010 02:36:09 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 1E107145B58; Tue, 14 Dec 2010 08:35:58 +0100 (CET) Date: Tue, 14 Dec 2010 07:36:00 -0000 From: Joel Brobecker To: Mike Frysinger 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 Message-ID: <20101214073558.GS2596@adacore.com> References: <1291219863-18458-1-git-send-email-vapier@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1291219863-18458-1-git-send-email-vapier@gentoo.org> User-Agent: Mutt/1.5.20 (2009-06-14) 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/msg00216.txt.bz2 > 2010-12-01 Mike Frysinger > > * 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