Bug 36412 - gcov -l -p exceeds maximum file name length
Summary: gcov -l -p exceeds maximum file name length
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-01 12:27 UTC by Peter Klotz
Modified: 2016-08-16 14:23 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-08-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Klotz 2008-06-01 12:27:46 UTC
The options "-l -p" of gcov sometimes create names for .gcov files that exceed the maximum file name length of 255 characters under Linux.

I managed to get this file name (261 characters):

#home#build#devel#wheel#linux#gcc41#ICOSOFT#PROJECTS#Libraries#D#DataRepository#Library#jam#linux#gcc41#profile#static#NetworkRetriever.gcda###home#build#devel#wheel#linux#gcc41#ICOSOFT#EXTLIBS#BOOST1#1.35.0#include#boost#detail#sp_counted_base_gcc_x86.hpp.gcov

gcov in this case returns with the error "could not open output file".

In my case I have a file name collision that forces me to use "-l -p". However since "gcov -l -p" fails I am stuck.

I wonder why no UID or numbering scheme is used for .gcov files. The output of gcov clearly tells which source file is linked to a given .gcov file.

Example (now):

File '/usr/include/c++/4.1/bits/locale_facets.tcc'
Lines executed:0.00% of 12
/usr/include/c++/4.1/bits/locale_facets.tcc:creating 'HelloWorld.gcda##locale_facets.tcc.gcov'

The last line could be changed to something like:

/usr/include/c++/4.1/bits/locale_facets.tcc:creating 'HelloWorld.gcda##000001.gcov'

or

/usr/include/c++/4.1/bits/locale_facets.tcc:creating 'HelloWorld.gcda##c5bbbc5921be4028b2a2cf44a2c04d90.gcov'

The source file can later also be deduced from the header within the .gcov file:

        -:    0:Source:/usr/include/c++/4.1/bits/locale_facets.tcc

So nothing would be lost by removing the source information from the .gcov file name.
Comment 1 Martin Liška 2016-08-09 14:25:29 UTC
Confirmed, it's quite valid use-case, I'm having a patch for that. It's quite a lot time since the PR was created, but it may by still usefull.
Comment 2 Peter Klotz 2016-08-09 21:06:50 UTC
Hello Martin

It's great that you came up with a solution!

Meanwhile I removed "-l" from the command line to avoid the error and use an additional script to rename files as soon as they are generated by gcov. This way file name collisions leading to overwritten files are prevented.

Once your solution is present in a binary distribution I'm happy to remove all these workarounds.

Regards, Peter.
Comment 3 Martin Liška 2016-08-10 07:45:39 UTC
(In reply to Peter Klotz from comment #2)
> Hello Martin
> 
> It's great that you came up with a solution!
> 
> Meanwhile I removed "-l" from the command line to avoid the error and use an
> additional script to rename files as soon as they are generated by gcov.
> This way file name collisions leading to overwritten files are prevented.
> 
> Once your solution is present in a binary distribution I'm happy to remove
> all these workarounds.
> 
> Regards, Peter.

Hi Peter.

I'm happy that you're using GCC and that the request is still more than valid.
I expect it's going to be accepted to trunk soon:
https://gcc.gnu.org/ml/gcc-patches/2016-08/msg00721.html

What compiler version are you using, I may backport the patch if you are interested (cause GCC 7.1 is going to be released in ~May 2017)?
Comment 4 Peter Klotz 2016-08-10 17:47:48 UTC
Hi Martin

The company I work for makes heavy use of Red Hat Enterprise Linux 7.

According to this article, a GCC 6 based Red Hat Developer Toolset should be available in the not too distant future.

http://developers.redhat.com/blog/2016/02/23/upcoming-features-in-gcc-6/

So a backport to the GCC 6 release series would help.

Regards, Peter.
Comment 5 Martin Liška 2016-08-16 14:14:50 UTC
Author: marxin
Date: Tue Aug 16 14:14:18 2016
New Revision: 239503

URL: https://gcc.gnu.org/viewcvs?rev=239503&root=gcc&view=rev
Log:
gcov: add new option (--hash-filenames) (PR

	PR gcov-profile/36412
	* doc/gcov.texi: Document --hash-filenames(-x).
	* gcov.c (print_usage): Add the option.
	(process_args): Process the option, sort options alphabetically.
	(md5sum_to_hex): New function.
	(make_gcov_file_name): Do the md5sum and append it to a
	filename.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/gcov.texi
    trunk/gcc/gcov.c
Comment 6 Martin Liška 2016-08-16 14:23:45 UTC
Fixed on trunk.