From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29992 invoked by alias); 11 Jul 2014 22:05:06 -0000 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 Received: (qmail 29964 invoked by uid 89); 11 Jul 2014 22:05:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f202.google.com Received: from mail-ie0-f202.google.com (HELO mail-ie0-f202.google.com) (209.85.223.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 11 Jul 2014 22:04:59 +0000 Received: by mail-ie0-f202.google.com with SMTP id rd18so359553iec.5 for ; Fri, 11 Jul 2014 15:04:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=z/H6ndly0UaJeC0Rb0fMTwzYyM0MhN4dR+Lfm49e8Is=; b=Z/sYAD5xfRUQLbKXVo85uEEWUkvsboJjmP9852ovmsIKIDT8eqY2PfYtAFkhtZDB02 095MxwOFytkUP42Gb7KJqwgNthQ5n0T6Zkk1U6xW673ytwiuYGYE5Ylfa1PgHyXsDkB/ 6vsUZxgybCMPjtWuz0xI8370VzqLiWC67Vhlk2zdtan3u4CgQBcn2E00RFRa/jm/fWxa 7xfAEB+yniU4Q7f/yAIu6x2xQb3jqo7AkCrNspc0eov2OJQ8Rq9eBrbwHiAhnyeedWhs nGUm+8l5bNKPif/Q1gFEKWyRDuCN3UnPHajpi9/P7PttPBEawA6JvI5jsp42lQq2GyYa W2+Q== X-Gm-Message-State: ALoCoQkdeHXNBcYQzJzBQPM7Y6Fjw5uDHQ4Kfe58qCwKUuONSNxnxykVgjlz561XHQ4y38GP73k7 X-Received: by 10.42.62.202 with SMTP id z10mr3000493ich.7.1405116297168; Fri, 11 Jul 2014 15:04:57 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id j43si263659yhh.5.2014.07.11.15.04.57 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Jul 2014 15:04:57 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 4D69A31C4EC; Fri, 11 Jul 2014 15:04:56 -0700 (PDT) From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21440.24455.769287.540494@ruffy.mtv.corp.google.com> Date: Sat, 12 Jul 2014 00:42:00 -0000 To: Pedro Alves Cc: Jan Kratochvil , eliz@gnu.org, gdb-patches@sourceware.org Subject: Re: [PATCH] Re: Regression for GDB global --statistics In-Reply-To: <53BEC275.8000004@redhat.com> References: <20140630171333.GA2225@host2.jankratochvil.net> <21437.45024.997531.453750@ruffy.mtv.corp.google.com> <53BEC275.8000004@redhat.com> X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00298.txt.bz2 Pedro Alves writes: > Hi Doug, > > On 07/09/2014 10:10 PM, Doug Evans wrote: > > Here's a patch. > > > > 2014-07-09 Doug Evans > > > > * maint.c (count_symtabs_and_blocks): Handle NULL > > current_program_space. > > It's not obvious to me how this can be NULL, given we initialize > it so early. If there's a good reason, could you please add > a comment here mentioning it? 2014-07-11 Doug Evans * maint.c (count_symtabs_and_blocks): Handle NULL current_program_space. (report_command_stats): Check global enabled flag in addition to recorded enabled flag. (make_command_stats_cleanup): Handle msg_type == 0, startup. testsuite/ * gdb.base/maint.exp: Update testing of per-command stats. diff --git a/gdb/maint.c b/gdb/maint.c index 5f34af3..c7a937c 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -830,13 +830,19 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_primary_symtabs_ptr, int nr_primary_symtabs = 0; int nr_blocks = 0; - ALL_SYMTABS (o, s) + /* When collecting statistics during startup, this is called before + pretty much anything in gdb has been initialized, and thus + current_program_space may be NULL. */ + if (current_program_space != NULL) { - ++nr_symtabs; - if (s->primary) + ALL_SYMTABS (o, s) { - ++nr_primary_symtabs; - nr_blocks += BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); + ++nr_symtabs; + if (s->primary) + { + ++nr_primary_symtabs; + nr_blocks += BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); + } } } @@ -856,7 +862,7 @@ report_command_stats (void *arg) struct cmd_stats *start_stats = (struct cmd_stats *) arg; int msg_type = start_stats->msg_type; - if (start_stats->time_enabled) + if (start_stats->time_enabled && per_command_time) { long cmd_time = get_run_time () - start_stats->start_cpu_time; struct timeval now_wall_time, delta_wall_time, wait_time; @@ -877,7 +883,7 @@ report_command_stats (void *arg) (long) delta_wall_time.tv_usec); } - if (start_stats->space_enabled) + if (start_stats->space_enabled && per_command_space) { #ifdef HAVE_SBRK char *lim = (char *) sbrk (0); @@ -894,7 +900,7 @@ report_command_stats (void *arg) #endif } - if (start_stats->symtab_enabled) + if (start_stats->symtab_enabled && per_command_symtab) { int nr_symtabs, nr_primary_symtabs, nr_blocks; @@ -920,8 +926,14 @@ make_command_stats_cleanup (int msg_type) { struct cmd_stats *new_stat; - /* Early exit if we're not reporting any stats. */ - if (!per_command_time + /* Early exit if we're not reporting any stats. It can be expensive to + compute the pre-command values so don't collect them at all if we're + not reporting stats. Alas this doesn't work in the startup case because + we don't know yet whether we will be reporting the stats. For the + startup case collect the data anyway (it should be cheap at this point), + and leave it to the reporter to decide whether to print them. */ + if (msg_type != 0 + && !per_command_time && !per_command_space && !per_command_symtab) return make_cleanup (null_cleanup, 0); @@ -930,7 +942,7 @@ make_command_stats_cleanup (int msg_type) new_stat->msg_type = msg_type; - if (per_command_space) + if (msg_type == 0 || per_command_space) { #ifdef HAVE_SBRK char *lim = (char *) sbrk (0); @@ -939,14 +951,14 @@ make_command_stats_cleanup (int msg_type) #endif } - if (per_command_time) + if (msg_type == 0 || per_command_time) { new_stat->start_cpu_time = get_run_time (); gettimeofday (&new_stat->start_wall_time, NULL); new_stat->time_enabled = 1; } - if (per_command_symtab) + if (msg_type == 0 || per_command_symtab) { int nr_symtabs, nr_primary_symtabs, nr_blocks; diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 64753b7..21d0a31 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -130,10 +130,11 @@ gdb_expect { # tests here!! gdb_test_no_output "maint check-symtabs" +# Test per-command stats. gdb_test_no_output "maint set per-command on" - -gdb_test "maint set per-command off" \ +gdb_test "pwd" \ "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)" +gdb_test_no_output "maint set per-command off" gdb_test "maint demangle" \ "\"maintenance demangle\" takes an argument to demangle\\."