GCC Middle and Back End API Reference
gcov-io.c File Reference

Functions

static void gcov_write_block (unsigned)
static gcov_unsigned_tgcov_write_words (unsigned)
static const gcov_unsigned_tgcov_read_words (unsigned)
static void gcov_allocate (unsigned)
static gcov_unsigned_t from_file (gcov_unsigned_t value)
GCOV_LINKAGE int gcov_open (#else gcov_open(const char *name, int mode)#endif)
GCOV_LINKAGE int gcov_close ()
GCOV_LINKAGE int gcov_magic ()
static void gcov_allocate ()
static void gcov_write_block ()
static gcov_unsigned_tgcov_write_words ()
GCOV_LINKAGE void gcov_write_unsigned ()
GCOV_LINKAGE void gcov_write_counter ()
GCOV_LINKAGE void gcov_write_string ()
GCOV_LINKAGE gcov_position_t gcov_write_tag ()
GCOV_LINKAGE void gcov_write_length ()
GCOV_LINKAGE void gcov_write_tag_length ()
GCOV_LINKAGE void gcov_write_summary ()
static const gcov_unsigned_tgcov_read_words ()
GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned ()
GCOV_LINKAGE gcov_type gcov_read_counter ()
GCOV_LINKAGE const char * gcov_read_string ()
GCOV_LINKAGE void gcov_read_summary ()
GCOV_LINKAGE void gcov_sync ()
GCOV_LINKAGE void gcov_seek ()
GCOV_LINKAGE time_t gcov_time ()
static unsigned GCOV_LINKAGE
unsigned 
gcov_histo_index ()
static void gcov_histogram_merge (gcov_bucket_type *tgt_histo, gcov_bucket_type *src_histo)
GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary, gcov_working_set_t *gcov_working_sets)

Function Documentation

GCOV_LINKAGE void compute_working_sets ( const struct gcov_ctr_summary summary,
gcov_working_set_t gcov_working_sets 
)
This is used by gcov-dump (IN_GCOV == -1) and in the compiler
   (!IN_GCOV && !IN_LIBGCOV).   
Compute the working set information from the counter histogram in
   the profile summary. This is an array of information corresponding to a
   range of percentages of the total execution count (sum_all), and includes
   the number of counters required to cover that working set percentage and
   the minimum counter value in that working set.   

References count, gcov_bucket_type::cum_value, gcov_ctr_summary::histogram, gcov_working_set_info::min_counter, gcov_bucket_type::min_value, gcov_bucket_type::num_counters, gcov_working_set_info::num_counters, and gcov_ctr_summary::sum_all.

Referenced by dump_working_sets(), and get_working_sets().

static gcov_unsigned_t from_file ( gcov_unsigned_t  value)
inlinestatic
static void gcov_allocate ( unsigned  )
static
static void gcov_allocate ( )
static
GCOV_LINKAGE int gcov_close ( void  )
Close the current gcov file. Flushes data to disk. Returns nonzero
   on failure or error flag set.   

References gcov_var::alloc, gcov_var::buffer, gcov_var::error, gcov_var::file, free(), gcov_write_block(), gcov_var::length, gcov_var::mode, and gcov_var::offset.

Referenced by coverage_finish(), dump_gcov_file(), read_count_file(), and read_graph_file().

static unsigned GCOV_LINKAGE unsigned gcov_histo_index ( )
static
Determine the index into histogram for VALUE.  

References floor_log2(), HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.

Referenced by gcov_histogram_merge().

static void gcov_histogram_merge ( gcov_bucket_type tgt_histo,
gcov_bucket_type src_histo 
)
static
Merge SRC_HISTO into TGT_HISTO. The counters are assumed to be in
   the same relative order in both histograms, and are matched up
   and merged in reverse order. Each counter is assigned an equal portion of
   its entry's original cumulative counter value when computing the
   new merged cum_value.   

References gcov_bucket_type::cum_value, gcov_histo_index(), memcpy(), memset(), gcov_bucket_type::min_value, and gcov_bucket_type::num_counters.

GCOV_LINKAGE int gcov_magic ( )
Check if MAGIC is EXPECTED. Use it to determine endianness of the
   file. Returns +1 for same endian, -1 for other endian and zero for
   not EXPECTED.   

References gcov_var::endian.

Referenced by dump_gcov_file(), read_count_file(), and read_graph_file().

GCOV_LINKAGE int gcov_open ( #else gcov_open(const char *name, int mode)#  endif)
Open a gcov file. NAME is the name of the file to open and MODE
   indicates whether a new file should be created, or an existing file
   opened. If MODE is >= 0 an existing file will be opened, if
   possible, and if MODE is <= 0, a new file will be created. Use
   MODE=0 to attempt to reopen an existing file and then fall back on
   creating a new one.  If MODE < 0, the file will be opened in
   read-only mode.  Otherwise it will be opened for modification.
   Return zero on failure, >0 on opening an existing file and <0 on
   creating a new one.   

References gcov_var::endian, errno, gcov_var::error, gcov_var::file, gcov_var::length, gcov_var::mode, gcov_var::offset, gcov_var::overread, and gcov_var::start.

Referenced by coverage_init(), dump_gcov_file(), read_count_file(), and read_graph_file().

GCOV_LINKAGE gcov_type gcov_read_counter ( void  )
Read counter value from a coverage file. Sets error flag on file
   error, overflow flag on overflow  

References buffer, gcov_var::error, from_file(), and gcov_read_words().

Referenced by gcov_read_summary(), read_count_file(), and tag_counters().

GCOV_LINKAGE const char* gcov_read_string ( void  )
Read string from coverage file. Returns a pointer to a static
   buffer, or NULL on empty string. You must copy the string before
   calling another gcov function.   

References gcov_read_unsigned(), and gcov_read_words().

Referenced by read_graph_file(), tag_function(), and tag_lines().

GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned ( void  )
Read unsigned value from a coverage file. Sets error flag on file
   error, overflow flag on overflow  

References buffer, from_file(), and gcov_read_words().

Referenced by dump_gcov_file(), gcov_read_string(), gcov_read_summary(), read_count_file(), read_graph_file(), tag_arcs(), tag_blocks(), tag_function(), and tag_lines().

static const gcov_unsigned_t* gcov_read_words ( unsigned  )
static
static const gcov_unsigned_t* gcov_read_words ( )
static
Return a pointer to read BYTES bytes from the gcov file. Returns
   NULL on failure (read past EOF).   

References gcov_var::alloc, gcov_var::buffer, gcov_var::file, gcov_allocate(), gcov_var::length, memcpy(), gcov_var::mode, gcov_var::offset, gcov_var::overread, and gcov_var::start.

GCOV_LINKAGE void gcov_seek ( )
Move to a given position in a gcov file.   

References gcov_var::file, gcov_write_block(), gcov_var::mode, gcov_var::offset, and gcov_var::start.

GCOV_LINKAGE void gcov_sync ( )
Reset to a known position.  BASE should have been obtained from
   gcov_position, LENGTH should be a record length.   

References gcov_var::file, gcov_var::length, gcov_var::mode, gcov_var::offset, and gcov_var::start.

Referenced by dump_gcov_file(), read_count_file(), and read_graph_file().

GCOV_LINKAGE time_t gcov_time ( void  )
Return the modification time of the current gcov file.   

References gcov_var::file.

Referenced by read_graph_file().

static void gcov_write_block ( unsigned  )
static
@verbatim File format for coverage information

Copyright (C) 1996-2013 Free Software Foundation, Inc. Contributed by Bob Manson manso.nosp@m.n@cy.nosp@m.gnus..nosp@m.com. Completely remangled by Nathan Sidwell natha.nosp@m.n@co.nosp@m.desou.nosp@m.rcer.nosp@m.y.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/.

Routines declared in gcov-io.h.  This file should be #included by
   another source file, after having #included gcov-io.h.   

Referenced by gcov_close(), gcov_seek(), gcov_write_length(), and gcov_write_words().

static void gcov_write_block ( )
static
Write out the current block, if needs be.   

References gcov_var::buffer, gcov_var::error, gcov_var::file, gcov_var::offset, and gcov_var::start.

GCOV_LINKAGE void gcov_write_counter ( )
Write counter VALUE to coverage file.  Sets error flag
   appropriately.   

References buffer, and gcov_write_words().

Referenced by gcov_write_summary().

GCOV_LINKAGE void gcov_write_length ( )
Write a record length using POSITION, which was returned by
   gcov_write_tag.  The current file position is the end of the
   record, and is restored before returning.  Returns nonzero on
   overflow.   

References buffer, gcov_var::buffer, gcov_write_block(), gcov_var::mode, gcov_var::offset, offset, and gcov_var::start.

Referenced by branch_prob(), and coverage_begin_function().

GCOV_LINKAGE void gcov_write_string ( )
Write STRING to coverage file.  Sets error flag on file
   error, overflow flag on overflow  

References buffer, gcov_write_words(), memcpy(), and strlen().

Referenced by branch_prob(), coverage_begin_function(), and output_location().

GCOV_LINKAGE gcov_position_t gcov_write_tag ( )
Write a tag TAG and reserve space for the record length. Return a
   value to be used for gcov_write_length.   

References buffer, gcov_write_words(), gcov_var::offset, and gcov_var::start.

Referenced by branch_prob(), coverage_begin_function(), and output_location().

GCOV_LINKAGE void gcov_write_tag_length ( )
Write a tag TAG and length LENGTH.   

References buffer, and gcov_write_words().

Referenced by gcov_write_summary().

GCOV_LINKAGE void gcov_write_unsigned ( )
Write unsigned VALUE to coverage file.  Sets error flag
   appropriately.   

References buffer, and gcov_write_words().

Referenced by branch_prob(), coverage_begin_function(), coverage_init(), gcov_write_summary(), and output_location().

static gcov_unsigned_t* gcov_write_words ( unsigned  )
static
static gcov_unsigned_t* gcov_write_words ( )
static
Allocate space to write BYTES bytes to the gcov file. Return a
   pointer to those bytes, or NULL on failure.   

References gcov_var::alloc, gcov_var::buffer, gcov_allocate(), gcov_write_block(), memcpy(), gcov_var::mode, and gcov_var::offset.