diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-09 12:54:19 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-09 12:54:19 +0000 |
commit | 90c2be4439c656f63074408d6c91442511a9e061 (patch) | |
tree | da04474c0297ae3c91b3bdce0c519ca2f9d2e5a8 /gcc/gcov-io.h | |
parent | 40734805198ef874623eb7be9ec3de9251c799b7 (diff) | |
download | gcc-90c2be4439c656f63074408d6c91442511a9e061.tar.gz |
* final.c (end_final): Use C trees to output data structures for profiling.
* Makefile.in (LIBGCC_DEPS): Added missing dependency on gcov-io.h
(profile.o): New dependency profile.h
(final.o): New dependency profile.h
* profile.h: New file. New global structure profile_info.
* final.h (count_edges_instrumented_now): Declare.
(current_function_cfg_checksum): Declare.
(function_list): New structure.
(functions_head, functions_tail): New static variables.
(end_final): Emits more data, removed some -ax stuff.
(final): Stores function names and chcksums.
* gcov-io.h (__write_gcov_string): New function.
(__read_gcov_string): New function.
* gcov.c (read_profile): New function.
(create_program_flow_graph): Uses read_profile instead of reading
da_file.
(read_files): Removed da_file checking, it's done by read_profile now.
* libgcc2.c (bb_function_info): New structure.
(bb): New field in structure, removed some -ax stuff.
(__bb_exit_func): Changed structure of da_file.
* profile.c (count_edges_instrumented_now): New global variable.
(current_function_cfg_checksum): New global variable.
(max_counter_in_program): New global variable.
(get_exec_counts): New function.
(compute_checksum): New function.
(instrument_edges): Sets count_edges_instrumented_now.
(compute_branch_probabilities): Uses get_exec_counts instead of
reading da_file.
(branch_prob): Calls compute_checksum and writes extra data to bbg_file.
(init_branch_prob): Removed da_file checking, done in get_exec_counts
now.
(end_branch_prob): Removed da_file checking, done in get_exec_counts
now.
* gcov.texi: Updated information about gcov file format.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53326 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcov-io.h')
-rw-r--r-- | gcc/gcov-io.h | 115 |
1 files changed, 108 insertions, 7 deletions
diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h index 7352429c80d..9e1c081b16d 100644 --- a/gcc/gcov-io.h +++ b/gcc/gcov-io.h @@ -24,13 +24,24 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include <stdio.h> #include <sys/types.h> -static int __fetch_long PARAMS ((long *, char *, size_t)) ATTRIBUTE_UNUSED; -static int __read_long PARAMS ((long *, FILE *, size_t)) ATTRIBUTE_UNUSED; -static int __write_long PARAMS ((long, FILE *, size_t)) ATTRIBUTE_UNUSED; -static int __fetch_gcov_type PARAMS ((gcov_type *, char *, size_t)) ATTRIBUTE_UNUSED; -static int __store_gcov_type PARAMS ((gcov_type, char *, size_t)) ATTRIBUTE_UNUSED; -static int __read_gcov_type PARAMS ((gcov_type *, FILE *, size_t)) ATTRIBUTE_UNUSED; -static int __write_gcov_type PARAMS ((gcov_type, FILE *, size_t)) ATTRIBUTE_UNUSED; +static int __fetch_long PARAMS ((long *, char *, size_t)) + ATTRIBUTE_UNUSED; +static int __read_long PARAMS ((long *, FILE *, size_t)) + ATTRIBUTE_UNUSED; +static int __write_long PARAMS ((long, FILE *, size_t)) + ATTRIBUTE_UNUSED; +static int __fetch_gcov_type PARAMS ((gcov_type *, char *, size_t)) + ATTRIBUTE_UNUSED; +static int __store_gcov_type PARAMS ((gcov_type, char *, size_t)) + ATTRIBUTE_UNUSED; +static int __read_gcov_type PARAMS ((gcov_type *, FILE *, size_t)) + ATTRIBUTE_UNUSED; +static int __write_gcov_type PARAMS ((gcov_type, FILE *, size_t)) + ATTRIBUTE_UNUSED; +static int __write_gcov_string PARAMS ((const char *, size_t, FILE*, long)) + ATTRIBUTE_UNUSED; +static int __read_gcov_string PARAMS ((char *, size_t, FILE*, long)) + ATTRIBUTE_UNUSED; /* These routines only work for signed values. */ @@ -193,4 +204,94 @@ __read_long (dest, file, bytes) return __fetch_long (dest, c, bytes); } + +/* Writes string in gcov format. */ + +static int +__write_gcov_string (string, length, file, delim) + const char *string; + size_t length; + FILE *file; + long delim; +{ + size_t temp = length + 1; + + /* delimiter */ + if (__write_long (delim, file, 4) != 0) + return 1; + + if (__write_long (length, file, 4) != 0) + return 1; + + if (fwrite (string, temp, 1, file) != 1) + return 1; + + temp &= 3; + + if (temp) + { + char c[4]; + + c[0] = c[1] = c[2] = c[3] = 0; + + if (fwrite (c, sizeof (char), 4 - temp, file) != 4 - temp) + return 1; + } + + if (__write_long (delim, file, 4) != 0) + return 1; + + return 0; +} + +/* Reads string in gcov format. */ + + +static int +__read_gcov_string (string, max_length, file, delim) + char *string; + size_t max_length; + FILE *file; + long delim; +{ + long delim_from_file; + long length; + long read_length; + long tmp; + + if (__read_long (&delim_from_file, file, 4) != 0) + return 1; + + if (delim_from_file != delim) + return 1; + + if (__read_long (&length, file, 4) != 0) + return 1; + + if (length > (long) max_length) + read_length = max_length; + else + read_length = length; + + tmp = (((length + 1) - 1) / 4 + 1) * 4; + /* This is the size occupied by the string in the file */ + + if (fread (string, read_length, 1, file) != 1) + return 1; + + string[read_length] = 0; + + if (fseek (file, tmp - read_length, SEEK_CUR) < 0) + return 1; + + if (__read_long (&delim_from_file, file, 4) != 0) + return 1; + + if (delim_from_file != delim) + return 1; + + return 0; +} + + #endif /* ! GCC_GCOV_IO_H */ |