From patchwork Mon Apr 3 08:54:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 67193 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93B0E3858409 for ; Mon, 3 Apr 2023 08:54:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9BA2A3858D39 for ; Mon, 3 Apr 2023 08:54:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BA2A3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C8AB11F8D9; Mon, 3 Apr 2023 08:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1680512063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xq0Luw54PN7/pmvOZ0C31Jq3DviwirhTZmnM4wtMLrE=; b=denD7f9NYpbjotsgfV0fmExgUNo/zq7dT4lHj/DZuyH6/9AbRHffzJtKv71MvzegS6m+f5 PT2N7QoUGWLKtWNotdiUYyYRUrDcgQ+3KGvfklgrKTNJ50W3p69ypE6V/CjWzMoNPYSzpQ 9l0zOUtX+zCE6pd5TNt0zD1Q4px2MAc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1680512063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xq0Luw54PN7/pmvOZ0C31Jq3DviwirhTZmnM4wtMLrE=; b=wKQu3+wFZv2fIbx9m1UaqHRvnQgUD28qTQheslRn0EoSjuQL/GX9OnwQgrF6w9FQrce/AO 3Zxg8IlHMHPAsHCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B307413416; Mon, 3 Apr 2023 08:54:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lfTRKj+UKmT/UAAAMHmgww (envelope-from ); Mon, 03 Apr 2023 08:54:23 +0000 Message-ID: <7e35e83c-996e-047d-5dce-6c5f6b6ce452@suse.cz> Date: Mon, 3 Apr 2023 10:54:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH][stage1] gcov: respect -fprofile-prefix-map when it comes to output of .gcda file To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Martin Jambor , Richard Biener , Jan Hubicka X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Respect the profile prefix map and save .gcda files to a path that is also translated with -fprofile-prefix-map option (if provided). It's a stage 1 material, if you are interested in the fix, please install it, I won't be able to take care of it at that time. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Thanks, Martin PR gcov-profile/105063 gcc/ChangeLog: * coverage.cc (coverage_init): Combine strings with concat and respect profile path mapping. --- gcc/coverage.cc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/gcc/coverage.cc b/gcc/coverage.cc index 7ed3a5d4ceb..3fd7f6e8e76 100644 --- a/gcc/coverage.cc +++ b/gcc/coverage.cc @@ -112,7 +112,7 @@ static char *bbg_file_name; static unsigned bbg_file_stamp; /* Name of the count data (gcda) file. */ -static char *da_file_name; +static const char *da_file_name; /* The names of merge functions for counters. */ #define STR(str) #str @@ -1259,8 +1259,6 @@ coverage_init (const char *filename) #else const char *separator = "/"; #endif - int len = strlen (filename); - int prefix_len = 0; /* Since coverage_init is invoked very early, before the pass manager, we need to set up the dumping explicitly. This is @@ -1289,26 +1287,19 @@ coverage_init (const char *filename) "prefix %qs", filename, profile_prefix_path); } filename = mangle_path (filename); - len = strlen (filename); } else profile_data_prefix = getpwd (); } - if (profile_data_prefix) - prefix_len = strlen (profile_data_prefix); - /* Name of da file. */ - da_file_name = XNEWVEC (char, len + strlen (GCOV_DATA_SUFFIX) - + prefix_len + 2); - if (profile_data_prefix) - { - memcpy (da_file_name, profile_data_prefix, prefix_len); - da_file_name[prefix_len++] = *separator; - } - memcpy (da_file_name + prefix_len, filename, len); - strcpy (da_file_name + prefix_len + len, GCOV_DATA_SUFFIX); + da_file_name = concat (profile_data_prefix, separator, filename, + GCOV_DATA_SUFFIX, NULL); + else + da_file_name = concat (filename, GCOV_DATA_SUFFIX, NULL); + + da_file_name = remap_profile_filename (da_file_name); bbg_file_stamp = local_tick; if (flag_auto_profile) @@ -1385,7 +1376,6 @@ coverage_finish (void) coverage_obj_finish (fn_ctor, object_checksum); } - XDELETEVEC (da_file_name); da_file_name = NULL; }