This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gcov]: Improve type system


Hi,
The gcov types have to be consistent on both host and target. This patch
creates some typedefs so that things have the correct number of bits,
even where the target's plain int is tiny.

booted & tested on i686-pc-linux-gnu, installed.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-05-10  Nathan Sidwell  <nathan@codesourcery.com>

	* defaults.h (GCOV_TYPE_SIZE): Remove.
	* gcov-io.h (gcov_type): Set to specific mode int on target.
	(gcov_unsigned_t, gcov_position_t): New.
	(GCOV_TYPE_NODE): New.
	(GCOV_TAG_SUMMARY_LENGTH): Adjust.
	(GCOV_COUNTERS_SUMMABLE): New.
	(gcov_ctr_summary, gcov_sumary, gcov_fn_info, gcov_merge_fn,
	gcov_ctr_info, gcov_info): Adjust types.
	(gcov_var): Adjust types.
	(gcov_write_unsigned, gcov_write_tag,
	gcov_write_length, gcov_write_tag_length, gcov_write_summary,
	gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
	(gcov_position, gcov_sync, gcov_seek): Adjust gcov types.
	* gcov-io.c (gcov_write_unsigned, gcov_write_tag,
	gcov_write_length, gcov_write_tag_length, gcov_write_summary,
	gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
	* libgcov.c (gcov_crc32, gcov_version_mismatch, gcov_exit,
	__gcov_init, __gcov_merge_add): Adjust gcov types.
	* coverage.c (ctr_merge_functions): Constify.
	(ctr_names): New.
	(read_counts_file): Adjust gcov types. Only summarize & merge
	summable counters.
	(coverage_counter_ref): Use GCOV_TYPE_NODE.
	(build_fn_info_type, build_fn_info_value, build_ctr_info_type,
	build_ctr_info_value, build_gcov_info): Adjust types.
	* profile.c (branch_prob): Adjust gcov types.
	* gcov_dump (dump_file): Adjust gcov types.

Index: coverage.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 coverage.c
*** coverage.c	7 May 2003 10:40:09 -0000	1.6
--- coverage.c	10 May 2003 16:47:56 -0000
*************** static htab_t counts_hash = NULL;
*** 99,105 ****
  static GTY(()) rtx ctr_labels[GCOV_COUNTERS];
  
  /* The names of merge functions for counters.  */
! static const char *ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS;
  
  /* Forward declarations.  */
  static hashval_t htab_counts_entry_hash PARAMS ((const void *));
--- 99,106 ----
  static GTY(()) rtx ctr_labels[GCOV_COUNTERS];
  
  /* The names of merge functions for counters.  */
! static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS;
! static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES;
  
  /* Forward declarations.  */
  static hashval_t htab_counts_entry_hash PARAMS ((const void *));
*************** htab_counts_entry_del (of)
*** 151,158 ****
  static void
  read_counts_file ()
  {
!   unsigned fn_ident = 0;
!   unsigned version, ix, checksum = -1;
    counts_entry_t *summaried = NULL;
    unsigned seen_summary = 0;
    
--- 152,160 ----
  static void
  read_counts_file ()
  {
!   gcov_unsigned_t fn_ident = 0;
!   gcov_unsigned_t version, checksum = -1;
!   unsigned ix;
    counts_entry_t *summaried = NULL;
    unsigned seen_summary = 0;
    
*************** read_counts_file ()
*** 168,174 ****
    else if ((version = gcov_read_unsigned ()) != GCOV_VERSION)
      {
        char v[4], e[4];
!       unsigned required = GCOV_VERSION;
        
        for (ix = 4; ix--; required >>= 8, version >>= 8)
  	{
--- 170,176 ----
    else if ((version = gcov_read_unsigned ()) != GCOV_VERSION)
      {
        char v[4], e[4];
!       gcov_unsigned_t required = GCOV_VERSION;
        
        for (ix = 4; ix--; required >>= 8, version >>= 8)
  	{
*************** read_counts_file ()
*** 186,193 ****
  			     htab_counts_entry_del);
    while (!gcov_is_eof ())
      {
!       unsigned tag, length;
!       unsigned long offset;
        int error;
        
        tag = gcov_read_unsigned ();
--- 188,195 ----
  			     htab_counts_entry_del);
    while (!gcov_is_eof ())
      {
!       gcov_unsigned_t tag, length;
!       gcov_position_t offset;
        int error;
        
        tag = gcov_read_unsigned ();
*************** read_counts_file ()
*** 259,275 ****
  	      htab_delete (counts_hash);
  	      break;
  	    }
! 	  
! 	  /* This should always be true for a just allocated entry,
! 	     and always false for an existing one. Check this way, in
! 	     case the gcov file is corrupt.  */
! 	  if (!entry->chain || summaried != entry)
  	    {
  	      entry->chain = summaried;
  	      summaried = entry;
  	    }
  	  for (ix = 0; ix != n_counts; ix++)
  	    entry->counts[ix] += gcov_read_counter ();
  	}
        gcov_sync (offset, length);
        if ((error = gcov_is_error ()))
--- 261,285 ----
  	      htab_delete (counts_hash);
  	      break;
  	    }
! 	  else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
! 	    {
! 	      warning ("cannot merge separate %s counters for function %u",
! 		       ctr_names[elt.ctr], fn_ident);
! 	      goto skip_merge;
! 	    }
! 
! 	  if (elt.ctr < GCOV_COUNTERS_SUMMABLE
! 	      /* This should always be true for a just allocated entry,
! 	     	 and always false for an existing one. Check this way, in
! 	     	 case the gcov file is corrupt.  */
! 	      && (!entry->chain || summaried != entry))
  	    {
  	      entry->chain = summaried;
  	      summaried = entry;
  	    }
  	  for (ix = 0; ix != n_counts; ix++)
  	    entry->counts[ix] += gcov_read_counter ();
+ 	skip_merge:;
  	}
        gcov_sync (offset, length);
        if ((error = gcov_is_error ()))
*************** get_coverage_counts (unsigned counter, u
*** 332,338 ****
  rtx
  coverage_counter_ref (unsigned counter, unsigned no)
  {
!   enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
    rtx ref;
  
    if (!ctr_labels[counter])
--- 342,349 ----
  rtx
  coverage_counter_ref (unsigned counter, unsigned no)
  {
!   unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
!   enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
    rtx ref;
  
    if (!ctr_labels[counter])
*************** coverage_counter_ref (unsigned counter, 
*** 350,357 ****
      }
  
    no += prg_n_ctrs[counter];
!   ref = plus_constant (ctr_labels[counter],
! 		       GCOV_TYPE_SIZE / BITS_PER_UNIT * no);
    ref = gen_rtx_MEM (mode, ref);
    set_mem_alias_set (ref, new_alias_set ());
  
--- 361,367 ----
      }
  
    no += prg_n_ctrs[counter];
!   ref = plus_constant (ctr_labels[counter], gcov_size / BITS_PER_UNIT * no);
    ref = gen_rtx_MEM (mode, ref);
    set_mem_alias_set (ref, new_alias_set ());
  
*************** build_fn_info_type (counters)
*** 489,498 ****
    tree array_type;
    
    /* ident */
!   fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
  
    /* checksum */
!   field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
  
--- 499,508 ----
    tree array_type;
    
    /* ident */
!   fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
  
    /* checksum */
!   field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
  
*************** build_fn_info_value (function, type)
*** 525,538 ****
    
    /* ident */
    value = tree_cons (fields,
! 		     convert (unsigned_type_node,
  			      build_int_2 (function->ident, 0)),
  		     value);
    fields = TREE_CHAIN (fields);
    
    /* checksum */
    value = tree_cons (fields,
! 		     convert (unsigned_type_node,
  			      build_int_2 (function->checksum, 0)),
  		     value);
    fields = TREE_CHAIN (fields);
--- 535,548 ----
    
    /* ident */
    value = tree_cons (fields,
! 		     convert (unsigned_intSI_type_node,
  			      build_int_2 (function->ident, 0)),
  		     value);
    fields = TREE_CHAIN (fields);
    
    /* checksum */
    value = tree_cons (fields,
! 		     convert (unsigned_intSI_type_node,
  			      build_int_2 (function->checksum, 0)),
  		     value);
    fields = TREE_CHAIN (fields);
*************** build_ctr_info_type ()
*** 562,587 ****
  {
    tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
    tree field, fields = NULL_TREE;
    tree gcov_merge_fn_type;
!   
    /* counters */
!   field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
  
    /* values */
!   field = build_decl (FIELD_DECL, NULL_TREE,
! 		      build_pointer_type (make_signed_type (GCOV_TYPE_SIZE)));
    TREE_CHAIN (field) = fields;
    fields = field;
  
    /* merge */
    gcov_merge_fn_type =
! 	build_function_type_list (
! 		void_type_node,
! 		build_pointer_type (make_signed_type (GCOV_TYPE_SIZE)),
! 		unsigned_type_node,
! 		NULL_TREE);
    field = build_decl (FIELD_DECL, NULL_TREE,
  		      build_pointer_type (gcov_merge_fn_type));
    TREE_CHAIN (field) = fields;
--- 572,595 ----
  {
    tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
    tree field, fields = NULL_TREE;
+   tree gcov_ptr_type = build_pointer_type (GCOV_TYPE_NODE);
    tree gcov_merge_fn_type;
! 
    /* counters */
!   field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
  
    /* values */
!   field = build_decl (FIELD_DECL, NULL_TREE, gcov_ptr_type);
    TREE_CHAIN (field) = fields;
    fields = field;
  
    /* merge */
    gcov_merge_fn_type =
!     build_function_type_list (void_type_node,
! 			      gcov_ptr_type, unsigned_type_node,
! 			      NULL_TREE);
    field = build_decl (FIELD_DECL, NULL_TREE,
  		      build_pointer_type (gcov_merge_fn_type));
    TREE_CHAIN (field) = fields;
*************** build_ctr_info_value (counter, type)
*** 607,613 ****
  
    /* counters */
    value = tree_cons (fields,
! 		     convert (unsigned_type_node,
  			      build_int_2 (prg_n_ctrs[counter], 0)),
  		     value);
    fields = TREE_CHAIN (fields);
--- 615,621 ----
  
    /* counters */
    value = tree_cons (fields,
! 		     convert (unsigned_intSI_type_node,
  			      build_int_2 (prg_n_ctrs[counter], 0)),
  		     value);
    fields = TREE_CHAIN (fields);
*************** build_ctr_info_value (counter, type)
*** 641,649 ****
    DECL_ARTIFICIAL (fn) = 1;
    TREE_NOTHROW (fn) = 1;
    value = tree_cons (fields,
! 		     build1 (ADDR_EXPR,
! 			     TREE_TYPE (fields),
! 			     fn),
  		     value);
  
    value = build_constructor (type, nreverse (value));
--- 649,655 ----
    DECL_ARTIFICIAL (fn) = 1;
    TREE_NOTHROW (fn) = 1;
    value = tree_cons (fields,
! 		     build1 (ADDR_EXPR, TREE_TYPE (fields), fn),
  		     value);
  
    value = build_constructor (type, nreverse (value));
*************** build_gcov_info ()
*** 680,689 ****
    const_type = build_qualified_type (type, TYPE_QUAL_CONST);
    
    /* Version ident */
!   field = build_decl (FIELD_DECL, NULL_TREE, long_unsigned_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
!   value = tree_cons (field, convert (long_unsigned_type_node,
  				     build_int_2 (GCOV_VERSION, 0)),
  		     value);
    
--- 686,695 ----
    const_type = build_qualified_type (type, TYPE_QUAL_CONST);
    
    /* Version ident */
!   field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
    TREE_CHAIN (field) = fields;
    fields = field;
!   value = tree_cons (field, convert (unsigned_intSI_type_node,
  				     build_int_2 (GCOV_VERSION, 0)),
  		     value);
    
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.104
diff -c -3 -p -r1.104 defaults.h
*** defaults.h	6 Apr 2003 21:44:06 -0000	1.104
--- defaults.h	10 May 2003 16:47:58 -0000
*************** do { fputs (integer_asm_op (POINTER_SIZE
*** 404,418 ****
  #define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
  #endif
  
- /* Type used by GCOV counters.  Use 64bit data type if target supports
-    it.  */
- #if LONG_TYPE_SIZE >= 64
- #define GCOV_TYPE_SIZE LONG_TYPE_SIZE
- #else
- #define GCOV_TYPE_SIZE LONG_LONG_TYPE_SIZE
- #endif
- 
- 
  /* By default, the preprocessor should be invoked the same way in C++
     as in C.  */
  #ifndef CPLUSPLUS_CPP_SPEC
--- 404,409 ----
Index: gcov-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-dump.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 gcov-dump.c
*** gcov-dump.c	7 May 2003 10:40:09 -0000	1.11
--- gcov-dump.c	10 May 2003 16:47:59 -0000
*************** dump_file (filename)
*** 241,247 ****
        if ((error = gcov_is_error ()))
  	{
  	  printf (error < 0 ? "%s:counter overflow at %lu\n" :
! 		  "%s:read error at %lu\n", filename, gcov_position ());
  	  break;
  	}
      }
--- 241,248 ----
        if ((error = gcov_is_error ()))
  	{
  	  printf (error < 0 ? "%s:counter overflow at %lu\n" :
! 		  "%s:read error at %lu\n", filename,
! 		  (long unsigned) gcov_position ());
  	  break;
  	}
      }
Index: gcov-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 gcov-io.c
*** gcov-io.c	7 May 2003 10:40:09 -0000	1.4
--- gcov-io.c	10 May 2003 16:47:59 -0000
*************** gcov_write_bytes (unsigned bytes)
*** 181,187 ****
     appropriately.  */
  
  GCOV_LINKAGE void
! gcov_write_unsigned (unsigned value)
  {
    unsigned char *buffer = gcov_write_bytes (4);
    unsigned ix;
--- 181,187 ----
     appropriately.  */
  
  GCOV_LINKAGE void
! gcov_write_unsigned (gcov_unsigned_t value)
  {
    unsigned char *buffer = gcov_write_bytes (4);
    unsigned ix;
*************** gcov_write_string (const char *string)
*** 261,270 ****
  /* Write a tag TAG and reserve space for the record length. Return a
     value to be used for gcov_write_length.  */
  
! GCOV_LINKAGE unsigned long
! gcov_write_tag (unsigned tag)
  {
!   unsigned long result = gcov_var.position;
    unsigned char *buffer = gcov_write_bytes (8);
    unsigned ix;
  
--- 261,270 ----
  /* Write a tag TAG and reserve space for the record length. Return a
     value to be used for gcov_write_length.  */
  
! GCOV_LINKAGE gcov_position_t
! gcov_write_tag (gcov_unsigned_t tag)
  {
!   gcov_position_t result = gcov_var.position;
    unsigned char *buffer = gcov_write_bytes (8);
    unsigned ix;
  
*************** gcov_write_tag (unsigned tag)
*** 285,295 ****
     overflow.  */
  
  GCOV_LINKAGE void
! gcov_write_length (unsigned long position)
  {
    if (position)
      {
!       unsigned length = gcov_var.position - position - 8;
        unsigned char *buffer = &gcov_var.buffer[position + 4];
        unsigned ix;
        
--- 285,295 ----
     overflow.  */
  
  GCOV_LINKAGE void
! gcov_write_length (gcov_position_t position)
  {
    if (position)
      {
!       gcov_unsigned_t length = gcov_var.position - position - 8;
        unsigned char *buffer = &gcov_var.buffer[position + 4];
        unsigned ix;
        
*************** gcov_write_length (unsigned long positio
*** 300,311 ****
  	}
      }
  }
! #endif
  
  /* Write a tag TAG and length LENGTH.  */
  
  GCOV_LINKAGE void
! gcov_write_tag_length (unsigned tag, unsigned length)
  {
    unsigned char *buffer = gcov_write_bytes (8);
    unsigned ix;
--- 300,312 ----
  	}
      }
  }
! 
! #else /* IN_LIBGCOV */
  
  /* Write a tag TAG and length LENGTH.  */
  
  GCOV_LINKAGE void
! gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
  {
    unsigned char *buffer = gcov_write_bytes (8);
    unsigned ix;
*************** gcov_write_tag_length (unsigned tag, uns
*** 325,343 ****
    return;
  }
  
- #if IN_LIBGCOV
  /* Write a summary structure to the gcov file.  Return non-zero on
     overflow.  */
  
  GCOV_LINKAGE void
! gcov_write_summary (unsigned tag, const struct gcov_summary *summary)
  {
    unsigned ix;
    const struct gcov_ctr_summary *csum;
  
    gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
    gcov_write_unsigned (summary->checksum);
!   for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++)
      {
        gcov_write_unsigned (csum->num);
        gcov_write_unsigned (csum->runs);
--- 326,343 ----
    return;
  }
  
  /* Write a summary structure to the gcov file.  Return non-zero on
     overflow.  */
  
  GCOV_LINKAGE void
! gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
  {
    unsigned ix;
    const struct gcov_ctr_summary *csum;
  
    gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
    gcov_write_unsigned (summary->checksum);
!   for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
      {
        gcov_write_unsigned (csum->num);
        gcov_write_unsigned (csum->runs);
*************** gcov_read_bytes (unsigned bytes)
*** 372,381 ****
  /* Read unsigned value from a coverage file. Sets error flag on file
     error, overflow flag on overflow */
  
! GCOV_LINKAGE unsigned
  gcov_read_unsigned ()
  {
!   unsigned value = 0;
    unsigned ix;
    const unsigned char *buffer = gcov_read_bytes (4);
  
--- 372,381 ----
  /* Read unsigned value from a coverage file. Sets error flag on file
     error, overflow flag on overflow */
  
! GCOV_LINKAGE gcov_unsigned_t
  gcov_read_unsigned ()
  {
!   gcov_unsigned_t value = 0;
    unsigned ix;
    const unsigned char *buffer = gcov_read_bytes (4);
  
*************** gcov_read_summary (struct gcov_summary *
*** 442,448 ****
    struct gcov_ctr_summary *csum;
    
    summary->checksum = gcov_read_unsigned ();
!   for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++)
      {
        csum->num = gcov_read_unsigned ();
        csum->runs = gcov_read_unsigned ();
--- 442,448 ----
    struct gcov_ctr_summary *csum;
    
    summary->checksum = gcov_read_unsigned ();
!   for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
      {
        csum->num = gcov_read_unsigned ();
        csum->runs = gcov_read_unsigned ();
Index: gcov-io.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.h,v
retrieving revision 1.32
diff -c -3 -p -r1.32 gcov-io.h
*** gcov-io.h	7 May 2003 10:40:09 -0000	1.32
--- gcov-io.h	10 May 2003 16:48:04 -0000
*************** Software Foundation, 59 Temple Place - S
*** 158,186 ****
  #define GCC_GCOV_IO_H
  
  #if IN_LIBGCOV
! #if LONG_TYPE_SIZE == GCOV_TYPE_SIZE
! typedef long gcov_type;
  #else
! typedef long long gcov_type;
  #endif
  #if defined (TARGET_HAS_F_SETLKW)
  #define GCOV_LOCKED 1
  #else
  #define GCOV_LOCKED 0
  #endif
  #else /* !IN_LIBGCOV */
! #if defined (HOST_HAS_F_SETLKW)
! #define GCOV_LOCKED 1
! #else
! #define GCOV_LOCKED 0
! #endif
  #if IN_GCOV
  #define GCOV_LINKAGE static
  typedef HOST_WIDEST_INT gcov_type;
  #if IN_GCOV > 0
  #include <sys/types.h>
  #endif
  #endif
  #endif /* !IN_LIBGCOV */
  
  /* In gcov we want function linkage to be static, so we do not
--- 158,205 ----
  #define GCC_GCOV_IO_H
  
  #if IN_LIBGCOV
! /* About the target */
! 
! typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
! typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
! #if LONG_LONG_TYPE_SIZE > 32
! typedef signed gcov_type __attribute__ ((mode (DI)));
  #else
! typedef signed gcov_type __attribute__ ((mode (SI)));
  #endif
+ 
  #if defined (TARGET_HAS_F_SETLKW)
  #define GCOV_LOCKED 1
  #else
  #define GCOV_LOCKED 0
  #endif
+ 
  #else /* !IN_LIBGCOV */
! /* About the host */
! 
! typedef unsigned gcov_unsigned_t;
! typedef unsigned gcov_position_t;
! /* gcov_type is typedef'd elsewhere for the compiler */
  #if IN_GCOV
  #define GCOV_LINKAGE static
  typedef HOST_WIDEST_INT gcov_type;
  #if IN_GCOV > 0
  #include <sys/types.h>
  #endif
+ #else /*!IN_GCOV */
+ #if LONG_LONG_TYPE_SIZE > 32
+ #define GCOV_TYPE_NODE intDI_type_node
+ #else
+ #define GCOV_TYPE_NODE intSI_type_node
+ #endif
  #endif
+ 
+ #if defined (HOST_HAS_F_SETLKW)
+ #define GCOV_LOCKED 1
+ #else
+ #define GCOV_LOCKED 0
+ #endif
+ 
  #endif /* !IN_LIBGCOV */
  
  /* In gcov we want function linkage to be static, so we do not
*************** typedef HOST_WIDEST_INT gcov_type;
*** 247,256 ****
  #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 8)
  #define GCOV_TAG_OBJECT_SUMMARY  ((unsigned)0xa1000000)
  #define GCOV_TAG_PROGRAM_SUMMARY ((unsigned)0xa3000000)
! #define GCOV_TAG_SUMMARY_LENGTH  (1 * 4 + GCOV_COUNTERS * (2 * 4 + 3 * 8))
  
  /* Counters that are collected.  */
  #define GCOV_COUNTER_ARCS 	0  /* Arc transitions.  */
  #define GCOV_COUNTERS		1
  
  /* A list of human readable names of the counters */
--- 266,277 ----
  #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 8)
  #define GCOV_TAG_OBJECT_SUMMARY  ((unsigned)0xa1000000)
  #define GCOV_TAG_PROGRAM_SUMMARY ((unsigned)0xa3000000)
! #define GCOV_TAG_SUMMARY_LENGTH  (1 * 4 + GCOV_COUNTERS_SUMMABLE * (2 * 4 + 3 * 8))
  
  /* Counters that are collected.  */
  #define GCOV_COUNTER_ARCS 	0  /* Arc transitions.  */
+ #define GCOV_COUNTERS_SUMMABLE	1  /* Counters which can be
+ 				      summaried. */
  #define GCOV_COUNTERS		1
  
  /* A list of human readable names of the counters */
*************** typedef HOST_WIDEST_INT gcov_type;
*** 296,313 ****
  /* Cumulative counter data.   */
  struct gcov_ctr_summary
  {
!   unsigned num;		/* number of counters.  */
!   unsigned runs;	/* number of program runs */
!   gcov_type sum_all;	/* sum of all counters accumulated. */
!   gcov_type run_max;	/* maximum value on a single run.  */
!   gcov_type sum_max;    /* sum of individual run max values. */
  };
  
  /* Object & program summary record.  */
  struct gcov_summary
  {
!   unsigned checksum;	  /* checksum of program */
!   struct gcov_ctr_summary ctrs[GCOV_COUNTERS];
  };
  
  /* Structures embedded in coveraged program.  The structures generated
--- 317,334 ----
  /* Cumulative counter data.   */
  struct gcov_ctr_summary
  {
!   gcov_unsigned_t num;		/* number of counters.  */
!   gcov_unsigned_t runs;		/* number of program runs */
!   gcov_type sum_all;		/* sum of all counters accumulated. */
!   gcov_type run_max;		/* maximum value on a single run.  */
!   gcov_type sum_max;    	/* sum of individual run max values. */
  };
  
  /* Object & program summary record.  */
  struct gcov_summary
  {
!   gcov_unsigned_t checksum;	/* checksum of program */
!   struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
  };
  
  /* Structures embedded in coveraged program.  The structures generated
*************** struct gcov_summary
*** 320,353 ****
     explicitly calculate the correct array stride.  */
  struct gcov_fn_info
  {
!   unsigned ident;               /* unique ident of function */
!   unsigned checksum;		/* function checksum */
    unsigned n_ctrs[0];		/* instrumented counters */
  };
  
  /* Type of function used to merge counters.  */
! typedef void (*gcov_merge_fn) (gcov_type *, unsigned);
  
  /* Information about counters.  */
  struct gcov_ctr_info
  {
!   unsigned num;		/* number of counters.  */
!   gcov_type *values;	/* their values.  */
!   gcov_merge_fn merge;  /* The function used to merge them.  */
  };
  
  /* Information about a single object file.  */
  struct gcov_info
  {
!   unsigned long version;        /* expected version number */
    struct gcov_info *next;	/* link to next, used by libgcc */
  
    const char *filename;		/* output file name */
  
!   unsigned n_functions;             /* number of functions */
    const struct gcov_fn_info *functions; /* table of functions */
  
!   unsigned ctr_mask;              /* mask of counters instrumented.  */
    struct gcov_ctr_info counts[0]; /* count data. The number of bits
  				     set in the ctr_mask field
  				     determines how big this array
--- 341,374 ----
     explicitly calculate the correct array stride.  */
  struct gcov_fn_info
  {
!   gcov_unsigned_t ident;	/* unique ident of function */
!   gcov_unsigned_t checksum;	/* function checksum */
    unsigned n_ctrs[0];		/* instrumented counters */
  };
  
  /* Type of function used to merge counters.  */
! typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
  
  /* Information about counters.  */
  struct gcov_ctr_info
  {
!   gcov_unsigned_t num;		/* number of counters.  */
!   gcov_type *values;		/* their values.  */
!   gcov_merge_fn merge;  	/* The function used to merge them.  */
  };
  
  /* Information about a single object file.  */
  struct gcov_info
  {
!   gcov_unsigned_t version;	/* expected version number */
    struct gcov_info *next;	/* link to next, used by libgcc */
  
    const char *filename;		/* output file name */
  
!   unsigned n_functions;		/* number of functions */
    const struct gcov_fn_info *functions; /* table of functions */
  
!   unsigned ctr_mask;		/* mask of counters instrumented.  */
    struct gcov_ctr_info counts[0]; /* count data. The number of bits
  				     set in the ctr_mask field
  				     determines how big this array
*************** extern void __gcov_merge_add (gcov_type 
*** 372,379 ****
  GCOV_LINKAGE struct gcov_var
  {
    FILE *file;
!   size_t position;
!   size_t length;
    size_t alloc;
    unsigned modified;
    int error;
--- 393,400 ----
  GCOV_LINKAGE struct gcov_var
  {
    FILE *file;
!   gcov_position_t position;
!   gcov_position_t length;
    size_t alloc;
    unsigned modified;
    int error;
*************** GCOV_LINKAGE int gcov_open (const char *
*** 385,415 ****
  GCOV_LINKAGE int gcov_close (void);
  #if !IN_GCOV
  GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned);
! GCOV_LINKAGE void gcov_write_unsigned (unsigned);
  #if IN_LIBGCOV
  GCOV_LINKAGE void gcov_write_counter (gcov_type);
  #else
  GCOV_LINKAGE void gcov_write_string (const char *);
  #endif
  #if !IN_LIBGCOV
! GCOV_LINKAGE unsigned long gcov_write_tag (unsigned);
! GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/);
! #endif
! GCOV_LINKAGE void gcov_write_tag_length (unsigned, unsigned);
! #if IN_LIBGCOV
! GCOV_LINKAGE void gcov_write_summary (unsigned, const struct gcov_summary *);
  #endif
  #endif /* !IN_GCOV */
  GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned);
! GCOV_LINKAGE unsigned gcov_read_unsigned (void);
  GCOV_LINKAGE gcov_type gcov_read_counter (void);
  #if !IN_LIBGCOV
  GCOV_LINKAGE const char *gcov_read_string (void);
  #endif
  GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *);
! static unsigned long gcov_position (void);
! static void gcov_sync (unsigned long /*base*/, unsigned /*length */);
! static void gcov_seek (unsigned long /*position*/);
  static void gcov_rewrite (void);
  static int gcov_is_eof (void);
  static int gcov_is_error (void);
--- 406,436 ----
  GCOV_LINKAGE int gcov_close (void);
  #if !IN_GCOV
  GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned);
! GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t);
  #if IN_LIBGCOV
  GCOV_LINKAGE void gcov_write_counter (gcov_type);
  #else
  GCOV_LINKAGE void gcov_write_string (const char *);
  #endif
  #if !IN_LIBGCOV
! GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
! GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
! #else
! GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t);
! GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
! 				      const struct gcov_summary *);
  #endif
  #endif /* !IN_GCOV */
  GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned);
! GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void);
  GCOV_LINKAGE gcov_type gcov_read_counter (void);
  #if !IN_LIBGCOV
  GCOV_LINKAGE const char *gcov_read_string (void);
  #endif
  GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *);
! static gcov_position_t gcov_position (void);
! static void gcov_sync (gcov_position_t /*base*/, gcov_unsigned_t /*length */);
! static void gcov_seek (gcov_position_t /*position*/);
  static void gcov_rewrite (void);
  static int gcov_is_eof (void);
  static int gcov_is_error (void);
*************** GCOV_LINKAGE time_t gcov_time (void);
*** 419,425 ****
  
  /* Save the current position in the gcov file.  */
  
! static inline unsigned long
  gcov_position (void)
  {
    return gcov_var.position;
--- 440,446 ----
  
  /* Save the current position in the gcov file.  */
  
! static inline gcov_position_t
  gcov_position (void)
  {
    return gcov_var.position;
*************** gcov_position (void)
*** 429,435 ****
     gcov_save_position, LENGTH should be a record length, or zero.  */
  
  static inline void
! gcov_sync (unsigned long base, unsigned length)
  {
    if (gcov_var.buffer)
      {
--- 450,456 ----
     gcov_save_position, LENGTH should be a record length, or zero.  */
  
  static inline void
! gcov_sync (gcov_position_t base, gcov_unsigned_t length)
  {
    if (gcov_var.buffer)
      {
*************** gcov_sync (unsigned long base, unsigned 
*** 446,452 ****
  /* Move to the end of the gcov file.  */
  
  static inline void
! gcov_seek (unsigned long base)
  {
    gcov_var.position = base < gcov_var.length ? base : gcov_var.length;
  }
--- 467,473 ----
  /* Move to the end of the gcov file.  */
  
  static inline void
! gcov_seek (gcov_position_t base)
  {
    gcov_var.position = base < gcov_var.length ? base : gcov_var.length;
  }
Index: libgcov.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/libgcov.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 libgcov.c
*** libgcov.c	7 May 2003 10:40:09 -0000	1.13
--- libgcov.c	10 May 2003 16:48:04 -0000
*************** static struct gcov_info *gcov_list;
*** 79,90 ****
  
  /* A program checksum allows us to distinguish program data for an
     object file included in multiple programs.  */
! static unsigned gcov_crc32;
  
  static void
! gcov_version_mismatch (struct gcov_info *ptr, unsigned version)
  {
!   unsigned expected = GCOV_VERSION;
    unsigned ix;
    char e[4], v[4];
  
--- 79,90 ----
  
  /* A program checksum allows us to distinguish program data for an
     object file included in multiple programs.  */
! static gcov_unsigned_t gcov_crc32;
  
  static void
! gcov_version_mismatch (struct gcov_info *ptr, gcov_unsigned_t version)
  {
!   gcov_unsigned_t expected = GCOV_VERSION;
    unsigned ix;
    char e[4], v[4];
  
*************** gcov_exit (void)
*** 123,133 ****
        unsigned t_ix;
        
        for (t_ix = 0, ci_ptr = gi_ptr->counts, cs_ptr = this_program.ctrs;
! 	   t_ix != GCOV_COUNTERS; t_ix++, cs_ptr++)
  	if ((1 << t_ix) & gi_ptr->ctr_mask)
  	  {
  	    const gcov_type *c_ptr;
! 	    unsigned c_num;
  
  	    cs_ptr->num += ci_ptr->num;
  	    for (c_num = ci_ptr->num, c_ptr = ci_ptr->values; c_num--; c_ptr++)
--- 123,133 ----
        unsigned t_ix;
        
        for (t_ix = 0, ci_ptr = gi_ptr->counts, cs_ptr = this_program.ctrs;
! 	   t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++, cs_ptr++)
  	if ((1 << t_ix) & gi_ptr->ctr_mask)
  	  {
  	    const gcov_type *c_ptr;
! 	    gcov_unsigned_t c_num;
  
  	    cs_ptr->num += ci_ptr->num;
  	    for (c_num = ci_ptr->num, c_ptr = ci_ptr->values; c_num--; c_ptr++)
*************** gcov_exit (void)
*** 140,146 ****
  	  }
      }
  
!   /* Now write the data  */
    for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
      {
        struct gcov_summary this_object;
--- 140,146 ----
  	  }
      }
  
!   /* Now merge each file  */
    for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
      {
        struct gcov_summary this_object;
*************** gcov_exit (void)
*** 154,171 ****
        struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
        int error;
        int merging;
!       unsigned tag, length;
!       unsigned long summary_pos = ~0UL;
  
        /* Totals for this object file.  */
        memset (&this_object, 0, sizeof (this_object));
        for (t_ix = c_ix = 0,
  	     ci_ptr = gi_ptr->counts, cs_ptr = this_object.ctrs;
! 	   t_ix != GCOV_COUNTERS; t_ix++, cs_ptr++)
  	if ((1 << t_ix) & gi_ptr->ctr_mask)
  	  {
  	    const gcov_type *c_ptr;
! 	    unsigned c_num;
  
  	    cs_ptr->num += ci_ptr->num;
  	    values[c_ix] = ci_ptr->values;
--- 154,171 ----
        struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
        int error;
        int merging;
!       gcov_unsigned_t tag, length;
!       gcov_position_t summary_pos = ~(gcov_position_t)0;
  
        /* Totals for this object file.  */
        memset (&this_object, 0, sizeof (this_object));
        for (t_ix = c_ix = 0,
  	     ci_ptr = gi_ptr->counts, cs_ptr = this_object.ctrs;
! 	   t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++, cs_ptr++)
  	if ((1 << t_ix) & gi_ptr->ctr_mask)
  	  {
  	    const gcov_type *c_ptr;
! 	    gcov_unsigned_t c_num;
  
  	    cs_ptr->num += ci_ptr->num;
  	    values[c_ix] = ci_ptr->values;
*************** gcov_exit (void)
*** 258,264 ****
  	  /* Check program & object summary */
  	  while (!gcov_is_eof ())
  	    {
! 	      unsigned long base = gcov_position ();
  	      int is_program;
  	      
  	      tag = gcov_read_unsigned ();
--- 258,264 ----
  	  /* Check program & object summary */
  	  while (!gcov_is_eof ())
  	    {
! 	      gcov_position_t base = gcov_position ();
  	      int is_program;
  	      
  	      tag = gcov_read_unsigned ();
*************** gcov_exit (void)
*** 295,301 ****
  	     cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
  	     cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
  	     cs_all = all.ctrs;
! 	   t_ix != GCOV_COUNTERS;
  	   t_ix++, cs_obj++, cs_tobj++, cs_prg++, cs_tprg++, cs_all++)
  	{
  	  if ((1 << t_ix) & gi_ptr->ctr_mask)
--- 295,301 ----
  	     cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
  	     cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
  	     cs_all = all.ctrs;
! 	   t_ix != GCOV_COUNTERS_SUMMABLE;
  	   t_ix++, cs_obj++, cs_tobj++, cs_prg++, cs_tprg++, cs_all++)
  	{
  	  if ((1 << t_ix) & gi_ptr->ctr_mask)
*************** gcov_exit (void)
*** 340,347 ****
        program.checksum = gcov_crc32;
        
        /* Write out the data.  */
!       gcov_write_unsigned (GCOV_DATA_MAGIC);
!       gcov_write_unsigned (GCOV_VERSION);
        
        /* Write execution counts for each function.  */
        for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--;
--- 340,346 ----
        program.checksum = gcov_crc32;
        
        /* Write out the data.  */
!       gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
        
        /* Write execution counts for each function.  */
        for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--;
*************** __gcov_init (struct gcov_info *info)
*** 396,411 ****
    else
      {
        const char *ptr = info->filename;
!       unsigned crc32 = gcov_crc32;
    
        do
  	{
  	  unsigned ix;
! 	  unsigned value = *ptr << 24;
  
  	  for (ix = 8; ix--; value <<= 1)
  	    {
! 	      unsigned feedback;
  
  	      feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
  	      crc32 <<= 1;
--- 395,410 ----
    else
      {
        const char *ptr = info->filename;
!       gcov_unsigned_t crc32 = gcov_crc32;
    
        do
  	{
  	  unsigned ix;
! 	  gcov_unsigned_t value = *ptr << 24;
  
  	  for (ix = 8; ix--; value <<= 1)
  	    {
! 	      gcov_unsigned_t feedback;
  
  	      feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
  	      crc32 <<= 1;
*************** __gcov_flush (void)
*** 456,464 ****
     an array COUNTERS of N_COUNTERS old counters and it reads the same number
     of counters from the gcov file.  */
  void
! __gcov_merge_add (counters, n_counters)
!      gcov_type *counters;
!      unsigned n_counters;
  {
    for (; n_counters; counters++, n_counters--)
      *counters += gcov_read_counter ();
--- 455,461 ----
     an array COUNTERS of N_COUNTERS old counters and it reads the same number
     of counters from the gcov file.  */
  void
! __gcov_merge_add (gcov_type *counters, unsigned n_counters)
  {
    for (; n_counters; counters++, n_counters--)
      *counters += gcov_read_counter ();
Index: profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 profile.c
*** profile.c	23 Apr 2003 14:05:11 -0000	1.118
--- profile.c	10 May 2003 17:09:34 -0000
*************** branch_prob ()
*** 670,691 ****
    if (rtl_dump_file)
      fprintf (rtl_dump_file, "%d ignored edges\n", ignored_edges);
  
!   /* Write the .bbg data from which gcov can reconstruct the basic block
!      graph.  First output the number of basic blocks, and then for every
!      edge output the source and target basic block numbers.
!      NOTE: The format of this file must be compatible with gcov.  */
  
    if (coverage_begin_output ())
      {
!       long offset;
        
-       /* Basic block flags */
        offset = gcov_write_tag (GCOV_TAG_BLOCKS);
        for (i = 0; i != (unsigned) (n_basic_blocks + 2); i++)
  	gcov_write_unsigned (0);
        gcov_write_length (offset);
!       
!       /* Arcs */
        FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
  	{
  	  edge e;
--- 670,694 ----
    if (rtl_dump_file)
      fprintf (rtl_dump_file, "%d ignored edges\n", ignored_edges);
  
!   /* Write the data from which gcov can reconstruct the basic block
!      graph.  */
  
+   /* Basic block flags */
    if (coverage_begin_output ())
      {
!       gcov_position_t offset;
        
        offset = gcov_write_tag (GCOV_TAG_BLOCKS);
        for (i = 0; i != (unsigned) (n_basic_blocks + 2); i++)
  	gcov_write_unsigned (0);
        gcov_write_length (offset);
!     }
! 
!   /* Arcs */
!   if (coverage_begin_output ())
!     {
!       gcov_position_t offset;
! 
        FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
  	{
  	  edge e;
*************** branch_prob ()
*** 716,727 ****
  	}
      }
    
!   /* Output line number information about each basic block for GCOV
!      utility.  */
    if (coverage_begin_output ())
      {
        char const *prev_file_name = NULL;
!       long offset;
        
        FOR_EACH_BB (bb)
  	{
--- 719,729 ----
  	}
      }
    
!   /* Line numbers. */
    if (coverage_begin_output ())
      {
        char const *prev_file_name = NULL;
!       gcov_position_t offset;
        
        FOR_EACH_BB (bb)
  	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]