GCC Middle and Back End API Reference
gcov-io.cc File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gcov_var
 

Macros

#define GCOV_MODE_STDIN   2
 

Enumerations

enum  gcov_file_error { GCOV_FILE_COUNTER_OVERFLOW = -1 , GCOV_FILE_NO_ERROR = 0 , GCOV_FILE_WRITE_ERROR = 1 , GCOV_FILE_EOF = 2 }
 

Functions

static gcov_unsigned_tgcov_read_words (void *buffer, unsigned)
 
static gcov_position_t gcov_position (void)
 
static int gcov_is_error (void)
 
static gcov_unsigned_t from_file (gcov_unsigned_t value)
 
GCOV_LINKAGE int gcov_open (const char *name, int mode)
 
GCOV_LINKAGE int gcov_close (void)
 
GCOV_LINKAGE int gcov_magic (gcov_unsigned_t magic, gcov_unsigned_t expected)
 
GCOV_LINKAGE void gcov_write (const void *data, unsigned length)
 
GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t value)
 
GCOV_LINKAGE void gcov_write_string (const char *string)
 
GCOV_LINKAGE void gcov_write_filename (const char *filename)
 
static void gcov_seek (gcov_position_t base)
 
GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t tag)
 
GCOV_LINKAGE void gcov_write_length (gcov_position_t position)
 
static void * gcov_read_bytes (void *buffer, unsigned count)
 
GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void)
 
GCOV_LINKAGE gcov_type gcov_read_counter (void)
 
char * mangle_path (char const *base)
 
GCOV_LINKAGE const char * gcov_read_string (void)
 
GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *summary)
 
GCOV_LINKAGE void gcov_sync (gcov_position_t base, gcov_unsigned_t length)
 

Variables

struct gcov_var gcov_var
 

Macro Definition Documentation

◆ GCOV_MODE_STDIN

#define GCOV_MODE_STDIN   2

Referenced by gcov_open(), gcov_position(), and gcov_sync().

Enumeration Type Documentation

◆ gcov_file_error

Indicates the last gcov file access error or that no error occurred
so far.   
Enumerator
GCOV_FILE_COUNTER_OVERFLOW 
GCOV_FILE_NO_ERROR 
GCOV_FILE_WRITE_ERROR 
GCOV_FILE_EOF 

Function Documentation

◆ from_file()

static gcov_unsigned_t from_file ( gcov_unsigned_t value)
inlinestatic

◆ gcov_close()

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::error, gcov_var::file, GCOV_FILE_WRITE_ERROR, and gcov_var::mode.

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

◆ gcov_is_error()

static int gcov_is_error ( void )
inlinestatic
Return nonzero if the error flag is set.   
We need to expose this function when compiling for gcov-tool.   

References gcov_var::error, and gcov_var::file.

Referenced by coverage_begin_function(), coverage_end_function(), dump_gcov_file(), read_count_file(), read_counts_file(), and read_graph_file().

◆ gcov_magic()

GCOV_LINKAGE int gcov_magic ( gcov_unsigned_t magic,
gcov_unsigned_t expected )
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(), read_counts_file(), and read_graph_file().

◆ gcov_open()

GCOV_LINKAGE int gcov_open ( const char * name,
int mode )
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, non-zero on success.   

References gcov_var::endian, errno, gcov_var::error, fdopen, gcov_var::file, fopen, GCOV_FILE_NO_ERROR, GCOV_MODE_STDIN, gcov_nonruntime_assert, LONG_MAX, gcov_var::mode, O_BINARY, O_RDONLY, and SEEK_SET.

Referenced by coverage_init(), dump_gcov_file(), read_count_file(), read_counts_file(), read_graph_file(), and autofdo::read_profile().

◆ gcov_position()

static gcov_position_t gcov_position ( void )
inlinestatic
Save the current position in the gcov file.   
We need to expose this function when compiling for gcov-tool.   

References gcov_var::file, GCOV_MODE_STDIN, and gcov_var::mode.

Referenced by dump_gcov_file(), gcov_write_length(), gcov_write_tag(), read_count_file(), read_counts_file(), read_graph_file(), tag_arcs(), tag_conditions(), tag_counters(), tag_function(), and tag_lines().

◆ gcov_read_bytes()

static void * gcov_read_bytes ( void * buffer,
unsigned count )
static

IN_GCOV

Return a pointer to read COUNT bytes from the gcov file.  Returns
NULL on failure (read past EOF).   

References count, gcov_var::error, gcov_var::file, GCOV_FILE_EOF, gcov_var::mode, and NULL.

Referenced by gcov_read_string(), and gcov_read_words().

◆ gcov_read_counter()

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 gcov_var::error, from_file(), GCOV_FILE_COUNTER_OVERFLOW, and gcov_read_words().

Referenced by autofdo::autofdo_source_profile::read(), read_count_file(), read_counts_file(), autofdo::function_instance::read_function_instance(), and tag_counters().

◆ gcov_read_string()

GCOV_LINKAGE const char * gcov_read_string ( void )
We need to expose the below function when compiling for gcov-tool.   
Read string from coverage file.  Allocate the buffer for the string
from the heap or die.  Return a pointer to the string, or NULL on
empty string.   

References gcov_read_bytes(), and gcov_read_unsigned().

Referenced by dump_gcov_file(), autofdo::string_table::read(), read_graph_file(), tag_function(), and tag_lines().

◆ gcov_read_summary()

GCOV_LINKAGE void gcov_read_summary ( struct gcov_summary * summary)

◆ gcov_read_unsigned()

◆ gcov_read_words()

static gcov_unsigned_t * gcov_read_words ( void * buffer,
unsigned words )
static
File format for coverage information
   Copyright (C) 1996-2024 Free Software Foundation, Inc.
   Contributed by Bob Manson <manson@cygnus.com>.
   Completely remangled by Nathan Sidwell <nathan@codesourcery.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.   
Read WORDS gcov_unsigned_t values from gcov file.   

References gcov_read_bytes(), and GCOV_WORD_SIZE.

Referenced by gcov_read_counter(), and gcov_read_unsigned().

◆ gcov_seek()

static void gcov_seek ( gcov_position_t base)
static
Move to a given position in a gcov file.   

References gcov_var::file, and SEEK_SET.

Referenced by gcov_write_length().

◆ gcov_sync()

GCOV_LINKAGE void gcov_sync ( gcov_position_t base,
gcov_unsigned_t length )
We need to expose the below function when compiling for gcov-tool.   
Reset to a known position.  BASE should have been obtained from
gcov_position, LENGTH should be a record length.   

References gcov_var::file, GCOV_MODE_STDIN, gcov_nonruntime_assert, gcov_var::mode, and SEEK_SET.

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

◆ gcov_write()

GCOV_LINKAGE void gcov_write ( const void * data,
unsigned length )
Write DATA of LENGTH characters to coverage file.   

References gcov_var::error, gcov_var::file, GCOV_FILE_WRITE_ERROR, and r.

◆ gcov_write_filename()

GCOV_LINKAGE void gcov_write_filename ( const char * filename)
Write FILENAME to coverage file.  Sets error flag on file
error, overflow flag on overflow  

References free(), gcov_write_string(), and NULL.

Referenced by coverage_begin_function(), and output_location().

◆ gcov_write_length()

GCOV_LINKAGE void gcov_write_length ( gcov_position_t position)
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 current_position, gcov_nonruntime_assert, gcov_position(), gcov_seek(), GCOV_WORD_SIZE, gcov_write_unsigned(), and gcov_var::mode.

Referenced by branch_prob(), and coverage_begin_function().

◆ gcov_write_string()

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

References gcov_var::error, gcov_var::file, GCOV_FILE_WRITE_ERROR, gcov_write_unsigned(), and r.

Referenced by branch_prob(), coverage_begin_function(), coverage_init(), and gcov_write_filename().

◆ 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 gcov_position(), and gcov_write_unsigned().

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

◆ gcov_write_unsigned()

◆ mangle_path()

char * mangle_path ( char const * base)
Mangle filename path of BASE and output new allocated pointer with
mangled path.   

Referenced by coverage_init(), get_gcov_intermediate_filename(), and mangle_name().

Variable Documentation

◆ gcov_var

struct gcov_var gcov_var