Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
bb_exit_func.c File Reference
#include <stdio.h>
#include <strings.h>
#include "bfd.h"
#include "gmon_out.h"

Go to the source code of this file.


struct  bb


#define OUT_NAME   "gmon.out"


void __bb_exit_func ()


struct bb__bb_head = (struct bb *) 0

Class Documentation

struct bb

Definition at line 33 of file bb_exit_func.c.

Collaboration diagram for bb:
Class Members
const unsigned long * addresses
long * counts
const char * filename
long ncounts
struct bb * next
long zero_word

Define Documentation

#define OUT_NAME   "gmon.out"

Function Documentation

void __bb_exit_func ( )

Definition at line 47 of file bb_exit_func.c.

  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"). */
#   define OUT_NAME  "gmon.out"
#   define OUT_NAME  "gmon.cnt"
  fp = fopen (OUT_NAME, "wb");
  if (!fp)
      perror (OUT_NAME);
  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);
  fclose (fp);

Variable Documentation

Definition at line 43 of file bb_exit_func.c.