From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7666 invoked by alias); 18 Apr 2011 17:49:07 -0000 Received: (qmail 7656 invoked by uid 22791); 18 Apr 2011 17:49:07 -0000 X-SWARE-Spam-Status: No, hits=-51.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Apr 2011 17:48:53 +0000 Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p3IHmpH5018693; Mon, 18 Apr 2011 10:48:52 -0700 Received: from martint2.mtv.corp.google.com (martint2.mtv.corp.google.com [172.18.116.35]) by hpaq6.eem.corp.google.com with ESMTP id p3IHmoYR004684; Mon, 18 Apr 2011 10:48:50 -0700 Received: by martint2.mtv.corp.google.com (Postfix, from userid 66176) id D2B231EE08E; Mon, 18 Apr 2011 10:48:49 -0700 (PDT) To: reply@codereview.appspotmail.com, gcc-patches@gcc.gnu.org Subject: PR 47793 - Support relative paths using -fprofile-generate (issue4434055) Message-Id: <20110418174849.D2B231EE08E@martint2.mtv.corp.google.com> Date: Mon, 18 Apr 2011 18:13:00 -0000 From: martint@google.com (Martin Thuresson) X-System-Of-Record: true Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01430.txt.bz2 This is slightly updated from my previous patch proposal. The test now correctly work if multiple tests are executed in parallell. 2011-04-17 Martin Thuresson * gcc/doc/invoke.tex: Document support for relative profile paths. * gcc/testsuite/gcc.dg/pr47793.c: New test. * gcc/libgcov.c (gcov_exit): Support relative profile paths. Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 172439) +++ gcc/doc/invoke.texi (working copy) @@ -7751,7 +7751,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 can be used. 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. Index: gcc/testsuite/gcc.dg/pr47793.c =================================================================== --- gcc/testsuite/gcc.dg/pr47793.c (revision 0) +++ gcc/testsuite/gcc.dg/pr47793.c (revision 0) @@ -0,0 +1,12 @@ +/* Bug pr47793: Allow relative paths in profile-generate. */ +/* { dg-do run } */ +/* { dg-options "-O -fprofile-generate=./" } */ +/* { dg-final { scan-file pr47793.gcda "."} } */ + +int +main(void) +{ + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ Index: gcc/libgcov.c =================================================================== --- gcc/libgcov.c (revision 172439) +++ gcc/libgcov.c (working copy) @@ -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); } -- This patch is available for review at http://codereview.appspot.com/4434055