Hi,

This patch fixes the issue when using gcov-tool to merge LIPO profiles
after we compressing the module infomration . We should not decompress
the string as the compressed string should be written directly to the
profile later. Tested with some LIPO profiles.

Thanks,

-Rong
2015-12-01  Rong Xu  <x...@google.com>

        * gcov-dump.c (tag_module_info): Dump string information.
        * gcov-io.c (gcov_read_module_info): record combined_len
          and don't uncompress in gcov-tool.

Index: gcov-dump.c
===================================================================
--- gcov-dump.c (revision 231134)
+++ gcov-dump.c (working copy)
@@ -588,6 +588,11 @@ tag_module_info (const char *filename ATTRIBUTE_UN
     {
       if (!mod_info->is_primary)
        printf ("%s\n", mod_info->source_filename);
+      unsigned short compressed_size = mod_info->combined_strlen;
+      unsigned short uncompressed_size = mod_info->combined_strlen>>16;
+      printf ("compressed_ strlen=%d uncompressed_strlen=%d String:\n",
+              compressed_size,uncompressed_size);
+      printf ("%s\n", mod_info->saved_cc1_strings);
     }
   else
     {
Index: gcov-io.c
===================================================================
--- gcov-io.c   (revision 231134)
+++ gcov-io.c   (working copy)
@@ -835,16 +835,18 @@ gcov_read_module_info (struct gcov_module_info *mo
   len -= (src_filename_len + 1);
 
   saved_compressed_len = (unsigned long) gcov_read_unsigned ();
-  saved_uncompressed_len  = saved_compressed_len >> 16;
-  saved_compressed_len &= 0xFFFF;
+  mod_info->combined_strlen = saved_compressed_len;
   tag_len = gcov_read_unsigned ();
   len -= (tag_len + 2);
   gcc_assert (!len);
   compressed_array = (char *) xmalloc (tag_len * sizeof (gcov_unsigned_t));
-  uncompressed_array = (char *) xmalloc (saved_uncompressed_len);
   for (i = 0; i < tag_len; i++)
     ((gcov_unsigned_t *) compressed_array)[i] = gcov_read_unsigned ();
 
+#if !defined (IN_GCOV_TOOL)
+  saved_uncompressed_len  = saved_compressed_len >> 16;
+  saved_compressed_len &= 0xFFFF;
+  uncompressed_array = (char *) xmalloc (saved_uncompressed_len);
   result_len = saved_uncompressed_len;
   uncompress ((Bytef *)uncompressed_array, &result_len,
               (const Bytef *)compressed_array, saved_compressed_len);
@@ -851,6 +853,9 @@ gcov_read_module_info (struct gcov_module_info *mo
   gcc_assert (result_len == saved_uncompressed_len);
   mod_info->saved_cc1_strings = uncompressed_array;
   free (compressed_array);
+#else /* IN_GCOV_TOOL: we don't need to uncompress. It's a pass through.  */
+  mod_info->saved_cc1_strings = compressed_array;
+#endif
 }
 #endif
 

Reply via email to