diff mbox

PR 47793 - Support relative paths using -fprofile-generate

Message ID AANLkTi=B8wq3uxBP3Kzk3jGw6Rn=jAjf6oAhFG_jqxj8@mail.gmail.com
State New
Headers show

Commit Message

Martin Thuresson Feb. 23, 2011, 6:21 p.m. UTC
Change 165596 and 168475 updated the code for handling gcda-paths. As
part of this change, relative paths stopped working.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793

This patch adds a guard so that "/" is not added when no prefix is
given.

The added testcase uses the path "../gcc/". This puts the gcda in the
same directory, so that the cleanup-coverage-files will find them.

I have tested the patch using "make bootstrap; make -k check" with
target x86_64-unknown-linux-gnu and saw no additional test failures.

Let me know if there is any other testing I should do.

Thanks,
Martin

Comments

Martin Thuresson Feb. 23, 2011, 11:37 p.m. UTC | #1
On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
> Change 165596 and 168475 updated the code for handling gcda-paths. As
> part of this change, relative paths stopped working.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>
> This patch adds a guard so that "/" is not added when no prefix is
> given.
>
> The added testcase uses the path "../gcc/". This puts the gcda in the
> same directory, so that the cleanup-coverage-files will find them.
>
> I have tested the patch using "make bootstrap; make -k check" with
> target x86_64-unknown-linux-gnu and saw no additional test failures.
>
> Let me know if there is any other testing I should do.

ChangeLog
gcc/

2011-02-23  Martin Thuresson  <martint@google.com>

	PR gcov-profile/47793
	* libgcov.c (gcov_exit): Support relative profile paths.

gcc/testsuite/

2011-02-23  Martin Thuresson  <martint@google.com>

	PR gcov-profile/47793
	* gcc.dg/pr47793.c: New.

>
> Thanks,
> Martin
>
Martin Thuresson March 1, 2011, 10:07 p.m. UTC | #2
Ping.

On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
> On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
>> Change 165596 and 168475 updated the code for handling gcda-paths. As
>> part of this change, relative paths stopped working.
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>>
>> This patch adds a guard so that "/" is not added when no prefix is
>> given.
>>
>> The added testcase uses the path "../gcc/". This puts the gcda in the
>> same directory, so that the cleanup-coverage-files will find them.
>>
>> I have tested the patch using "make bootstrap; make -k check" with
>> target x86_64-unknown-linux-gnu and saw no additional test failures.
>>
>> Let me know if there is any other testing I should do.
>
> ChangeLog
> gcc/
>
> 2011-02-23  Martin Thuresson  <martint@google.com>
>
>        PR gcov-profile/47793
>        * libgcov.c (gcov_exit): Support relative profile paths.
>
> gcc/testsuite/
>
> 2011-02-23  Martin Thuresson  <martint@google.com>
>
>        PR gcov-profile/47793
>        * gcc.dg/pr47793.c: New.
>
>>
>> Thanks,
>> Martin
>>
>
Diego Novillo March 7, 2011, 7:53 p.m. UTC | #3
On Tue, Mar 1, 2011 at 17:07, Martin Thuresson <martint@google.com> wrote:
> Ping.
>
> On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
>> On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
>>> Change 165596 and 168475 updated the code for handling gcda-paths. As
>>> part of this change, relative paths stopped working.
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>>>
>>> This patch adds a guard so that "/" is not added when no prefix is
>>> given.
>>>
>>> The added testcase uses the path "../gcc/". This puts the gcda in the
>>> same directory, so that the cleanup-coverage-files will find them.
>>>
>>> I have tested the patch using "make bootstrap; make -k check" with
>>> target x86_64-unknown-linux-gnu and saw no additional test failures.
>>>
>>> Let me know if there is any other testing I should do.
>>
>> ChangeLog
>> gcc/
>>
>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>
>>        PR gcov-profile/47793
>>        * libgcov.c (gcov_exit): Support relative profile paths.
>>
>> gcc/testsuite/
>>
>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>
>>        PR gcov-profile/47793
>>        * gcc.dg/pr47793.c: New.

Martin,

Let's put it in google/main while the review is underway.  Is this a
regression vs 4.5 or 4.4?  If so, it may be suitable for trunk (or the
future release branch), but you will need an explicit approval from
the release managers (CC'd).  If it's a new bug, then this should go
in trunk after we re-enter stage 1.


Diego.
Martin Thuresson March 8, 2011, 5:24 a.m. UTC | #4
On Mon, Mar 7, 2011 at 11:53 AM, Diego Novillo <dnovillo@google.com> wrote:
> On Tue, Mar 1, 2011 at 17:07, Martin Thuresson <martint@google.com> wrote:
>> Ping.
>>
>> On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
>>> On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
>>>> Change 165596 and 168475 updated the code for handling gcda-paths. As
>>>> part of this change, relative paths stopped working.
>>>>
>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>>>>
>>>> This patch adds a guard so that "/" is not added when no prefix is
>>>> given.
>>>>
>>>> The added testcase uses the path "../gcc/". This puts the gcda in the
>>>> same directory, so that the cleanup-coverage-files will find them.
>>>>
>>>> I have tested the patch using "make bootstrap; make -k check" with
>>>> target x86_64-unknown-linux-gnu and saw no additional test failures.
>>>>
>>>> Let me know if there is any other testing I should do.
>>>
>>> ChangeLog
>>> gcc/
>>>
>>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>>
>>>        PR gcov-profile/47793
>>>        * libgcov.c (gcov_exit): Support relative profile paths.
>>>
>>> gcc/testsuite/
>>>
>>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>>
>>>        PR gcov-profile/47793
>>>        * gcc.dg/pr47793.c: New.
>
> Martin,
>
> Let's put it in google/main while the review is underway.  Is this a
> regression vs 4.5 or 4.4?  If so, it may be suitable for trunk (or the
> future release branch), but you will need an explicit approval from
> the release managers (CC'd).  If it's a new bug, then this should go
> in trunk after we re-enter stage 1.

I have not tested 4.5 yet, but looking at the SVN log, I believe
this was introduced 2010/10/17.

Martin
Xinliang David Li May 4, 2011, 11:40 p.m. UTC | #5
Is this patch ok for trunk?

Allowing relative path in -fprofile-generate= is very useful when
running the program remotely -- the profile data will be just dumped
in the dir relative to the working dir in the remote machine. Using
GCOV_PREFIX_STRIP can workaround the problem, but it is not always to
pass environment around.

Thanks,

David

On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
> On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
>> Change 165596 and 168475 updated the code for handling gcda-paths. As
>> part of this change, relative paths stopped working.
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>>
>> This patch adds a guard so that "/" is not added when no prefix is
>> given.
>>
>> The added testcase uses the path "../gcc/". This puts the gcda in the
>> same directory, so that the cleanup-coverage-files will find them.
>>
>> I have tested the patch using "make bootstrap; make -k check" with
>> target x86_64-unknown-linux-gnu and saw no additional test failures.
>>
>> Let me know if there is any other testing I should do.
>
> ChangeLog
> gcc/
>
> 2011-02-23  Martin Thuresson  <martint@google.com>
>
>        PR gcov-profile/47793
>        * libgcov.c (gcov_exit): Support relative profile paths.
>
> gcc/testsuite/
>
> 2011-02-23  Martin Thuresson  <martint@google.com>
>
>        PR gcov-profile/47793
>        * gcc.dg/pr47793.c: New.
>
>>
>> Thanks,
>> Martin
>>
>
Xinliang David Li May 6, 2011, 6 p.m. UTC | #6
Honza, what do you think of the patch? It actually fixed a regression.

Thanks,

David

On Wed, May 4, 2011 at 4:40 PM, Xinliang David Li <davidxl@google.com> wrote:
> Is this patch ok for trunk?
>
> Allowing relative path in -fprofile-generate= is very useful when
> running the program remotely -- the profile data will be just dumped
> in the dir relative to the working dir in the remote machine. Using
> GCOV_PREFIX_STRIP can workaround the problem, but it is not always to
> pass environment around.
>
> Thanks,
>
> David
>
> On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
>> On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
>>> Change 165596 and 168475 updated the code for handling gcda-paths. As
>>> part of this change, relative paths stopped working.
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
>>>
>>> This patch adds a guard so that "/" is not added when no prefix is
>>> given.
>>>
>>> The added testcase uses the path "../gcc/". This puts the gcda in the
>>> same directory, so that the cleanup-coverage-files will find them.
>>>
>>> I have tested the patch using "make bootstrap; make -k check" with
>>> target x86_64-unknown-linux-gnu and saw no additional test failures.
>>>
>>> Let me know if there is any other testing I should do.
>>
>> ChangeLog
>> gcc/
>>
>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>
>>        PR gcov-profile/47793
>>        * libgcov.c (gcov_exit): Support relative profile paths.
>>
>> gcc/testsuite/
>>
>> 2011-02-23  Martin Thuresson  <martint@google.com>
>>
>>        PR gcov-profile/47793
>>        * gcc.dg/pr47793.c: New.
>>
>>>
>>> Thanks,
>>> Martin
>>>
>>
>
Jan Hubicka May 12, 2011, 10:48 p.m. UTC | #7
> Is this patch ok for trunk?
Hi,
the patch is OK.
Sorry for delayed reply, I was very busy by the inliner/thunk bits and this code
is not really in my area of expertise, so it needed some consideration to make sense
of it.

Honza
> 
> Allowing relative path in -fprofile-generate= is very useful when
> running the program remotely -- the profile data will be just dumped
> in the dir relative to the working dir in the remote machine. Using
> GCOV_PREFIX_STRIP can workaround the problem, but it is not always to
> pass environment around.
> 
> Thanks,
> 
> David
> 
> On Wed, Feb 23, 2011 at 3:37 PM, Martin Thuresson <martint@google.com> wrote:
> > On Wed, Feb 23, 2011 at 10:21 AM, Martin Thuresson <martint@google.com> wrote:
> >> Change 165596 and 168475 updated the code for handling gcda-paths. As
> >> part of this change, relative paths stopped working.
> >>
> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47793
> >>
> >> This patch adds a guard so that "/" is not added when no prefix is
> >> given.
> >>
> >> The added testcase uses the path "../gcc/". This puts the gcda in the
> >> same directory, so that the cleanup-coverage-files will find them.
> >>
> >> I have tested the patch using "make bootstrap; make -k check" with
> >> target x86_64-unknown-linux-gnu and saw no additional test failures.
> >>
> >> Let me know if there is any other testing I should do.
> >
> > ChangeLog
> > gcc/
> >
> > 2011-02-23  Martin Thuresson  <martint@google.com>
> >
> >        PR gcov-profile/47793
> >        * libgcov.c (gcov_exit): Support relative profile paths.
> >
> > gcc/testsuite/
> >
> > 2011-02-23  Martin Thuresson  <martint@google.com>
> >
> >        PR gcov-profile/47793
> >        * gcc.dg/pr47793.c: New.
> >
> >>
> >> Thanks,
> >> Martin
> >>
> >
diff mbox

Patch

diff -uprN /gcc/trunk/gcc/doc/invoke.texi gcc/doc/invoke.texi
--- /gcc/trunk/gcc/doc/invoke.texi	2011-02-09 02:01:59.000000000 -0800
+++ gcc/doc/invoke.texi	2011-02-22 09:32:41.000000000 -0800
@@ -7733,7 +7733,7 @@  Set the directory to search for the prof
 This option affects only the profile data generated by
 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
-and its related options.
+and its related options. Both absolute and relative paths are supported.
 By default, GCC will use the current directory as @var{path}, thus the
 profile data file will appear in the same directory as the object file.
 
diff -uprN /gcc/trunk/gcc/libgcov.c gcc/libgcov.c
--- /gcc/trunk/gcc/libgcov.c	2011-01-05 01:30:09.000000000 -0800
+++ gcc/libgcov.c	2011-02-23 08:51:35.000000000 -0800
@@ -283,8 +283,9 @@  gcov_exit (void)
 	      }
         }
       /* Update complete filename with stripped original. */
-      if (!IS_DIR_SEPARATOR (*fname) && !HAS_DRIVE_SPEC(fname))
+      if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
 	{
+          /* If prefix is given, add directory separator.  */
 	  strcpy (gi_filename_up, "/");
 	  strcpy (gi_filename_up + 1, fname);
 	}
diff -uprN /gcc/trunk/gcc/testsuite/gcc.dg/pr47793.c gcc/testsuite/gcc.dg/pr47793.c
--- /gcc/trunk/gcc/testsuite/gcc.dg/pr47793.c	1969-12-31 16:00:00.000000000 -0800
+++ gcc/testsuite/gcc.dg/pr47793.c	2011-02-23 08:51:54.000000000 -0800
@@ -0,0 +1,12 @@ 
+/* Bug pr47793: Allow relative paths in profile-generate.  */
+/* { dg-do run } */
+/* { dg-options "-O -fprofile-generate=../gcc/" } */
+/* { dg-final { scan-file pr47793.gcda "."} } */
+
+int
+main(void)
+{
+  return 0;
+}
+
+/* { dg-final { cleanup-coverage-files } } */