[Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Teresa Johnson
Support for embedding arbitrary build information from the profile-generate
compile into the gcda file in a new BUILD_INFO record. Lines from a file
passed to the -fprofile-generate compile via a new
-fprofile-generate-buildinfo=filename option are embedded as strings
in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
record. They are ignored on profile-use compiles, but emitted by gcov-dump.
This is useful for recording information about, for example, source revision
info that can be helpful for diagnosing profile mis-matches.

For example:

$ cat buildinfo.txt
Build timestamp 
Build source revision r12345
Other random build data

$ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

$ a.out
$ gcov-dump foo.gcda
foo.gcda:data:magic `gcda':version `408*'
foo.gcda:stamp 708902860
foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
foo.gcda:   counter histogram:
foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
foo.gcda: a700:  24:BUILD INFO num_strings=3
foo.gcda:   Build timestamp 
foo.gcda:   Build source revision r12345
foo.gcda:   Other random build data
foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
cfg_checksum=0xdb5de9e8
foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

Tested manually, passes regression tests. Ok for Google/4_8?

Thanks,
Teresa

-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
Support for embedding arbitrary build information from the profile-generate
compile into the gcda file in a new BUILD_INFO record. Lines from a file
passed to the -fprofile-generate compile via a new
-fprofile-generate-buildinfo=filename option are embedded as strings
in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
record. They are ignored on profile-use compiles, but emitted by gcov-dump.
This is useful for recording information about, for example, source revision
info that can be helpful for diagnosing profile mis-matches.

For example:

$ cat buildinfo.txt 
Build timestamp 
Build source revision r12345
Other random build data

$ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

$ a.out

$ gcov-dump foo.gcda
foo.gcda:data:magic `gcda':version `408*'
foo.gcda:stamp 708902860
foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
foo.gcda:   counter histogram:
foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
foo.gcda: a700:  24:BUILD INFO num_strings=3
foo.gcda:   Build timestamp 
foo.gcda:   Build source revision r12345
foo.gcda:   Other random build data
foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156, 
cfg_checksum=0xdb5de9e8
foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

Tested manually, passes regression tests. Ok for Google/4_8?

Thanks,
Teresa

2014-05-23  Teresa Johnson  tejohn...@google.com

Google ref b/14794433

* gcc/common.opt (flag_profile_generate_buildinfo): New flag.
* gcc/coverage.c (read_counts_file): Handle build info tag.
(build_info_type): Initialize new build_info gcov_info fields.
(build_info): Ditto.
(str_list_append): Move earlier in file.
(read_buildinfo): New function.
(coverage_obj_init): Handle flag_profile_generate_buildinfo.
* gcc/gcov.c (read_count_file): Handle build info tag.
* gcc/gcov-dump.c (tag_table): Ditto.
(tag_build_info): New function.
* gcc/gcov-io.c (gcov_compute_string_array_len): Outline from
gcov_write_module_info.
(gcov_write_string_array): Ditto.
(gcov_read_string_array): Outline from gcov_read_module_info.
(gcov_read_build_info): New function.
(gcov_read_module_info): Invoke outlined gcov_read_string_array.
* gcc/gcov-io.h (GCOV_TAG_BUILD_INFO): New tag.
(gcov_read_build_info): Declare.
(gcov_read_string_array): Ditto.
(gcov_compute_string_array_len): Ditto.
(gcov_write_string_array): Ditto.
* libgcc/dyn-ipa.c (gcov_write_module_info): Invoke outlined
gcov_compute_string_array_len and gcov_write_string_array.
* libgcc/libgcov-driver.c (gcov_exit_merge_gcda): Read build info.
(gcov_write_build_info): New function.
(gcov_exit_write_gcda): Write build info.
* libgcc/libgcov.h (struct gcov_info): Add new build info fields.

Index: gcc/common.opt
===
--- gcc/common.opt  (revision 210862)
+++ gcc/common.opt  (working copy)
@@ -1798,6 +1798,10 @@ fprofile-generate-sampling
 Common Var(flag_profile_generate_sampling)
 Turn on instrumentation sampling with -fprofile-generate with rate set by 
--param 

Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Xinliang David Li
The change makes gcov_info a variable length array, which is not ideal.

Better just add one more field (instead of two):

struct gcov_info {
   ...
  char ** build_info;
};

For regular case, it is null, for case where the build info is
available, make it point to a string array (with an null end marker
string).

David





On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson tejohn...@google.com wrote:
 Support for embedding arbitrary build information from the profile-generate
 compile into the gcda file in a new BUILD_INFO record. Lines from a file
 passed to the -fprofile-generate compile via a new
 -fprofile-generate-buildinfo=filename option are embedded as strings
 in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
 record. They are ignored on profile-use compiles, but emitted by gcov-dump.
 This is useful for recording information about, for example, source revision
 info that can be helpful for diagnosing profile mis-matches.

 For example:

 $ cat buildinfo.txt
 Build timestamp 
 Build source revision r12345
 Other random build data

 $ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

 $ a.out
 $ gcov-dump foo.gcda
 foo.gcda:data:magic `gcda':version `408*'
 foo.gcda:stamp 708902860
 foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
 foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
 foo.gcda:   counter histogram:
 foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
 foo.gcda: a700:  24:BUILD INFO num_strings=3
 foo.gcda:   Build timestamp 
 foo.gcda:   Build source revision r12345
 foo.gcda:   Other random build data
 foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
 cfg_checksum=0xdb5de9e8
 foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

 Tested manually, passes regression tests. Ok for Google/4_8?

 Thanks,
 Teresa

 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Teresa Johnson
Done. Passes manual testing, rerunning regression testing. New patch attached.

Thanks,
Teresa

On Fri, May 23, 2014 at 11:35 AM, Xinliang David Li davi...@google.com wrote:
 The change makes gcov_info a variable length array, which is not ideal.

 Better just add one more field (instead of two):

 struct gcov_info {
...
   char ** build_info;
 };

 For regular case, it is null, for case where the build info is
 available, make it point to a string array (with an null end marker
 string).

 David





 On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson tejohn...@google.com wrote:
 Support for embedding arbitrary build information from the profile-generate
 compile into the gcda file in a new BUILD_INFO record. Lines from a file
 passed to the -fprofile-generate compile via a new
 -fprofile-generate-buildinfo=filename option are embedded as strings
 in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
 record. They are ignored on profile-use compiles, but emitted by gcov-dump.
 This is useful for recording information about, for example, source revision
 info that can be helpful for diagnosing profile mis-matches.

 For example:

 $ cat buildinfo.txt
 Build timestamp 
 Build source revision r12345
 Other random build data

 $ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

 $ a.out
 $ gcov-dump foo.gcda
 foo.gcda:data:magic `gcda':version `408*'
 foo.gcda:stamp 708902860
 foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
 foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
 foo.gcda:   counter histogram:
 foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
 foo.gcda: a700:  24:BUILD INFO num_strings=3
 foo.gcda:   Build timestamp 
 foo.gcda:   Build source revision r12345
 foo.gcda:   Other random build data
 foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
 cfg_checksum=0xdb5de9e8
 foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

 Tested manually, passes regression tests. Ok for Google/4_8?

 Thanks,
 Teresa

 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
Support for embedding arbitrary build information from the profile-generate
compile into the gcda file in a new BUILD_INFO record. Lines from a file
passed to the -fprofile-generate compile via a new
-fprofile-generate-buildinfo=filename option are embedded as strings
in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
record. They are ignored on profile-use compiles, but emitted by gcov-dump.
This is useful for recording information about, for example, source revision
info that can be helpful for diagnosing profile mis-matches.

For example:

$ cat buildinfo.txt 
Build timestamp 
Build source revision r12345
Other random build data

$ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

$ a.out

$ gcov-dump foo.gcda
foo.gcda:data:magic `gcda':version `408*'
foo.gcda:stamp 708902860
foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
foo.gcda:   counter histogram:
foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
foo.gcda: a700:  24:BUILD INFO num_strings=3
foo.gcda:   Build timestamp 
foo.gcda:   Build source revision r12345
foo.gcda:   Other random build data
foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156, 
cfg_checksum=0xdb5de9e8
foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

Tested manually, passes regression tests. Ok for Google/4_8?

Thanks,
Teresa

2014-05-23  Teresa Johnson  tejohn...@google.com

Google ref b/14794433

* gcc/common.opt (flag_profile_generate_buildinfo): New flag.
* gcc/coverage.c (read_counts_file): Handle build info tag.
(build_info_type): Initialize new build_info gcov_info field.
(build_info): Ditto.
(build_gcov_build_info_value): New function.
(str_list_append): Move earlier in file.
(read_buildinfo): New function.
(coverage_obj_init): Handle flag_profile_generate_buildinfo.
* gcc/gcov.c (read_count_file): Handle build info tag.
* gcc/gcov-dump.c (tag_table): Ditto.
(tag_build_info): New function.
* gcc/gcov-io.c (gcov_compute_string_array_len): Outline from
gcov_write_module_info.
(gcov_write_string_array): Ditto.
(gcov_read_string_array): Outline from gcov_read_module_info.
(gcov_read_build_info): New function.
(gcov_read_module_info): Invoke outlined gcov_read_string_array.
* gcc/gcov-io.h (GCOV_TAG_BUILD_INFO): New tag.
(gcov_read_build_info): Declare.
(gcov_read_string_array): Ditto.
(gcov_compute_string_array_len): Ditto.

Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Xinliang David Li
  for (i = 0; i  num_strings; i++)
+{
+  if (strcmp (build_info_strings[i], gi_ptr-build_info[i]))

Add also check of gi_ptr-build_info:

   if (!gi_ptr-build_info || strcmp ( )


+{
+  gcov_error (profiling:%s:Mismatched build info string 


+  else if (tag == GCOV_TAG_BUILD_INFO)
+{

Add comment about not consumed by compiler, skipping the data ...

+  gcov_unsigned_t num_strings;
+  char **build_info_strings = gcov_read_build_info (length,
+num_strings);


@@ -2307,6 +2435,9 @@ coverage_obj_init (void)
   if (cgraph_dump_file)
 fprintf (cgraph_dump_file, Using data file %s\n, da_file_name);

+  if (flag_profile_generate_buildinfo)
+read_buildinfo ();


Why building it in init, not finalize routine as the rest of the gcov info?


David

On Fri, May 23, 2014 at 1:59 PM, Teresa Johnson tejohn...@google.com wrote:
 Done. Passes manual testing, rerunning regression testing. New patch attached.

 Thanks,
 Teresa

 On Fri, May 23, 2014 at 11:35 AM, Xinliang David Li davi...@google.com 
 wrote:
 The change makes gcov_info a variable length array, which is not ideal.

 Better just add one more field (instead of two):

 struct gcov_info {
...
   char ** build_info;
 };

 For regular case, it is null, for case where the build info is
 available, make it point to a string array (with an null end marker
 string).

 David





 On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson tejohn...@google.com 
 wrote:
 Support for embedding arbitrary build information from the profile-generate
 compile into the gcda file in a new BUILD_INFO record. Lines from a file
 passed to the -fprofile-generate compile via a new
 -fprofile-generate-buildinfo=filename option are embedded as strings
 in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
 record. They are ignored on profile-use compiles, but emitted by gcov-dump.
 This is useful for recording information about, for example, source revision
 info that can be helpful for diagnosing profile mis-matches.

 For example:

 $ cat buildinfo.txt
 Build timestamp 
 Build source revision r12345
 Other random build data

 $ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

 $ a.out
 $ gcov-dump foo.gcda
 foo.gcda:data:magic `gcda':version `408*'
 foo.gcda:stamp 708902860
 foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
 foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
 foo.gcda:   counter histogram:
 foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
 foo.gcda: a700:  24:BUILD INFO num_strings=3
 foo.gcda:   Build timestamp 
 foo.gcda:   Build source revision r12345
 foo.gcda:   Other random build data
 foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
 cfg_checksum=0xdb5de9e8
 foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

 Tested manually, passes regression tests. Ok for Google/4_8?

 Thanks,
 Teresa

 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Teresa Johnson
On Fri, May 23, 2014 at 2:28 PM, Xinliang David Li davi...@google.com wrote:
   for (i = 0; i  num_strings; i++)
 +{
 +  if (strcmp (build_info_strings[i], gi_ptr-build_info[i]))

 Add also check of gi_ptr-build_info:

if (!gi_ptr-build_info || strcmp ( )

Added the check earlier, just above this walk over strings. If we
reached here the stamps were the same so if we had see a build info
tag then we should have a non-null build_info.



 +{
 +  gcov_error (profiling:%s:Mismatched build info string 


 +  else if (tag == GCOV_TAG_BUILD_INFO)
 +{

 Add comment about not consumed by compiler, skipping the data ...

Ok.


 +  gcov_unsigned_t num_strings;
 +  char **build_info_strings = gcov_read_build_info (length,
 +num_strings);


 @@ -2307,6 +2435,9 @@ coverage_obj_init (void)
if (cgraph_dump_file)
  fprintf (cgraph_dump_file, Using data file %s\n, da_file_name);

 +  if (flag_profile_generate_buildinfo)
 +read_buildinfo ();


 Why building it in init, not finalize routine as the rest of the gcov info?

Not sure what the issue is? We are just reading in the file here.

Teresa



 David

 On Fri, May 23, 2014 at 1:59 PM, Teresa Johnson tejohn...@google.com wrote:
 Done. Passes manual testing, rerunning regression testing. New patch 
 attached.

 Thanks,
 Teresa

 On Fri, May 23, 2014 at 11:35 AM, Xinliang David Li davi...@google.com 
 wrote:
 The change makes gcov_info a variable length array, which is not ideal.

 Better just add one more field (instead of two):

 struct gcov_info {
...
   char ** build_info;
 };

 For regular case, it is null, for case where the build info is
 available, make it point to a string array (with an null end marker
 string).

 David





 On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson tejohn...@google.com 
 wrote:
 Support for embedding arbitrary build information from the profile-generate
 compile into the gcda file in a new BUILD_INFO record. Lines from a file
 passed to the -fprofile-generate compile via a new
 -fprofile-generate-buildinfo=filename option are embedded as strings
 in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
 record. They are ignored on profile-use compiles, but emitted by gcov-dump.
 This is useful for recording information about, for example, source 
 revision
 info that can be helpful for diagnosing profile mis-matches.

 For example:

 $ cat buildinfo.txt
 Build timestamp 
 Build source revision r12345
 Other random build data

 $ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

 $ a.out
 $ gcov-dump foo.gcda
 foo.gcda:data:magic `gcda':version `408*'
 foo.gcda:stamp 708902860
 foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
 foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
 foo.gcda:   counter histogram:
 foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
 foo.gcda: a700:  24:BUILD INFO num_strings=3
 foo.gcda:   Build timestamp 
 foo.gcda:   Build source revision r12345
 foo.gcda:   Other random build data
 foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
 cfg_checksum=0xdb5de9e8
 foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

 Tested manually, passes regression tests. Ok for Google/4_8?

 Thanks,
 Teresa

 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Xinliang David Li
On Fri, May 23, 2014 at 2:50 PM, Teresa Johnson tejohn...@google.com wrote:
 On Fri, May 23, 2014 at 2:28 PM, Xinliang David Li davi...@google.com wrote:
   for (i = 0; i  num_strings; i++)
 +{
 +  if (strcmp (build_info_strings[i], gi_ptr-build_info[i]))

 Add also check of gi_ptr-build_info:

if (!gi_ptr-build_info || strcmp ( )

 Added the check earlier, just above this walk over strings. If we
 reached here the stamps were the same so if we had see a build info
 tag then we should have a non-null build_info.



 +{
 +  gcov_error (profiling:%s:Mismatched build info string 


 +  else if (tag == GCOV_TAG_BUILD_INFO)
 +{

 Add comment about not consumed by compiler, skipping the data ...

 Ok.


 +  gcov_unsigned_t num_strings;
 +  char **build_info_strings = gcov_read_build_info (length,
 +num_strings);


 @@ -2307,6 +2435,9 @@ coverage_obj_init (void)
if (cgraph_dump_file)
  fprintf (cgraph_dump_file, Using data file %s\n, da_file_name);

 +  if (flag_profile_generate_buildinfo)
 +read_buildinfo ();


 Why building it in init, not finalize routine as the rest of the gcov info?

 Not sure what the issue is? We are just reading in the file here.


It is better to consolidate all the gcov info build related thing in
one place. Is it doable inside build_info () function?

David



 Teresa



 David

 On Fri, May 23, 2014 at 1:59 PM, Teresa Johnson tejohn...@google.com wrote:
 Done. Passes manual testing, rerunning regression testing. New patch 
 attached.

 Thanks,
 Teresa

 On Fri, May 23, 2014 at 11:35 AM, Xinliang David Li davi...@google.com 
 wrote:
 The change makes gcov_info a variable length array, which is not ideal.

 Better just add one more field (instead of two):

 struct gcov_info {
...
   char ** build_info;
 };

 For regular case, it is null, for case where the build info is
 available, make it point to a string array (with an null end marker
 string).

 David





 On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson tejohn...@google.com 
 wrote:
 Support for embedding arbitrary build information from the 
 profile-generate
 compile into the gcda file in a new BUILD_INFO record. Lines from a file
 passed to the -fprofile-generate compile via a new
 -fprofile-generate-buildinfo=filename option are embedded as strings
 in the gcov_info struct and emitted as-is to a new GCOV_TAG_BUILD_INFO
 record. They are ignored on profile-use compiles, but emitted by 
 gcov-dump.
 This is useful for recording information about, for example, source 
 revision
 info that can be helpful for diagnosing profile mis-matches.

 For example:

 $ cat buildinfo.txt
 Build timestamp 
 Build source revision r12345
 Other random build data

 $ g++ foo.cc -fprofile-generate -fprofile-generate-buildinfo=buildinfo.txt

 $ a.out
 $ gcov-dump foo.gcda
 foo.gcda:data:magic `gcda':version `408*'
 foo.gcda:stamp 708902860
 foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
 foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1, sum_max=1
 foo.gcda:   counter histogram:
 foo.gcda:   1: num counts=1, min counter=1, cum_counter=1
 foo.gcda: a700:  24:BUILD INFO num_strings=3
 foo.gcda:   Build timestamp 
 foo.gcda:   Build source revision r12345
 foo.gcda:   Other random build data
 foo.gcda: 0100:   3:FUNCTION ident=1, lineno_checksum=0x17c79156,
 cfg_checksum=0xdb5de9e8
 foo.gcda:  01a1:   2:COUNTERS arcs 1 counts

 Tested manually, passes regression tests. Ok for Google/4_8?

 Thanks,
 Teresa

 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413



 --
 Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [Google/4_8] Support for embedding build info into gcda files

2014-05-23 Thread Xinliang David Li
ok

On Fri, May 23, 2014 at 3:14 PM, Teresa Johnson tejohn...@google.com wrote:

 On May 23, 2014 2:56 PM, Xinliang David Li davi...@google.com wrote:

 On Fri, May 23, 2014 at 2:50 PM, Teresa Johnson tejohn...@google.com
 wrote:
  On Fri, May 23, 2014 at 2:28 PM, Xinliang David Li davi...@google.com
  wrote:
for (i = 0; i  num_strings; i++)
  +{
  +  if (strcmp (build_info_strings[i], gi_ptr-build_info[i]))
 
  Add also check of gi_ptr-build_info:
 
 if (!gi_ptr-build_info || strcmp ( )
 
  Added the check earlier, just above this walk over strings. If we
  reached here the stamps were the same so if we had see a build info
  tag then we should have a non-null build_info.
 
 
 
  +{
  +  gcov_error (profiling:%s:Mismatched build info string 
 
 
  +  else if (tag == GCOV_TAG_BUILD_INFO)
  +{
 
  Add comment about not consumed by compiler, skipping the data ...
 
  Ok.
 
 
  +  gcov_unsigned_t num_strings;
  +  char **build_info_strings = gcov_read_build_info (length,
  +
  num_strings);
 
 
  @@ -2307,6 +2435,9 @@ coverage_obj_init (void)
 if (cgraph_dump_file)
   fprintf (cgraph_dump_file, Using data file %s\n, da_file_name);
 
  +  if (flag_profile_generate_buildinfo)
  +read_buildinfo ();
 
 
  Why building it in init, not finalize routine as the rest of the gcov
  info?
 
  Not sure what the issue is? We are just reading in the file here.
 

 It is better to consolidate all the gcov info build related thing in
 one place. Is it doable inside build_info () function?

 Ok. Will move there and retest. Ok with these changes if tests pass?

 Thanks,
 Teresa



 David



  Teresa
 
 
 
  David
 
  On Fri, May 23, 2014 at 1:59 PM, Teresa Johnson tejohn...@google.com
  wrote:
  Done. Passes manual testing, rerunning regression testing. New patch
  attached.
 
  Thanks,
  Teresa
 
  On Fri, May 23, 2014 at 11:35 AM, Xinliang David Li
  davi...@google.com wrote:
  The change makes gcov_info a variable length array, which is not
  ideal.
 
  Better just add one more field (instead of two):
 
  struct gcov_info {
 ...
char ** build_info;
  };
 
  For regular case, it is null, for case where the build info is
  available, make it point to a string array (with an null end marker
  string).
 
  David
 
 
 
 
 
  On Fri, May 23, 2014 at 11:08 AM, Teresa Johnson
  tejohn...@google.com wrote:
  Support for embedding arbitrary build information from the
  profile-generate
  compile into the gcda file in a new BUILD_INFO record. Lines from a
  file
  passed to the -fprofile-generate compile via a new
  -fprofile-generate-buildinfo=filename option are embedded as strings
  in the gcov_info struct and emitted as-is to a new
  GCOV_TAG_BUILD_INFO
  record. They are ignored on profile-use compiles, but emitted by
  gcov-dump.
  This is useful for recording information about, for example, source
  revision
  info that can be helpful for diagnosing profile mis-matches.
 
  For example:
 
  $ cat buildinfo.txt
  Build timestamp 
  Build source revision r12345
  Other random build data
 
  $ g++ foo.cc -fprofile-generate
  -fprofile-generate-buildinfo=buildinfo.txt
 
  $ a.out
  $ gcov-dump foo.gcda
  foo.gcda:data:magic `gcda':version `408*'
  foo.gcda:stamp 708902860
  foo.gcda: a300:  22:PROGRAM_SUMMARY checksum=0x86a3bc55
  foo.gcda:   counts=1, runs=1, sum_all=1, run_max=1,
  sum_max=1
  foo.gcda:   counter histogram:
  foo.gcda:   1: num counts=1, min counter=1,
  cum_counter=1
  foo.gcda: a700:  24:BUILD INFO num_strings=3
  foo.gcda:   Build timestamp 
  foo.gcda:   Build source revision r12345
  foo.gcda:   Other random build data
  foo.gcda: 0100:   3:FUNCTION ident=1,
  lineno_checksum=0x17c79156,
  cfg_checksum=0xdb5de9e8
  foo.gcda:  01a1:   2:COUNTERS arcs 1 counts
 
  Tested manually, passes regression tests. Ok for Google/4_8?
 
  Thanks,
  Teresa
 
  --
  Teresa Johnson | Software Engineer | tejohn...@google.com |
  408-460-2413
 
 
 
  --
  Teresa Johnson | Software Engineer | tejohn...@google.com |
  408-460-2413
 
 
 
  --
  Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413