GCC Middle and Back End API Reference
gcov-tool.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "intl.h"
#include "diagnostic.h"
#include "version.h"
#include "gcov-io.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
Include dependency graph for gcov-tool.cc:

Functions

struct gcov_infogcov_profile_merge (struct gcov_info *, struct gcov_info *, int, int)
 
struct gcov_infogcov_profile_merge_stream (const char *, int, int)
 
int gcov_profile_overlap (struct gcov_info *, struct gcov_info *)
 
int gcov_profile_normalize (struct gcov_info *, gcov_type)
 
int gcov_profile_scale (struct gcov_info *, float, int, int)
 
struct gcov_infogcov_read_profile_dir (const char *, int)
 
void gcov_do_dump (struct gcov_info *, int, int)
 
const chargcov_get_filename (struct gcov_info *list)
 
void gcov_set_verbose (void)
 
static int unlink_profile_dir (const char *path)
 
static void gcov_output_files (const char *out, struct gcov_info *profile)
 
static int profile_merge (const char *d1, const char *d2, const char *out, int w1, int w2)
 
static void print_merge_usage_message (int error_p)
 
static void ATTRIBUTE_NORETURN merge_usage (void)
 
static int do_merge (int argc, char **argv)
 
static void print_merge_stream_usage_message (int error_p)
 
static void ATTRIBUTE_NORETURN merge_stream_usage (void)
 
static int do_merge_stream (int argc, char **argv)
 
static int profile_rewrite (const char *d1, const char *out, int64_t n_val, float scale, int n, int d)
 
static void print_rewrite_usage_message (int error_p)
 
static void ATTRIBUTE_NORETURN rewrite_usage (void)
 
static int do_rewrite (int argc, char **argv)
 
static int profile_overlap (const char *d1, const char *d2)
 
static void print_overlap_usage_message (int error_p)
 
static void ATTRIBUTE_NORETURN overlap_usage (void)
 
static int do_overlap (int argc, char **argv)
 
static void print_usage (int error_p)
 
static void print_version (void)
 
static int process_args (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

static bool verbose
 
static const struct option merge_options []
 
static const struct option merge_stream_options []
 
static const struct option rewrite_options []
 
static const struct option overlap_options []
 
int overlap_func_level
 
int overlap_obj_level
 
int overlap_hot_only
 
int overlap_use_fullname
 
double overlap_hot_threshold = 0.005
 
static const struct option options []
 

Function Documentation

◆ do_merge()

static int do_merge ( int argc,
char ** argv )
static
Driver for profile merge subcommand.   

References fatal_error(), gcov_set_verbose(), ggc_alloc(), input_location, merge_options, merge_usage(), NULL, profile_merge(), and verbose.

Referenced by main().

◆ do_merge_stream()

static int do_merge_stream ( int argc,
char ** argv )
static

◆ do_overlap()

static int do_overlap ( int argc,
char ** argv )
static

◆ do_rewrite()

static int do_rewrite ( int argc,
char ** argv )
static
Driver for profile rewrite subcommand.   

References fatal_error(), fnotice(), gcov_set_verbose(), ggc_alloc(), input_location, NULL, profile_rewrite(), rewrite_options, rewrite_usage(), and verbose.

Referenced by main().

◆ gcov_do_dump()

void gcov_do_dump ( struct gcov_info * ,
int ,
int  )
extern

◆ gcov_get_filename()

const char * gcov_get_filename ( struct gcov_info * list)
extern

Referenced by gcov_output_files().

◆ gcov_output_files()

static void gcov_output_files ( const char * out,
struct gcov_info * profile )
static
Output GCOV_INFO lists PROFILE to directory OUT. Note that
we will remove all the gcda files in OUT.   

References errno, F_OK, fatal_error(), free(), gcov_do_dump(), gcov_get_filename(), ggc_alloc(), input_location, NULL, and unlink_profile_dir().

Referenced by profile_merge(), and profile_rewrite().

◆ gcov_profile_merge()

struct gcov_info * gcov_profile_merge ( struct gcov_info * ,
struct gcov_info * ,
int ,
int  )
extern
Gcc offline profile processing tool support.  
Copyright (C) 2014-2024 Free Software Foundation, Inc.
   Contributed by Rong Xu <xur@google.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<http://www.gnu.org/licenses/>.   

Referenced by profile_merge().

◆ gcov_profile_merge_stream()

struct gcov_info * gcov_profile_merge_stream ( const char * ,
int ,
int  )
extern

Referenced by do_merge_stream().

◆ gcov_profile_normalize()

int gcov_profile_normalize ( struct gcov_info * ,
gcov_type  )
extern

Referenced by profile_rewrite().

◆ gcov_profile_overlap()

int gcov_profile_overlap ( struct gcov_info * ,
struct gcov_info *  )
extern

Referenced by profile_overlap().

◆ gcov_profile_scale()

int gcov_profile_scale ( struct gcov_info * ,
float ,
int ,
int  )
extern

Referenced by profile_rewrite().

◆ gcov_read_profile_dir()

struct gcov_info * gcov_read_profile_dir ( const char * ,
int  )
extern

◆ gcov_set_verbose()

void gcov_set_verbose ( void )
extern

◆ main()

int main ( int argc,
char ** argv )

◆ merge_stream_usage()

static void ATTRIBUTE_NORETURN merge_stream_usage ( void )
static
Print merge-stream usage and exit.   

References FATAL_EXIT_CODE, fnotice(), ggc_alloc(), and print_merge_stream_usage_message().

Referenced by do_merge_stream().

◆ merge_usage()

static void ATTRIBUTE_NORETURN merge_usage ( void )
static
Print merge usage and exit.   

References FATAL_EXIT_CODE, fnotice(), ggc_alloc(), and print_merge_usage_message().

Referenced by do_merge().

◆ overlap_usage()

static void ATTRIBUTE_NORETURN overlap_usage ( void )
static
Print overlap usage and exit.   

References FATAL_EXIT_CODE, fnotice(), ggc_alloc(), and print_overlap_usage_message().

Referenced by do_overlap().

◆ print_merge_stream_usage_message()

static void print_merge_stream_usage_message ( int error_p)
static
Usage message for profile merge-stream.   

References fnotice(), and ggc_alloc().

Referenced by merge_stream_usage(), and print_usage().

◆ print_merge_usage_message()

static void print_merge_usage_message ( int error_p)
static
Usage message for profile merge.   

References fnotice(), and ggc_alloc().

Referenced by merge_usage(), and print_usage().

◆ print_overlap_usage_message()

static void print_overlap_usage_message ( int error_p)
static
Usage message for profile overlap.   

References fnotice(), and ggc_alloc().

Referenced by overlap_usage(), and print_usage().

◆ print_rewrite_usage_message()

static void print_rewrite_usage_message ( int error_p)
static
Usage function for profile rewrite.   

References fnotice(), and ggc_alloc().

Referenced by print_usage(), and rewrite_usage().

◆ print_usage()

static void print_usage ( int error_p)
static
Print a usage message and exit.  If ERROR_P is nonzero, this is an error,
otherwise the output of --help.   

References FATAL_EXIT_CODE, fnotice(), ggc_alloc(), print_merge_stream_usage_message(), print_merge_usage_message(), print_overlap_usage_message(), print_rewrite_usage_message(), progname, and SUCCESS_EXIT_CODE.

◆ print_version()

static void print_version ( void )
static
Print version information and exit.   

References _, fnotice(), ggc_alloc(), progname, and SUCCESS_EXIT_CODE.

Referenced by process_args().

◆ process_args()

static int process_args ( int argc,
char ** argv )
static
Process args, return index to first non-arg.   

References ggc_alloc(), NULL, print_usage(), and print_version().

Referenced by main().

◆ profile_merge()

static int profile_merge ( const char * d1,
const char * d2,
const char * out,
int w1,
int w2 )
static
Merging profile D1 and D2 with weight as W1 and W2, respectively.
The result profile is written to directory OUT.
Return 0 on success.   

References d1, d2, fnotice(), gcov_output_files(), gcov_profile_merge(), gcov_read_profile_dir(), ggc_alloc(), and verbose.

Referenced by do_merge().

◆ profile_overlap()

static int profile_overlap ( const char * d1,
const char * d2 )
static
Driver function to computer the overlap score b/w profile D1 and D2.
Return 1 on error and 0 if OK.   

References d1, d2, gcov_profile_overlap(), gcov_read_profile_dir(), and ggc_alloc().

Referenced by do_overlap().

◆ profile_rewrite()

static int profile_rewrite ( const char * d1,
const char * out,
int64_t n_val,
float scale,
int n,
int d )
static
If N_VAL is no-zero, normalize the profile by setting the largest counter
counter value to N_VAL and scale others counters proportionally.
Otherwise, multiply the all counters by SCALE.   

References d1, gcov_output_files(), gcov_profile_normalize(), gcov_profile_scale(), gcov_read_profile_dir(), and ggc_alloc().

Referenced by do_rewrite().

◆ rewrite_usage()

static void ATTRIBUTE_NORETURN rewrite_usage ( void )
static
Print profile rewrite usage and exit.   

References FATAL_EXIT_CODE, fnotice(), ggc_alloc(), and print_rewrite_usage_message().

Referenced by do_rewrite().

◆ unlink_profile_dir()

static int unlink_profile_dir ( const char * path)
static
Remove the gcda files in PATH recursively.   

References ggc_alloc().

Referenced by gcov_output_files().

Variable Documentation

◆ merge_options

const struct option merge_options[]
static
Initial value:
=
{
{ "verbose", no_argument, NULL, 'v' },
{ "output", required_argument, NULL, 'o' },
{ "weight", required_argument, NULL, 'w' },
{ 0, 0, 0, 0 }
}
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
#define NULL
Definition system.h:50

Referenced by do_merge().

◆ merge_stream_options

const struct option merge_stream_options[]
static
Initial value:
=
{
{ "verbose", no_argument, NULL, 'v' },
{ "weight", required_argument, NULL, 'w' },
{ 0, 0, 0, 0 }
}

Referenced by do_merge_stream().

◆ options

const struct option options[]
static
Initial value:
=
{
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
{ 0, 0, 0, 0 }
}

◆ overlap_func_level

int overlap_func_level

Referenced by do_overlap().

◆ overlap_hot_only

int overlap_hot_only

Referenced by do_overlap().

◆ overlap_hot_threshold

double overlap_hot_threshold = 0.005

Referenced by do_overlap().

◆ overlap_obj_level

int overlap_obj_level

Referenced by do_overlap().

◆ overlap_options

const struct option overlap_options[]
static
Initial value:
=
{
{ "verbose", no_argument, NULL, 'v' },
{ "function", no_argument, NULL, 'f' },
{ "fullname", no_argument, NULL, 'F' },
{ "object", no_argument, NULL, 'o' },
{ "hotonly", no_argument, NULL, 'h' },
{ "hot_threshold", required_argument, NULL, 't' },
{ 0, 0, 0, 0 }
}

Referenced by do_overlap().

◆ overlap_use_fullname

int overlap_use_fullname

Referenced by do_overlap().

◆ rewrite_options

const struct option rewrite_options[]
static
Initial value:
=
{
{ "verbose", no_argument, NULL, 'v' },
{ "output", required_argument, NULL, 'o' },
{ "scale", required_argument, NULL, 's' },
{ "normalize", required_argument, NULL, 'n' },
{ 0, 0, 0, 0 }
}

Referenced by do_rewrite().

◆ verbose

bool verbose
static
Set to verbose output mode.   

Referenced by do_merge(), do_merge_stream(), do_overlap(), do_rewrite(), and profile_merge().