From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1158 invoked by alias); 19 Jun 2019 07:19:26 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 1148 invoked by uid 89); 19 Jun 2019 07:19:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.1 spammy=Common, H*i:sk:77b0d2c, onlinedocs, H*f:sk:77b0d2c X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Jun 2019 07:19:23 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 078BDAE54; Wed, 19 Jun 2019 07:19:21 +0000 (UTC) Subject: Re: gcc: -ftest-coverage and -auxbase To: David.Taylor@dell.com, richard.guenther@gmail.com Cc: gcc@gcc.gnu.org References: <12454.1560775576@usendtaylorx2l> <225ea1f9-aa07-84e0-2f47-28a71803daee@suse.cz> <381c2d23-5975-64c4-a13f-898624bb3c3e@suse.cz> <77b0d2c11304412488b37bcb934486f1@x13pwdurdag1004.AMER.DELL.COM> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Wed, 19 Jun 2019 07:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <77b0d2c11304412488b37bcb934486f1@x13pwdurdag1004.AMER.DELL.COM> Content-Type: multipart/mixed; boundary="------------0C3AD61307FCB33C2F16CA7F" X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00184.txt.bz2 This is a multi-part message in MIME format. --------------0C3AD61307FCB33C2F16CA7F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-length: 2354 On 6/18/19 11:51 PM, David.Taylor@dell.com wrote: >> From: Martin Liška >> Sent: Tuesday, June 18, 2019 11:20 AM >> >> .gcno files are created during compilation and contain info about a source file. >> These files will be created by a cross compiler, so that's fine. >> >> During a run of a program a .gcda file is created. It contains information about >> number of execution of edges. These files are dumped during at_exit by an >> instrumented application. And the content is stored to a disk (.gcda >> extension). >> >> So what difficulties do you have with that please? >> >> Martin > > Not sure I understand the question. > > Conceptually I don't have any problems with the compiler > creating .gcno files at compile time and the program creating > .gcda files at run-time. > > As far as the .gcda files go, exit is never called -- it's an embedded > operating system. The kernel does not call exit. Application > specific glue code will need to be written. This is to be expected. > And is completely reasonable. Yep, then call __gcov_dump at a place where you want to finish instrumentation: https://gcc.gnu.org/onlinedocs/gcc/Gcov-and-Optimization.html > > As far as the .gcno files go -- currently, while doing over 10,000 > compiles GCC wants to write all the .gcno files to the same file > name in the same NFS mounted directory. This is simultaneously > not useful and very very slow. Please take a look at attached patch, that will allow you to do: ./gcc/xgcc -Bgcc /tmp/main.c --coverage -fprofile-note-dir=/tmp/ $ ls -l /tmp/main.gcno -rw-r--r-- 1 marxin users 228 Jun 19 09:18 /tmp/main.gcno Is the suggested patch working for you? Martin > > Down the road I'm going to want to make additional changes -- > for example, putting the instrumentation data into a section > specified on the command line rather than .data. > > Right now I'm concerned about the .gcno files. I want to be > able to specify the pathname or the base of the pathname > on the command line. I don't really care whether it is called > -auxbase or something else. I was thinking '-auxbase' as that > is the name currently passed to the sub-processes. I do not > ultimately care what the name is... > > Additionally, if we do this I want it to be done in a manner > that when contributed back is likely to be accepted. > > --------------0C3AD61307FCB33C2F16CA7F Content-Type: text/x-patch; name="fprofile-note-dir.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fprofile-note-dir.patch" Content-length: 1870 diff --git a/gcc/common.opt b/gcc/common.opt index a1544d06824..d382e70317d 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2096,6 +2096,10 @@ Common Joined RejectNegative Var(profile_data_prefix) Set the top-level directory for storing the profile data. The default is 'pwd'. +fprofile-note-dir= +Common Joined RejectNegative Var(profile_note_prefix) +Set the top-level directory for storing the profile note file. + fprofile-correction Common Report Var(flag_profile_correction) Enable correction of flow inconsistent profile data input. diff --git a/gcc/coverage.c b/gcc/coverage.c index 1ffefd5f482..ea7b258d9dd 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -1204,6 +1204,12 @@ coverage_init (const char *filename) int len = strlen (filename); int prefix_len = 0; +#if HAVE_DOS_BASED_FILE_SYSTEM + const char *separator = "\\"; +#else + const char *separator = "/"; +#endif + /* Since coverage_init is invoked very early, before the pass manager, we need to set up the dumping explicitly. This is similar to the handling in finish_optimization_passes. */ @@ -1217,11 +1223,6 @@ coverage_init (const char *filename) of filename in order to prevent file path clashing. */ if (profile_data_prefix) { -#if HAVE_DOS_BASED_FILE_SYSTEM - const char *separator = "\\"; -#else - const char *separator = "/"; -#endif filename = concat (getpwd (), separator, filename, NULL); filename = mangle_path (filename); len = strlen (filename); @@ -1259,6 +1260,9 @@ coverage_init (const char *filename) memcpy (bbg_file_name, filename, len); strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX); + if (profile_note_prefix) + bbg_file_name = concat (profile_note_prefix, separator, bbg_file_name, NULL); + if (!gcov_open (bbg_file_name, -1)) { error ("cannot open %s", bbg_file_name); --------------0C3AD61307FCB33C2F16CA7F--