From patchwork Fri Dec 30 18:25:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 133692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6A411B6FBB for ; Sat, 31 Dec 2011 05:26:05 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1325874366; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=WoRhkD7mVCVWXz+0+cRw3vlFYAQ=; b=jU4GoggQGnxeDcS nGp0StP6K2GWcPLWBOx7qZ/FgbmNk/BEVJOhQ3xEOZ1B98VLmlKn8dppssmMlQM6 T8LJMmNRawzNzGPctGxgGiz3SFm2ur8k/po0ejAsYZbax+tfRpz7NQq6QT4Fu6Rk QcAMaSwqFuYOJ1v40BJOH/0TZ+fc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=CJmrpxhoq5il0APyAjjBSbfUqJuFvWJladLJvhOKGtOf3alKq+V+kLEdNzRO9C 6LF6+r1m5TOlKHdPY4L08Ls2CK/nsRaA6GXKSpPfv31VsBTt0bPD39hR9gw/aS6I 4Gy4Ud6CbyCMoaicHp3UJvqO3cjFC1KUIzPK+yUtzwD10=; Received: (qmail 17129 invoked by alias); 30 Dec 2011 18:26:02 -0000 Received: (qmail 17104 invoked by uid 22791); 30 Dec 2011 18:26:00 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Dec 2011 18:25:42 +0000 Received: by wgbdr1 with SMTP id dr1so21510877wgb.8 for ; Fri, 30 Dec 2011 10:25:41 -0800 (PST) Received: by 10.227.206.10 with SMTP id fs10mr40082432wbb.13.1325269540971; Fri, 30 Dec 2011 10:25:40 -0800 (PST) Received: by 10.227.206.10 with SMTP id fs10mr40082425wbb.13.1325269540884; Fri, 30 Dec 2011 10:25:40 -0800 (PST) Received: from [192.168.44.102] (5ac3c85d.bb.sky.com. [90.195.200.93]) by mx.google.com with ESMTPS id m13sm40434940wbh.0.2011.12.30.10.25.39 (version=SSLv3 cipher=OTHER); Fri, 30 Dec 2011 10:25:40 -0800 (PST) Message-ID: <4EFE021C.3040406@acm.org> Date: Fri, 30 Dec 2011 18:25:32 +0000 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16 MIME-Version: 1.0 To: GCC Patches Subject: [gcov] a few improvements X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I've committed this patch to fix and improve coverage reporting: 1) the time stamp local_tick will be -1 if the user overrides the random seed. In such cases the gcov data file should be deleted, just as it would if the time cannot be determined. 2) there was a typo in gcov_dump when dumping function data 3) when processing coverage data files, it's informative for gcov to emit the overall line coverage -- in addition to the individual line coverage. built & tested on i686-pc-linux-gnu nathan 2011-12-30 Nathan Sidwell * gcov.c (total_lines, total_executed): New global vars. (generate_results): Call executed_summary. (executed_summary): New function, broken out of ... (function_summary): ... here. Call it. * coverage.c (coverage_finish): Also check for local_tick == -1. * gcov-dump (tag_function): Correct labelling typo. Index: gcov.c =================================================================== --- gcov.c (revision 182730) +++ gcov.c (working copy) @@ -278,6 +278,9 @@ static unsigned a_names; /* Allocated static unsigned object_runs; static unsigned program_count; +static unsigned total_lines; +static unsigned total_executed; + /* Modification time of graph file. */ static time_t bbg_file_time; @@ -380,6 +383,7 @@ static void solve_flow_graph (function_t static void find_exception_blocks (function_t *); static void add_branch_counts (coverage_t *, const arc_t *); static void add_line_counts (coverage_t *, function_t *); +static void executed_summary (unsigned, unsigned); static void function_summary (const coverage_t *, const char *); static const char *format_gcov (gcov_type, gcov_type, int); static void accumulate_line_counts (source_t *); @@ -702,6 +706,8 @@ generate_results (const char *file_name) accumulate_line_counts (src); function_summary (&src->coverage, "File"); + total_lines += src->coverage.lines; + total_executed += src->coverage.lines_executed; if (flag_gcov_file && src->coverage.lines) { char *gcov_file_name @@ -724,6 +730,9 @@ generate_results (const char *file_name) } fnotice (stdout, "\n"); } + + if (!file_name) + executed_summary (total_lines, total_executed); } /* Release a function structure */ @@ -1666,20 +1675,25 @@ format_gcov (gcov_type top, gcov_type bo return buffer; } - -/* Output summary info for a function. */ +/* Summary of execution */ static void -function_summary (const coverage_t *coverage, const char *title) +executed_summary (unsigned lines, unsigned executed) { - fnotice (stdout, "%s '%s'\n", title, coverage->name); - - if (coverage->lines) + if (lines) fnotice (stdout, "Lines executed:%s of %d\n", - format_gcov (coverage->lines_executed, coverage->lines, 2), - coverage->lines); + format_gcov (executed, lines, 2), lines); else fnotice (stdout, "No executable lines\n"); +} + +/* Output summary info for a function or file. */ + +static void +function_summary (const coverage_t *coverage, const char *title) +{ + fnotice (stdout, "%s '%s'\n", title, coverage->name); + executed_summary (coverage->lines, coverage->lines_executed); if (flag_branches) { Index: coverage.c =================================================================== --- coverage.c (revision 182730) +++ coverage.c (working copy) @@ -1119,7 +1119,7 @@ coverage_finish (void) if (bbg_file_name && gcov_close ()) unlink (bbg_file_name); - if (!local_tick) + if (!local_tick || local_tick == (unsigned)-1) /* Only remove the da file, if we cannot stamp it. If we can stamp it, libgcov will DTRT. */ unlink (da_file_name); Index: gcov-dump.c =================================================================== --- gcov-dump.c (revision 182730) +++ gcov-dump.c (working copy) @@ -286,7 +286,7 @@ tag_function (const char *filename ATTRI { printf (" ident=%u", gcov_read_unsigned ()); printf (", lineno_checksum=0x%08x", gcov_read_unsigned ()); - printf (", cfg_checksum_checksum=0x%08x", gcov_read_unsigned ()); + printf (", cfg_checksum=0x%08x", gcov_read_unsigned ()); if (gcov_position () - pos < length) {