diff options
Diffstat (limited to 'gprof/bb_exit_func.c')
-rw-r--r-- | gprof/bb_exit_func.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/gprof/bb_exit_func.c b/gprof/bb_exit_func.c index 0f0259a..33f9296 100644 --- a/gprof/bb_exit_func.c +++ b/gprof/bb_exit_func.c @@ -1,7 +1,7 @@ /* bb_exit_func.c - dumps all the basic-block statistics linked into the bb_head chain to .d files. - Copyright 2000 Free Software Foundation, Inc. + Copyright 2000, 2001 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -30,64 +30,64 @@ #include "gmon_out.h" /* structure emitted by -a */ -struct bb { - long zero_word; - const char *filename; - long *counts; - long ncounts; - struct bb *next; - const unsigned long *addresses; +struct bb +{ + long zero_word; + const char *filename; + long *counts; + long ncounts; + struct bb *next; + const unsigned long *addresses; }; -struct bb *__bb_head = (struct bb *)0; +struct bb *__bb_head = (struct bb *) 0; void __bb_exit_func (void) { - const int version = GMON_VERSION; - struct gmon_hdr ghdr; - struct bb *ptr; - FILE *fp; - /* - * GEN_GMON_CNT_FILE should be defined on systems with mcleanup() - * functions that do not write basic-block to gmon.out. In such - * cases profiling with "-pg -a" would result in a gmon.out file - * without basic-block info (because the file written here would - * be overwritten. Thus, a separate file is generated instead. - * The two files can easily be combined by specifying them - * on gprof's command line (and possibly generating a gmon.sum - * file with "gprof -s"). - */ + const int version = GMON_VERSION; + struct gmon_hdr ghdr; + struct bb *ptr; + FILE *fp; + /* GEN_GMON_CNT_FILE should be defined on systems with mcleanup() + functions that do not write basic-block to gmon.out. In such + cases profiling with "-pg -a" would result in a gmon.out file + without basic-block info (because the file written here would be + overwritten. Thus, a separate file is generated instead. The + two files can easily be combined by specifying them on gprof's + command line (and possibly generating a gmon.sum file with "gprof + -s"). */ #ifndef GEN_GMON_CNT_FILE # define OUT_NAME "gmon.out" #else # define OUT_NAME "gmon.cnt" #endif - fp = fopen(OUT_NAME, "wb"); - if (!fp) { - perror(OUT_NAME); - return; - } /* if */ - memcpy(&ghdr.cookie[0], GMON_MAGIC, 4); - memcpy(&ghdr.version, &version, sizeof(version)); - fwrite(&ghdr, sizeof(ghdr), 1, fp); - - for (ptr = __bb_head; ptr != 0; ptr = ptr->next) { - u_int ncounts = ptr->ncounts; - u_char tag; - u_int i; + fp = fopen (OUT_NAME, "wb"); + if (!fp) + { + perror (OUT_NAME); + return; + } + memcpy (&ghdr.cookie[0], GMON_MAGIC, 4); + memcpy (&ghdr.version, &version, sizeof (version)); + fwrite (&ghdr, sizeof (ghdr), 1, fp); - tag = GMON_TAG_BB_COUNT; - fwrite(&tag, sizeof(tag), 1, fp); - fwrite(&ncounts, sizeof(ncounts), 1, fp); + for (ptr = __bb_head; ptr != 0; ptr = ptr->next) + { + u_int ncounts = ptr->ncounts; + u_char tag; + u_int i; - for (i = 0; i < ncounts; ++i) { - fwrite(&ptr->addresses[i], sizeof(ptr->addresses[0]), 1, fp); - fwrite(&ptr->counts[i], sizeof(ptr->counts[0]), 1, fp); - } /* for */ - } /* for */ - fclose (fp); -} /* __bb_exit_func */ + tag = GMON_TAG_BB_COUNT; + fwrite (&tag, sizeof (tag), 1, fp); + fwrite (&ncounts, sizeof (ncounts), 1, fp); - /*** end of __bb_exit_func.c ***/ + for (i = 0; i < ncounts; ++i) + { + fwrite (&ptr->addresses[i], sizeof (ptr->addresses[0]), 1, fp); + fwrite (&ptr->counts[i], sizeof (ptr->counts[0]), 1, fp); + } + } + fclose (fp); +} |