public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [google gcc-4_9] Fix bad LIPO profile produced by gcov-tool
@ 2015-12-02  0:34 Rong Xu
       [not found] ` <CAAkRFZJTz5AWcNgwqKO6vdT_iKdpT7_hmYw6q14N+sD+3R+adg@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Rong Xu @ 2015-12-02  0:34 UTC (permalink / raw)
  To: GCC Patches; +Cc: David Li

[-- Attachment #1: Type: text/plain, Size: 280 bytes --]

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

[-- Attachment #2: gcc_patch.txt --]
[-- Type: text/plain, Size: 2363 bytes --]

2015-12-01  Rong Xu  <xur@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
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [google gcc-4_9] Fix bad LIPO profile produced by gcov-tool
       [not found] ` <CAAkRFZJTz5AWcNgwqKO6vdT_iKdpT7_hmYw6q14N+sD+3R+adg@mail.gmail.com>
@ 2015-12-02  0:53   ` Rong Xu
  2015-12-02  1:12     ` Xinliang David Li
  0 siblings, 1 reply; 3+ messages in thread
From: Rong Xu @ 2015-12-02  0:53 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: GCC Patches

This is only needed for gcov-tool as we need to rewrite the
moduel-info to the profile (this is only used in decompress)

The transitional compiler path does not need it because the string is
already decompressed. It only needs to use the strings.

gcov-dump in theory does not need it either if it only dumps the
strings. But now I added the printing of both lengths. So now it is
also needed.

On Tue, Dec 1, 2015 at 4:46 PM, Xinliang David Li <davidxl@google.com> wrote:
> Not sure about this line:
>
> mod_info->combined_strlen = saved_compressed_len;
>
> This did not exist for the compiler path before.
>
> On Tue, Dec 1, 2015 at 4:34 PM, Rong Xu <xur@google.com> wrote:
>>
>> 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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [google gcc-4_9] Fix bad LIPO profile produced by gcov-tool
  2015-12-02  0:53   ` Rong Xu
@ 2015-12-02  1:12     ` Xinliang David Li
  0 siblings, 0 replies; 3+ messages in thread
From: Xinliang David Li @ 2015-12-02  1:12 UTC (permalink / raw)
  To: Rong Xu; +Cc: GCC Patches

So that field was never inited/used before?

Also saved_compressed_len = (unsigned long) gcov_read_unsigned ();

should use unsigned not unsigned long type.

On Tue, Dec 1, 2015 at 4:53 PM, Rong Xu <xur@google.com> wrote:
> This is only needed for gcov-tool as we need to rewrite the
> moduel-info to the profile (this is only used in decompress)
>
> The transitional compiler path does not need it because the string is
> already decompressed. It only needs to use the strings.
>
> gcov-dump in theory does not need it either if it only dumps the
> strings. But now I added the printing of both lengths. So now it is
> also needed.
>
> On Tue, Dec 1, 2015 at 4:46 PM, Xinliang David Li <davidxl@google.com> wrote:
>> Not sure about this line:
>>
>> mod_info->combined_strlen = saved_compressed_len;
>>
>> This did not exist for the compiler path before.
>>
>> On Tue, Dec 1, 2015 at 4:34 PM, Rong Xu <xur@google.com> wrote:
>>>
>>> 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
>>
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-02  1:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02  0:34 [google gcc-4_9] Fix bad LIPO profile produced by gcov-tool Rong Xu
     [not found] ` <CAAkRFZJTz5AWcNgwqKO6vdT_iKdpT7_hmYw6q14N+sD+3R+adg@mail.gmail.com>
2015-12-02  0:53   ` Rong Xu
2015-12-02  1:12     ` Xinliang David Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).