From: Ian Lance Taylor Date: Thu, 4 Jul 1996 18:35:44 +0000 (+0000) Subject: * bb_exit_func.c: Rename from __bb_exit_func.c, so that it can be X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13566744d912e2986a574e7afcc8bcd0732d00cc;p=binutils-gdb.git * bb_exit_func.c: Rename from __bb_exit_func.c, so that it can be stored on a System V file system. --- diff --git a/gprof/ChangeLog b/gprof/ChangeLog index 8cf7b3f2d02..4bbbd479ba7 100644 --- a/gprof/ChangeLog +++ b/gprof/ChangeLog @@ -2,6 +2,9 @@ Thu Jul 4 12:01:42 1996 Ian Lance Taylor * Released binutils 2.7. + * bb_exit_func.c: Rename from __bb_exit_func.c, so that it can be + stored on a System V file system. + Thu Jun 27 11:36:22 1996 Ian Lance Taylor * configure.in: Call AC_ISC_POSIX. diff --git a/gprof/__bb_exit_func.c b/gprof/__bb_exit_func.c deleted file mode 100644 index 813321566c7..00000000000 --- a/gprof/__bb_exit_func.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1994 David Mosberger-Tang. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or (at - * your option) any later version. - * - * __bb_exit_func() dumps all the basic-block statistics linked into - * the bb_head chain to .d files. - */ -#include -#include -#include "bfd.h" -#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 *__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"). - */ -#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; - - tag = GMON_TAG_BB_COUNT; - fwrite(&tag, sizeof(tag), 1, fp); - fwrite(&ncounts, sizeof(ncounts), 1, fp); - - 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 */ - - /*** end of __bb_exit_func.c ***/ diff --git a/gprof/bb_exit_func.c b/gprof/bb_exit_func.c new file mode 100644 index 00000000000..813321566c7 --- /dev/null +++ b/gprof/bb_exit_func.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1994 David Mosberger-Tang. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * __bb_exit_func() dumps all the basic-block statistics linked into + * the bb_head chain to .d files. + */ +#include +#include +#include "bfd.h" +#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 *__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"). + */ +#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; + + tag = GMON_TAG_BB_COUNT; + fwrite(&tag, sizeof(tag), 1, fp); + fwrite(&ncounts, sizeof(ncounts), 1, fp); + + 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 */ + + /*** end of __bb_exit_func.c ***/