From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4790 invoked by alias); 19 Oct 2011 01:05:45 -0000 Received: (qmail 4772 invoked by uid 22791); 19 Oct 2011 01:05:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 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; Wed, 19 Oct 2011 01:05:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B5C962BAB9D; Tue, 18 Oct 2011 21:05:27 -0400 (EDT) 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 niKOq7PrmzH5; Tue, 18 Oct 2011 21:05:27 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 61CC52BAB86; Tue, 18 Oct 2011 21:05:27 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 98FCF145615; Tue, 18 Oct 2011 21:05:22 -0400 (EDT) Date: Wed, 19 Oct 2011 02:08:00 -0000 From: Joel Brobecker To: John Wehle , Mike Frysinger Cc: gdb-patches@sourceware.org Subject: Re: GDB / SIM 7.3.1 Cosmetic patch for profile title Message-ID: <20111019010522.GE19246@adacore.com> References: <201110170428.p9H4SMZO025996@jwlab.FEITH.COM> <20111019004407.GD19246@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2JFBq9zoW8cOFH7v" Content-Disposition: inline In-Reply-To: <20111019004407.GD19246@adacore.com> 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: 2011-10/txt/msg00521.txt.bz2 --2JFBq9zoW8cOFH7v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 347 > As a side note, it took me a while to understand some of the logic. > It looks like `print_title_p' really means `we-have-some-profile-data'. > > So, if it was me, [...] In fact, here is what I meant. If someone can test it and confirm that I didn't screw something up, we could commit that. I think it's a lot clearer this way, no? -- Joel --2JFBq9zoW8cOFH7v Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sim-common-profile.diff" Content-length: 3049 commit 0e2091a0b6727c5ffb874df6c19bb08d7654f8d8 Author: Joel Brobecker Date: Tue Oct 18 18:01:04 2011 -0700 [sim] minor cleanup of sim-profile.c:profile_info Re-arange the code a little bit to make it clearer what the intent of each piece is. sim/common/ChangeLog: * sim-profile.c (sim_desc_has_profile_data): New function, mostly extracted out of profile_info. (profile_info): Rename `print_title_p' into `profile_data_collected_p'. Replace extracted-out code by call to sim_desc_has_profile_data. diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c index 83e964d..3221ecf 100644 --- a/sim/common/sim-profile.c +++ b/sim/common/sim-profile.c @@ -1109,6 +1109,32 @@ profile_print_addr_ranges (sim_cpu *cpu) } #endif +/* Return nonzero if some profile data has been collected, zero + otherwise. */ + +static int +sim_desc_has_profile_data (SIM_DESC sd) +{ + int i, c; + + /* FIXME: If the number of processors can be selected on the command line, + then MAX_NR_PROCESSORS will need to take an argument of `sd'. */ + + for (c = 0; c < MAX_NR_PROCESSORS; ++c) + { + sim_cpu *cpu = STATE_CPU (sd, c); + PROFILE_DATA *data = CPU_PROFILE_DATA (cpu); + + for (i = 0; i < MAX_PROFILE_VALUES; ++i) + if (PROFILE_FLAGS (data) [i]) + return 1; + } + + /* No profile data found. Return zero. */ + return 0; + +} + /* Top level function to print all summary profile information. It is [currently] intended that all such data is printed by this function. I'd rather keep it all in one place for now. To that end, MISC_CPU and @@ -1124,27 +1150,14 @@ profile_print_addr_ranges (sim_cpu *cpu) static void profile_info (SIM_DESC sd, int verbose) { - int i,c; - int print_title_p = 0; + int c; + const int profile_data_collected_p = sim_desc_has_profile_data (sd); - /* Only print the title if some data has been collected. */ /* ??? Why don't we just exit if no data collected? */ - /* FIXME: If the number of processors can be selected on the command line, - then MAX_NR_PROCESSORS will need to take an argument of `sd'. */ - - for (c = 0; c < MAX_NR_PROCESSORS && !print_title_p; ++c) - { - sim_cpu *cpu = STATE_CPU (sd, c); - PROFILE_DATA *data = CPU_PROFILE_DATA (cpu); - for (i = 0; i < MAX_PROFILE_VALUES; ++i) - if (PROFILE_FLAGS (data) [i]) - { - profile_printf (sd, cpu, "Summary profiling results:\n\n"); - print_title_p = 1; - break; - } - } + /* Only print the title if some data has been collected. */ + if (profile_data_collected_p) + profile_printf (sd, cpu, "Summary profiling results:\n\n"); /* Loop, cpu by cpu, printing results. */ @@ -1179,7 +1192,7 @@ profile_info (SIM_DESC sd, int verbose) } #ifdef SIM_HAVE_ADDR_RANGE - if (print_title_p + if (profile_data_collected_p && (PROFILE_INSN_P (cpu) || PROFILE_MODEL_P (cpu))) profile_print_addr_ranges (cpu); --2JFBq9zoW8cOFH7v--