public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][stage1] gcov: respect -fprofile-prefix-map when it comes to output of .gcda file
@ 2023-04-03  8:54 Martin Liška
  0 siblings, 0 replies; only message in thread
From: Martin Liška @ 2023-04-03  8:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Martin Jambor, Richard Biener, Jan Hubicka

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;
  }
  
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-03  8:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03  8:54 [PATCH][stage1] gcov: respect -fprofile-prefix-map when it comes to output of .gcda file Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).