|
GCC Middle and Back End API Reference
|

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 } |
Variables | |
| struct gcov_var | gcov_var |
| #define GCOV_MODE_STDIN 2 |
Referenced by gcov_open(), gcov_position(), and gcov_sync().
| enum gcov_file_error |
|
inlinestatic |
References gcov_var::endian.
Referenced by gcov_read_counter(), and gcov_read_unsigned().
| 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_file(), coverage_remove_note_file(), dump_gcov_file(), read_count_file(), read_counts_file(), and read_graph_file().
|
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(), autofdo::string_table::read(), autofdo::summary_info::read(), read_count_file(), read_counts_file(), read_graph_file(), and autofdo::read_profile().
| 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.
Functions for reading and writing gcov files. In libgcov you can open the file for reading then writing. Elsewhere you can open the file either for reading or for writing. When reading a file you may use the gcov_read_* functions, gcov_sync, gcov_position, and gcov_error. When writing a file you may use the gcov_write* functions and gcov_error. When a file is to be rewritten you use the functions for reading, then gcov_rewrite then the functions for writing. Your file may become corrupted if you break these invariants.
References gcov_var::endian.
Referenced by dump_gcov_file(), read_count_file(), read_counts_file(), and read_graph_file().
| 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.
Available everywhere.
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_file(), dump_gcov_file(), read_count_file(), read_counts_file(), read_graph_file(), and autofdo::read_profile().
|
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().
|
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_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::summary_info::read(), read_count_file(), read_counts_file(), autofdo::function_instance::read_function_instance(), and tag_counters().
| 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_LINKAGE void gcov_read_summary | ( | struct gcov_summary * | summary | ) |
References gcov_read_unsigned(), gcov_summary::runs, and gcov_summary::sum_max.
Referenced by read_count_file(), and tag_summary().
| 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 from_file(), and gcov_read_words().
Referenced by dump_gcov_file(), autofdo::fake_read_autofdo_module_profile(), gcov_read_string(), gcov_read_summary(), autofdo::autofdo_source_profile::read(), autofdo::string_table::read(), autofdo::summary_info::read(), read_count_file(), read_counts_file(), autofdo::function_instance::read_function_instance(), read_graph_file(), autofdo::read_profile(), tag_arcs(), tag_blocks(), tag_conditions(), tag_function(), tag_lines(), and tag_paths().
|
static |
File format for coverage information Copyright (C) 1996-2026 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().
|
static |
Move to a given position in a gcov file.
References gcov_var::file, and SEEK_SET.
Referenced by gcov_write_length().
| 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_LINKAGE void gcov_write | ( | const void * | data, |
| unsigned | length ) |
Write DATA of LENGTH characters to coverage file.
Available outside gcov
References gcov_var::error, gcov_var::file, GCOV_FILE_WRITE_ERROR, and r.
| 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_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_LINKAGE void gcov_write_string | ( | const char * | string | ) |
Write STRING to coverage file. Sets error flag on file error, overflow flag on overflow
Available only in compiler
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_file(), and gcov_write_filename().
| GCOV_LINKAGE gcov_position_t gcov_write_tag | ( | gcov_unsigned_t | 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_LINKAGE void gcov_write_unsigned | ( | gcov_unsigned_t | value | ) |
Write unsigned VALUE to coverage file.
References gcov_var::error, gcov_var::file, GCOV_FILE_WRITE_ERROR, and r.
Referenced by branch_prob(), coverage_begin_function(), coverage_init_file(), gcov_write_length(), gcov_write_string(), gcov_write_tag(), and output_location().
| 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().
| struct gcov_var gcov_var |