From patchwork Sun Jul 22 14:34:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 172517 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 B23C92C0128 for ; Mon, 23 Jul 2012 00:34:56 +1000 (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=1343572498; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=cNjC+Re mlxR7Eb9m2AAK/rW7Q0Q=; b=Azezo+FPj7RLvsnQCMLBOFoA3DzIczxQIb0Tpv9 IJRDSjOZvU5q8ZL2+GIwpz0ZcafoUS3KeCXNX6mZdzVD8uQWvyHso3vCJK9/7Xlx anriV5mnfe1/9F4ct8pbnOPsvjeh6tOezoA3Ly6wqgG6hCf9iHc1fef7UTo0ButR zENo= 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:MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=s9tetUXOp31JGZfkUDPWsyl9vWsCmoAlOoGp01c/ntiS3YR+eVLlzkd2lYG6iY 6wylHOdCzK9M+uiR8D2pXp9Ott3lOXgXU4R8AUMCKshdWNhYLE4DjpYVq7ctznQj 2KL9PoUWtdd+3Q0U7IBBmhDtH/0yCgd5SxaW6Uscl+MiY=; Received: (qmail 29732 invoked by alias); 22 Jul 2012 14:34:52 -0000 Received: (qmail 29232 invoked by uid 22791); 22 Jul 2012 14:34:50 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 Jul 2012 14:34:36 +0000 Received: by lbol5 with SMTP id l5so9127149lbo.20 for ; Sun, 22 Jul 2012 07:34:35 -0700 (PDT) Received: by 10.112.42.164 with SMTP id p4mr6106749lbl.54.1342967675087; Sun, 22 Jul 2012 07:34:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.4.229 with HTTP; Sun, 22 Jul 2012 07:34:14 -0700 (PDT) From: Steven Bosscher Date: Sun, 22 Jul 2012 16:34:14 +0200 Message-ID: Subject: [patch][gcov] Clarify the internals a bit To: GCC Patches Cc: Jan Hubicha , Nathan Sidwell 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 Hello, While reading up on how gcov/profiling works, I noticed that there are a lot of places where the notes file is still referred to as the "basic block graph" file. Also, the gcov manual has not been updated for -fprofile-dir. The attached patch addresses these issues, so that the next gcov newbie hopefully has an easier time understanding how everything fits together. Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? Ciao! Steven gcc/ * coverage.c: Refer to "notes file" instead of "graph file" in all comments. Explain history of bbg prefix. * gcov-io.h: Likewise. * gcov.c: Likewise. (find_source): Likewise in fnotice. (read_graph_file): Likewise. (read_count_file): Likewise. * doc/gcov.texi: Document -fprofile-dir flag. Add "notes file" and "data file" explicitly in the explanation of the files. libgcc/ * libgcov.c (__gcov_ior_profiler): Benign comment fix. Index: gcc/coverage.c =================================================================== --- gcc/coverage.c (revision 189747) +++ gcc/coverage.c (working copy) @@ -97,14 +97,16 @@ static GTY(()) tree gcov_info_var; static GTY(()) tree gcov_fn_info_type; static GTY(()) tree gcov_fn_info_ptr_type; -/* Name of the output file for coverage output file. If this is NULL - we're not writing to the notes file. */ +/* Name of the notes (gcno) output file. The "bbg" prefix is for + historical reasons, when the notes file contained only the + basic block graph notes. + If this is NULL we're not writing to the notes file. */ static char *bbg_file_name; -/* File stamp for graph file. */ +/* File stamp for notes file. */ static unsigned bbg_file_stamp; -/* Name of the count data file. */ +/* Name of the count data (gcda) file. */ static char *da_file_name; /* Hash table of count data. */ @@ -566,7 +568,7 @@ coverage_compute_cfg_checksum (void) return chksum; } -/* Begin output to the graph file for the current function. +/* Begin output to the notes file for the current function. Writes the function header. Returns nonzero if data should be output. */ int @@ -1079,7 +1081,7 @@ coverage_obj_finish (VEC(constructor_elt } /* Perform file-level initialization. Read in data file, generate name - of graph file. */ + of notes file. */ void coverage_init (const char *filename) @@ -1131,7 +1133,7 @@ coverage_init (const char *filename) } } -/* Performs file-level cleanup. Close graph file, generate coverage +/* Performs file-level cleanup. Close notes file, generate coverage variables and constructor. */ void Index: gcc/gcov-io.h =================================================================== --- gcc/gcov-io.h (revision 189747) +++ gcc/gcov-io.h (working copy) @@ -99,7 +99,7 @@ see the files COPYING3 and COPYING.RUNTI tags, values [41..9f] for the notes file and [a1..ff] for the data file. - The basic block graph file contains the following records + The notes file contains the following records note: unit function-graph* unit: header int32:checksum string:source function-graph: announce_function basic_blocks {arcs | lines}* Index: gcc/gcov.c =================================================================== --- gcc/gcov.c (revision 189747) +++ gcc/gcov.c (working copy) @@ -283,14 +283,16 @@ static unsigned total_executed; static time_t bbg_file_time; -/* Name and file pointer of the input file for the basic block graph. */ +/* Name of the notes (gcno) output file. The "bbg" prefix is for + historical reasons, when the notes file contained only the + basic block graph notes. */ static char *bbg_file_name; /* Stamp of the bbg file */ static unsigned bbg_stamp; -/* Name and file pointer of the input file for the arc count data. */ +/* Name and file pointer of the input file for the count data (gcda). */ static char *da_file_name; @@ -973,7 +975,7 @@ find_source (const char *file_name) { static int info_emitted; - fnotice (stderr, "%s:source file is newer than graph file '%s'\n", + fnotice (stderr, "%s:source file is newer than notes file '%s'\n", file_name, bbg_file_name); if (!info_emitted) { @@ -987,7 +989,7 @@ find_source (const char *file_name) return idx; } -/* Read the graph file. Return list of functions read -- in reverse order. */ +/* Read the notes file. Return list of functions read -- in reverse order. */ static function_t * read_graph_file (void) @@ -1003,13 +1005,13 @@ read_graph_file (void) if (!gcov_open (bbg_file_name, 1)) { - fnotice (stderr, "%s:cannot open graph file\n", bbg_file_name); + fnotice (stderr, "%s:cannot open notes file\n", bbg_file_name); return fns; } bbg_file_time = gcov_time (); if (!gcov_magic (gcov_read_unsigned (), GCOV_NOTE_MAGIC)) { - fnotice (stderr, "%s:not a gcov graph file\n", bbg_file_name); + fnotice (stderr, "%s:not a gcov notes file\n", bbg_file_name); gcov_close (); return fns; } @@ -1245,7 +1247,7 @@ read_count_file (function_t *fns) tag = gcov_read_unsigned (); if (tag != bbg_stamp) { - fnotice (stderr, "%s:stamp mismatch with graph file\n", da_file_name); + fnotice (stderr, "%s:stamp mismatch with notes file\n", da_file_name); goto cleanup; } Index: gcc/doc/gcov.texi =================================================================== --- gcc/doc/gcov.texi (revision 189747) +++ gcc/doc/gcov.texi (working copy) @@ -551,20 +551,23 @@ collected at that point to be dumped to @command{gcov} uses two files for profiling. The names of these files are derived from the original @emph{object} file by substituting the -file suffix with either @file{.gcno}, or @file{.gcda}. All of these files -are placed in the same directory as the object file, and contain data -stored in a platform-independent format. +file suffix with either @file{.gcno}, or @file{.gcda}. The files +contain coverage and profile data stored in a platform-independent format. +The @file{.gcno} files are placed in the same directory as the object +file. By default, the @file{.gcda} files are also stored in the same +directory as the object file, but the GCC @option{-profile-dir} option +may be used to store the @file{.gcda} files in a separate directory. -The @file{.gcno} file is generated when the source file is compiled with -the GCC @option{-ftest-coverage} option. It contains information to +The @file{.gcno} notes file is generated when the source file is compiled +with the GCC @option{-ftest-coverage} option. It contains information to reconstruct the basic block graphs and assign source line numbers to blocks. -The @file{.gcda} file is generated when a program containing object files -built with the GCC @option{-fprofile-arcs} option is executed. A -separate @file{.gcda} file is created for each object file compiled with -this option. It contains arc transition counts, and some summary -information. +The @file{.gcda} count data file is generated when a program containing +object files built with the GCC @option{-fprofile-arcs} option is executed. +A separate @file{.gcda} file is created for each object file compiled with +this option. It contains arc transition counts, value profile counts, and +some summary information. The full details of the file format is specified in @file{gcov-io.h}, and functions provided in that header file should be used to access the Index: libgcc/libgcov.c =================================================================== --- libgcc/libgcov.c (revision 189747) +++ libgcc/libgcov.c (working copy) @@ -1040,8 +1040,7 @@ __gcov_average_profiler (gcov_type *coun #endif #ifdef L_gcov_ior_profiler -/* Increase corresponding COUNTER by VALUE. FIXME: Perhaps we want - to saturate up. */ +/* Bitwise-OR VALUE into COUNTER. */ void __gcov_ior_profiler (gcov_type *counters, gcov_type value)