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: 78416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2154032vqo; Mon, 3 Apr 2023 01:54:52 -0700 (PDT) X-Google-Smtp-Source: AKy350ZnSTUd+HTZWgde+yZngnpw7oKG7I3hzOID4xL281SMctG0bnr/2DiCzD+bnm6Gk58q6wzq X-Received: by 2002:a17:906:3148:b0:930:fa8e:9597 with SMTP id e8-20020a170906314800b00930fa8e9597mr34693550eje.42.1680512092327; Mon, 03 Apr 2023 01:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680512092; cv=none; d=google.com; s=arc-20160816; b=rLAbRj1+66tiR+ZlhJt30MhsTvxyFBRpJBb3xAynZK9BIha9V6kToNX07vcsENFgAM iAou0VVLeRLpglSUCNfb/e7IFkHqtSm3Y0r6pQjs+A9Za4Is0oAm2LI9RkKHvUjHFztC W9yKJPT71C0OBDGNtzN+fPDqh1+/0ZQZL4D9m8ZEr3RAJm7x8011mfRTudIu6djux4ga ZSmapIbIJ5mL9wRhRyKo+Bp+EJ1/ytcnVUybbf3emH/ajvIIfChOUv7O+w7HiOMNMTtg P6+hr9MCVut/gPU46ipagIVGmQs1mLcAtwcsXkPA/XgAZhMxXvpc55V8mh51+0QEgKlF Rm9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=Xq0Luw54PN7/pmvOZ0C31Jq3DviwirhTZmnM4wtMLrE=; b=1FTJu9qW4qbthc9oDGh14TJCGgTImGFyzKp5NNDaZQYFpuO1FJvcX8a6Gfzj6Oahiz PToEf10LR8We90ITVVPNU1eeDhFGzohCSckK9twErGvxjw/MMalGE3dqvKXJQsEAo9SL 3raX0hWj+ohED102ZRfox6+0byafirny/8sPEcy+iEv90UL4a33htxaceWx/Muybqrkv qqSMP0nFiDIQM4UNBlMA6LS2lkORZl/czjaceZOFY0EAXVxpAfKvYQriBn4HtANJu6xa U5GfxNWV77e7agXLNJnn0Y6swQSQRO3n8S7ZQ6cA/r77VjlyEmw4CI20QvVD0NdocFbY ezow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=denD7f9N; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=wKQu3+wF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v15-20020a1709061dcf00b00947b15a0450si6334762ejh.850.2023.04.03.01.54.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 01:54:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=denD7f9N; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=wKQu3+wF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7781B3858425 for ; Mon, 3 Apr 2023 08:54:48 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762144647803662355?= X-GMAIL-MSGID: =?utf-8?q?1762144647803662355?= 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; }