From patchwork Wed Feb 23 18:21:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Thuresson X-Patchwork-Id: 84221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 343B6B7293 for ; Thu, 24 Feb 2011 05:21:55 +1100 (EST) Received: (qmail 17816 invoked by alias); 23 Feb 2011 18:21:53 -0000 Received: (qmail 17803 invoked by uid 22791); 23 Feb 2011 18:21:52 -0000 X-SWARE-Spam-Status: No, hits=-1.5 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) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Feb 2011 18:21:48 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id p1NILj09009655 for ; Wed, 23 Feb 2011 10:21:45 -0800 Received: from pwj3 (pwj3.prod.google.com [10.241.219.67]) by wpaz9.hot.corp.google.com with ESMTP id p1NILhe8020626 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 23 Feb 2011 10:21:44 -0800 Received: by pwj3 with SMTP id 3so73007pwj.1 for ; Wed, 23 Feb 2011 10:21:43 -0800 (PST) Received: by 10.142.195.19 with SMTP id s19mr3413065wff.253.1298485301209; Wed, 23 Feb 2011 10:21:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.200.16 with HTTP; Wed, 23 Feb 2011 10:21:21 -0800 (PST) In-Reply-To: References: From: Martin Thuresson Date: Wed, 23 Feb 2011 10:21:21 -0800 Message-ID: Subject: PR 47793 - Support relative paths using -fprofile-generate To: "kai.tietz@onevision.com" , gcc-patches X-System-Of-Record: true Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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 } } */