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] Change GCOV_TAG_FUNCTION layout


Hi,
I've installed this patch which changes the TAG_FUNCTION layout so that
no strings are needed in the data file. This means there are no
variable length objects dumped by libgcov and will help a future improvement.
(it also shrinks libgcov a bit too)

booted & tested on i686-pc-linux-gnu, with & w/o --enable-coverage

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan at codesourcery dot com : http://www.cs.bris.ac.uk/~nathan/ : nathan at acm dot org

2003-04-23  Nathan Sidwell  <nathan at codesourcery dot com>

	New GCOV_TAG_FUNCTION layout
	* coverage.c (struct function_list): Replace name with ident.
	(struct counts_entry): Likewise.
	(fn_ident): New.
	(htab_counts_entry_hash, htab_counts_entry_eq,
	htab_counts_entry_del): Adjust.
	(reads_count_file, get_coverage_counts,
	coverage_begin_output, coverage_end_function): Adjust.
	(build_fn_info_type, build_fn_info_value): Likewise.
	* gcov-dump.c (tag_function): Adjust.
	* gcov-io.c (gcov_write_string, gcov_read_string): Not in LIBGCOV.
	* gcov-io.h (gcov_write_string, gcov_read_string): Not in LIBGCOV.
	* gcov.c (struct function_info): Add ident.
	(read_graph_file, read_count_file): Adjust.
	* libgcov.c (gcov_exit): Adjust.

Index: coverage.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 coverage.c
*** coverage.c	23 Apr 2003 14:05:11 -0000	1.2
--- coverage.c	23 Apr 2003 17:39:34 -0000
*************** Software Foundation, 59 Temple Place - S
*** 50,56 ****
  struct function_list
  {
    struct function_list *next; 	 /* next function */
!   const char *name; 		 /* function name */
    unsigned checksum;	         /* function checksum */
    unsigned n_ctrs[GCOV_COUNTERS];/* number of counters.  */
  };
--- 50,56 ----
  struct function_list
  {
    struct function_list *next; 	 /* next function */
!   unsigned ident; 		 /* function ident */
    unsigned checksum;	         /* function checksum */
    unsigned n_ctrs[GCOV_COUNTERS];/* number of counters.  */
  };
*************** struct function_list
*** 59,65 ****
  typedef struct counts_entry
  {
    /* We hash by  */
!   char *function_name;
    unsigned ctr;
    
    /* Store  */
--- 59,65 ----
  typedef struct counts_entry
  {
    /* We hash by  */
!   unsigned ident;
    unsigned ctr;
    
    /* Store  */
*************** typedef struct counts_entry
*** 72,77 ****
--- 72,78 ----
    
  } counts_entry_t;
  
+ static unsigned fn_ident = 1;
  static struct function_list *functions_head = 0;
  static struct function_list **functions_tail = &functions_head;
  
*************** htab_counts_entry_hash (of)
*** 118,124 ****
  {
    const counts_entry_t *entry = of;
  
!   return htab_hash_string (entry->function_name) ^ entry->ctr;
  }
  
  static int
--- 119,125 ----
  {
    const counts_entry_t *entry = of;
  
!   return entry->ident * GCOV_COUNTERS + entry->ctr;
  }
  
  static int
*************** htab_counts_entry_eq (of1, of2)
*** 129,136 ****
    const counts_entry_t *entry1 = of1;
    const counts_entry_t *entry2 = of2;
  
!   return !strcmp (entry1->function_name, entry2->function_name)
!     && entry1->ctr == entry2->ctr;
  }
  
  static void
--- 130,136 ----
    const counts_entry_t *entry1 = of1;
    const counts_entry_t *entry2 = of2;
  
!   return entry1->ident == entry2->ident && entry1->ctr == entry2->ctr;
  }
  
  static void
*************** htab_counts_entry_del (of)
*** 139,145 ****
  {
    counts_entry_t *entry = of;
  
-   free (entry->function_name);
    free (entry->counts);
    free (entry);
  }
--- 139,144 ----
*************** htab_counts_entry_del (of)
*** 149,155 ****
  static void
  read_counts_file ()
  {
!   char *function_name_buffer = NULL;
    unsigned version, ix, checksum = -1;
    counts_entry_t *summaried = NULL;
    unsigned seen_summary = 0;
--- 148,154 ----
  static void
  read_counts_file ()
  {
!   unsigned fn_ident = 0;
    unsigned version, ix, checksum = -1;
    counts_entry_t *summaried = NULL;
    unsigned seen_summary = 0;
*************** read_counts_file ()
*** 193,201 ****
        offset = gcov_position ();
        if (tag == GCOV_TAG_FUNCTION)
  	{
! 	  const char *string = gcov_read_string ();
! 	  free (function_name_buffer);
! 	  function_name_buffer = string ? xstrdup (string) : NULL;
  	  checksum = gcov_read_unsigned ();
  	  if (seen_summary)
  	    {
--- 192,198 ----
        offset = gcov_position ();
        if (tag == GCOV_TAG_FUNCTION)
  	{
! 	  fn_ident = gcov_read_unsigned ();
  	  checksum = gcov_read_unsigned ();
  	  if (seen_summary)
  	    {
*************** read_counts_file ()
*** 231,243 ****
  	      entry->summary.sum_max += csum->sum_max;
  	    }
  	}
!       else if (GCOV_TAG_IS_COUNTER (tag) && function_name_buffer)
  	{
  	  counts_entry_t **slot, *entry, elt;
  	  unsigned n_counts = length / 8;
  	  unsigned ix;
  
! 	  elt.function_name = function_name_buffer;
  	  elt.ctr = GCOV_COUNTER_FOR_TAG (tag);
  
  	  slot = (counts_entry_t **) htab_find_slot
--- 228,240 ----
  	      entry->summary.sum_max += csum->sum_max;
  	    }
  	}
!       else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident)
  	{
  	  counts_entry_t **slot, *entry, elt;
  	  unsigned n_counts = length / 8;
  	  unsigned ix;
  
! 	  elt.ident = fn_ident;
  	  elt.ctr = GCOV_COUNTER_FOR_TAG (tag);
  
  	  slot = (counts_entry_t **) htab_find_slot
*************** read_counts_file ()
*** 246,252 ****
  	  if (!entry)
  	    {
  	      *slot = entry = xcalloc (1, sizeof (counts_entry_t));
! 	      entry->function_name = xstrdup (elt.function_name);
  	      entry->ctr = elt.ctr;
  	      entry->checksum = checksum;
  	      entry->summary.num = n_counts;
--- 243,249 ----
  	  if (!entry)
  	    {
  	      *slot = entry = xcalloc (1, sizeof (counts_entry_t));
! 	      entry->ident = elt.ident;
  	      entry->ctr = elt.ctr;
  	      entry->checksum = checksum;
  	      entry->summary.num = n_counts;
*************** read_counts_file ()
*** 255,261 ****
  	  else if (entry->checksum != checksum
  		   || entry->summary.num != n_counts)
  	    {
! 	      warning ("profile mismatch for `%s'", function_name_buffer);
  	      htab_delete (counts_hash);
  	      break;
  	    }
--- 252,258 ----
  	  else if (entry->checksum != checksum
  		   || entry->summary.num != n_counts)
  	    {
! 	      warning ("coverage mismatch for function %u", fn_ident);
  	      htab_delete (counts_hash);
  	      break;
  	    }
*************** read_counts_file ()
*** 281,287 ****
  	}
      }
  
-   free (function_name_buffer);
    gcov_close ();
  }
  
--- 278,283 ----
*************** get_coverage_counts (unsigned counter, u
*** 304,327 ****
        return NULL;
      }
  
!   elt.function_name
!     = (char *) IDENTIFIER_POINTER
!     (DECL_ASSEMBLER_NAME (current_function_decl));
    elt.ctr = counter;
    entry = htab_find (counts_hash, &elt);
    if (!entry)
      {
!       warning ("No profile for function '%s' found.", elt.function_name);
        return 0;
      }
    
    if (expected != entry->summary.num
        || compute_checksum () != entry->checksum)
      {
!       warning ("profile mismatch for `%s'", elt.function_name);
        return NULL;
      }
! 
    if (summary)
      *summary = &entry->summary;
  
--- 300,323 ----
        return NULL;
      }
  
!   elt.ident = fn_ident;
    elt.ctr = counter;
    entry = htab_find (counts_hash, &elt);
    if (!entry)
      {
!       warning ("no coverage for function '%s' found.", IDENTIFIER_POINTER
! 	       (DECL_ASSEMBLER_NAME (current_function_decl)));
        return 0;
      }
    
    if (expected != entry->summary.num
        || compute_checksum () != entry->checksum)
      {
!       warning ("coverage mismatch for `%s'", IDENTIFIER_POINTER
! 	       (DECL_ASSEMBLER_NAME (current_function_decl)));
        return NULL;
      }
!   
    if (summary)
      *summary = &entry->summary;
  
*************** coverage_begin_output ()
*** 426,434 ****
        
        /* Announce function */
        offset = gcov_write_tag (GCOV_TAG_FUNCTION);
        gcov_write_string (IDENTIFIER_POINTER
  			 (DECL_ASSEMBLER_NAME (current_function_decl)));
-       gcov_write_unsigned (compute_checksum ());
        gcov_write_string (file);
        gcov_write_unsigned (line);
        gcov_write_length (offset);
--- 422,431 ----
        
        /* Announce function */
        offset = gcov_write_tag (GCOV_TAG_FUNCTION);
+       gcov_write_unsigned (fn_ident);
+       gcov_write_unsigned (compute_checksum ());
        gcov_write_string (IDENTIFIER_POINTER
  			 (DECL_ASSEMBLER_NAME (current_function_decl)));
        gcov_write_string (file);
        gcov_write_unsigned (line);
        gcov_write_length (offset);
*************** coverage_end_function ()
*** 456,470 ****
      {
        struct function_list *item;
        
-       /* ??? Probably should re-use the existing struct function.  */
        item = xmalloc (sizeof (struct function_list));
        
        *functions_tail = item;
        functions_tail = &item->next;
  	
        item->next = 0;
!       item->name = xstrdup (IDENTIFIER_POINTER
! 			    (DECL_ASSEMBLER_NAME (current_function_decl)));
        item->checksum = compute_checksum ();
        for (i = 0; i != GCOV_COUNTERS; i++)
  	{
--- 453,466 ----
      {
        struct function_list *item;
        
        item = xmalloc (sizeof (struct function_list));
        
        *functions_tail = item;
        functions_tail = &item->next;
  	
        item->next = 0;
!       /* It would be nice to use the unique source location. */
!       item->ident = fn_ident;
        item->checksum = compute_checksum ();
        for (i = 0; i != GCOV_COUNTERS; i++)
  	{
*************** coverage_end_function ()
*** 476,481 ****
--- 472,478 ----
        fn_ctr_mask = 0;
      }
    bbg_function_announced = 0;
+   fn_ident++;
  }
  
  /* Creates the gcov_fn_info RECORD_TYPE.  */
*************** build_fn_info_type (counters)
*** 486,498 ****
  {
    tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
    tree field, fields;
-   tree string_type =
- 	  build_pointer_type (build_qualified_type (char_type_node,
- 						    TYPE_QUAL_CONST));
    tree array_type;
    
!   /* name */
!   fields = build_decl (FIELD_DECL, NULL_TREE, string_type);
  
    /* checksum */
    field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
--- 483,492 ----
  {
    tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
    tree field, fields;
    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);
*************** build_fn_info_value (function, type)
*** 523,542 ****
  {
    tree value = NULL_TREE;
    tree fields = TYPE_FIELDS (type);
-   size_t name_len = strlen (function->name);
-   tree fname = build_string (name_len + 1, function->name);
-   tree string_type =
- 	  build_pointer_type (build_qualified_type (char_type_node,
- 						    TYPE_QUAL_CONST));
    unsigned ix;
    tree array_value = NULL_TREE;
    
!   /* name */
!   TREE_TYPE (fname) =
! 	  build_array_type (char_type_node,
! 			    build_index_type (build_int_2 (name_len, 0)));
    value = tree_cons (fields,
! 		     build1 (ADDR_EXPR, string_type, fname),
  		     value);
    fields = TREE_CHAIN (fields);
    
--- 517,529 ----
  {
    tree value = NULL_TREE;
    tree fields = TYPE_FIELDS (type);
    unsigned ix;
    tree array_value = NULL_TREE;
    
!   /* ident */
    value = tree_cons (fields,
! 		     convert (unsigned_type_node,
! 			      build_int_2 (function->ident, 0)),
  		     value);
    fields = TREE_CHAIN (fields);
    
*************** coverage_init (filename)
*** 854,869 ****
  {
    int len = strlen (filename);
  
    da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1);
    strcpy (da_file_name, filename);
    strcat (da_file_name, GCOV_DATA_SUFFIX);
    
!   read_counts_file ();
! 
!   /* Open the bbg output file.  */
    bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1);
    strcpy (bbg_file_name, filename);
    strcat (bbg_file_name, GCOV_GRAPH_SUFFIX);
  }
  
  /* Performs file-level cleanup.  Close graph file, generate coverage
--- 841,857 ----
  {
    int len = strlen (filename);
  
+   /* Name of da file.  */
    da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1);
    strcpy (da_file_name, filename);
    strcat (da_file_name, GCOV_DATA_SUFFIX);
    
!   /* Name of bbg file.  */
    bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1);
    strcpy (bbg_file_name, filename);
    strcat (bbg_file_name, GCOV_GRAPH_SUFFIX);
+ 
+   read_counts_file ();
  }
  
  /* Performs file-level cleanup.  Close graph file, generate coverage
Index: gcov-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-dump.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 gcov-dump.c
*** gcov-dump.c	23 Apr 2003 14:05:11 -0000	1.9
--- gcov-dump.c	23 Apr 2003 17:39:35 -0000
*************** tag_function (filename, tag, length)
*** 254,268 ****
       unsigned tag ATTRIBUTE_UNUSED;
       unsigned length ATTRIBUTE_UNUSED;
  {
-   const char *name;
    unsigned long pos = gcov_position ();
    
!   name = gcov_read_string ();
!   printf (" `%s'", name ? name : "NULL");
!   printf (" checksum=0x%08x", gcov_read_unsigned ());
  
    if (gcov_position () - pos < length)
      {
        name = gcov_read_string ();
        printf (" %s", name ? name : "NULL");
        printf (":%u", gcov_read_unsigned ());
--- 254,270 ----
       unsigned tag ATTRIBUTE_UNUSED;
       unsigned length ATTRIBUTE_UNUSED;
  {
    unsigned long pos = gcov_position ();
    
!   printf (" ident=%u", gcov_read_unsigned ());
!   printf (", checksum=0x%08x", gcov_read_unsigned ());
  
    if (gcov_position () - pos < length)
      {
+       const char *name;
+       
+       name = gcov_read_string ();
+       printf (", `%s'", name ? name : "NULL");
        name = gcov_read_string ();
        printf (" %s", name ? name : "NULL");
        printf (":%u", gcov_read_unsigned ());
Index: gcov-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 gcov-io.c
*** gcov-io.c	23 Apr 2003 14:05:11 -0000	1.2
--- gcov-io.c	23 Apr 2003 17:39:38 -0000
*************** gcov_write_counter (gcov_type value)
*** 222,227 ****
--- 222,228 ----
  }
  #endif /* IN_LIBGCOV */
  
+ #if !IN_LIBGCOV
  /* Write STRING to coverage file.  Sets error flag on file
     error, overflow flag on overflow */
  
*************** gcov_write_string (const char *string)
*** 254,259 ****
--- 255,261 ----
        memcpy (buffer + 4 + length, &pad, rem);
      }
  }
+ #endif
  
  /* Write a tag TAG and reserve space for the record length. Return a
     value to be used for gcov_write_length.  */
*************** gcov_read_counter ()
*** 396,401 ****
--- 398,404 ----
     buffer, or NULL on empty string. You must copy the string before
     calling another gcov function.  */
  
+ #if !IN_LIBGCOV
  GCOV_LINKAGE const char *
  gcov_read_string ()
  {
*************** gcov_read_string ()
*** 407,412 ****
--- 410,416 ----
    length += 4 - (length & 3);
    return (const char *) gcov_read_bytes (length);
  }
+ #endif
  
  GCOV_LINKAGE void
  gcov_read_summary (struct gcov_summary *summary)
Index: gcov-io.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.h,v
retrieving revision 1.29
diff -c -3 -p -r1.29 gcov-io.h
*** gcov-io.h	23 Apr 2003 14:05:11 -0000	1.29
--- gcov-io.h	23 Apr 2003 17:39:38 -0000
*************** Software Foundation, 59 Temple Place - S
*** 95,104 ****
     file and [a1..ff] for the counter file.
  
     The basic block graph file contains the following records
!    	bbg:  function-graph*
  	function-graph: announce_function basic_blocks {arcs | lines}*
! 	announce_function: header string:name int32:checksum
! 		string:source int32:lineno
  	basic_block: header int32:flags*
  	arcs: header int32:block_no arc*
  	arc:  int32:dest_block int32:flags
--- 95,105 ----
     file and [a1..ff] for the counter file.
  
     The basic block graph file contains the following records
!    	bbg:  unit function-graph*
! 	unit: header int32:checksum string:source
  	function-graph: announce_function basic_blocks {arcs | lines}*
! 	announce_function: header int32:ident int32:checksum
! 		string:name string:source int32:lineno
  	basic_block: header int32:flags*
  	arcs: header int32:block_no arc*
  	arc:  int32:dest_block int32:flags
*************** Software Foundation, 59 Temple Place - S
*** 123,131 ****
     blocks they are for.
  
     The data file contains the following records.
!         da:   {function-data* summary:object summary:program*}*
          function-data:	announce_function arc_counts
! 	announce_function: header string:name int32:checksum
  	arc_counts: header int64:count*
  	summary: int32:checksum {count-summary}GCOV_COUNTERS
  	count-summary:	int32:num int32:runs int64:sum
--- 124,133 ----
     blocks they are for.
  
     The data file contains the following records.
!         da: {unit function-data* summary:object summary:program*}*
! 	unit: header int32:checksum
          function-data:	announce_function arc_counts
! 	announce_function: header int32:ident int32:checksum
  	arc_counts: header int64:count*
  	summary: int32:checksum {count-summary}GCOV_COUNTERS
  	count-summary:	int32:num int32:runs int64:sum
*************** struct gcov_summary
*** 279,285 ****
     explicitly calculate the correct array stride.  */
  struct gcov_fn_info
  {
!   const char *name;	        /* (mangled) name of function */
    unsigned checksum;		/* function checksum */
    unsigned n_ctrs[0];		/* instrumented counters */
  };
--- 281,287 ----
     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 */
  };
*************** GCOV_LINKAGE unsigned char *gcov_write_b
*** 339,346 ****
  GCOV_LINKAGE void gcov_write_unsigned (unsigned);
  #if IN_LIBGCOV
  GCOV_LINKAGE void gcov_write_counter (gcov_type);
! #endif
  GCOV_LINKAGE void gcov_write_string (const char *);
  GCOV_LINKAGE unsigned long gcov_write_tag (unsigned);
  GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/);
  #if IN_LIBGCOV
--- 341,349 ----
  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
  GCOV_LINKAGE unsigned long gcov_write_tag (unsigned);
  GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/);
  #if IN_LIBGCOV
*************** GCOV_LINKAGE void gcov_write_summary (un
*** 350,358 ****
  GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned);
  GCOV_LINKAGE unsigned gcov_read_unsigned (void);
  GCOV_LINKAGE gcov_type gcov_read_counter (void);
  GCOV_LINKAGE const char *gcov_read_string (void);
  GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *);
- 
  static unsigned long gcov_position (void);
  static void gcov_seek (unsigned long /*base*/, unsigned /*length */);
  static unsigned long gcov_seek_end (void);
--- 353,362 ----
  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_seek (unsigned long /*base*/, unsigned /*length */);
  static unsigned long gcov_seek_end (void);
Index: gcov.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 gcov.c
*** gcov.c	23 Apr 2003 14:05:11 -0000	1.61
--- gcov.c	23 Apr 2003 17:39:41 -0000
*************** typedef struct function_info
*** 168,173 ****
--- 168,174 ----
  {
    /* Name of function.  */
    char *name;
+   unsigned ident;
    unsigned checksum;
  
    /* Array of basic blocks.  */
*************** read_graph_file ()
*** 744,764 ****
        unsigned tag = gcov_read_unsigned ();
        unsigned length = gcov_read_unsigned ();
        unsigned long base = gcov_position ();
!       
        if (tag == GCOV_TAG_FUNCTION)
  	{
  	  char *function_name;
! 	  unsigned checksum, lineno;
  	  source_t *src;
  	  function_t *probe, *prev;
  
! 	  function_name = xstrdup (gcov_read_string ());
  	  checksum = gcov_read_unsigned ();
  	  src = find_source (gcov_read_string ());
  	  lineno = gcov_read_unsigned ();
  	  
  	  fn = (function_t *)xcalloc (1, sizeof (function_t));
  	  fn->name = function_name;
  	  fn->checksum = checksum;
  	  fn->src = src;
  	  fn->line = lineno;
--- 745,767 ----
        unsigned tag = gcov_read_unsigned ();
        unsigned length = gcov_read_unsigned ();
        unsigned long base = gcov_position ();
! 
        if (tag == GCOV_TAG_FUNCTION)
  	{
  	  char *function_name;
! 	  unsigned ident, checksum, lineno;
  	  source_t *src;
  	  function_t *probe, *prev;
  
! 	  ident = gcov_read_unsigned ();
  	  checksum = gcov_read_unsigned ();
+ 	  function_name = xstrdup (gcov_read_string ());
  	  src = find_source (gcov_read_string ());
  	  lineno = gcov_read_unsigned ();
  	  
  	  fn = (function_t *)xcalloc (1, sizeof (function_t));
  	  fn->name = function_name;
+ 	  fn->ident = ident;
  	  fn->checksum = checksum;
  	  fn->src = src;
  	  fn->line = lineno;
*************** read_count_file ()
*** 1015,1021 ****
  	program_count++;
        else if (tag == GCOV_TAG_FUNCTION)
  	{
! 	  const char *function_name = gcov_read_string ();
  	  struct function_info *fn_n = functions;
  
  	  for (fn = fn ? fn->next : NULL; ; fn = fn->next)
--- 1018,1024 ----
  	program_count++;
        else if (tag == GCOV_TAG_FUNCTION)
  	{
! 	  unsigned ident = gcov_read_unsigned ();
  	  struct function_info *fn_n = functions;
  
  	  for (fn = fn ? fn->next : NULL; ; fn = fn->next)
*************** read_count_file ()
*** 1026,1036 ****
  		fn_n = NULL;
  	      else
  		{
! 		  fnotice (stderr, "%s:unknown function `%s'\n",
! 			   da_file_name, function_name);
  		  break;
  		}
! 	      if (!strcmp (fn->name, function_name))
  		break;
  	    }
  
--- 1029,1039 ----
  		fn_n = NULL;
  	      else
  		{
! 		  fnotice (stderr, "%s:unknown function `%u'\n",
! 			   da_file_name, ident);
  		  break;
  		}
! 	      if (fn->ident == ident)
  		break;
  	    }
  
Index: libgcov.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/libgcov.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 libgcov.c
*** libgcov.c	23 Apr 2003 14:05:11 -0000	1.9
--- libgcov.c	23 Apr 2003 17:39:42 -0000
*************** gcov_exit (void)
*** 203,209 ****
  	    }
  	  
  	  /* Merge execution counts for each function.  */
! 	  for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--;
  	       fi_ptr = (const struct gcov_fn_info *)
  		 ((const char *) fi_ptr + fi_stride))
  	    {
--- 203,210 ----
  	    }
  	  
  	  /* Merge execution counts for each function.  */
! 	  for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions;
! 	       f_ix--;
  	       fi_ptr = (const struct gcov_fn_info *)
  		 ((const char *) fi_ptr + fi_stride))
  	    {
*************** gcov_exit (void)
*** 211,229 ****
  	      length = gcov_read_unsigned ();
  
  	      /* Check function */
! 	      if (tag != GCOV_TAG_FUNCTION)
  		{
  		read_mismatch:;
  		  fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
  			   gi_ptr->filename,
! 			   fi_ptr ? fi_ptr->name : "summaries");
  		  goto read_fatal;
  		}
  
- 	      if (strcmp (gcov_read_string (), fi_ptr->name)
- 		  || gcov_read_unsigned () != fi_ptr->checksum)
- 		goto read_mismatch;
- 
  	      for (c_ix = t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
  		if ((1 << t_ix) & gi_ptr->ctr_mask)
  		  {
--- 212,228 ----
  	      length = gcov_read_unsigned ();
  
  	      /* Check function */
! 	      if (tag != GCOV_TAG_FUNCTION
! 		  || gcov_read_unsigned () != fi_ptr->ident
! 		  || gcov_read_unsigned () != fi_ptr->checksum)
  		{
  		read_mismatch:;
  		  fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
  			   gi_ptr->filename,
! 			   f_ix + 1 ? "function" : "summaries");
  		  goto read_fatal;
  		}
  
  	      for (c_ix = t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
  		if ((1 << t_ix) & gi_ptr->ctr_mask)
  		  {
*************** gcov_exit (void)
*** 284,292 ****
        if (!summary_pos)
  	memset (&program, 0, sizeof (program));
  
-       fi_ptr = 0;
-       
        /* Merge the summaries.  */
        for (t_ix = c_ix = 0,
  	     cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
  	     cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
--- 283,290 ----
        if (!summary_pos)
  	memset (&program, 0, sizeof (program));
  
        /* Merge the summaries.  */
+       f_ix = ~0u;
        for (t_ix = c_ix = 0,
  	     cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
  	     cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
*************** gcov_exit (void)
*** 346,352 ****
  	{
  	  /* Announce function.  */
  	  base = gcov_write_tag (GCOV_TAG_FUNCTION);
! 	  gcov_write_string (fi_ptr->name);
  	  gcov_write_unsigned (fi_ptr->checksum);
  	  gcov_write_length (base);
  
--- 344,350 ----
  	{
  	  /* Announce function.  */
  	  base = gcov_write_tag (GCOV_TAG_FUNCTION);
! 	  gcov_write_unsigned (fi_ptr->ident);
  	  gcov_write_unsigned (fi_ptr->checksum);
  	  gcov_write_length (base);
  

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