@@ -951,11 +951,16 @@ in the object file. Prefix can be absolute, or relative. The
default is no prefix.
@item
-GCOV_PREFIX_STRIP indicates the how many initial directory names to strip off
-the hardwired absolute paths. Default value is 0.
+GCOV_PREFIX_STRIP_COMPONENTS indicates the how many initial directory names
+to strip off the hardwired absolute paths. Default value is 0.
-@emph{Note:} If GCOV_PREFIX_STRIP is set without GCOV_PREFIX is undefined,
- then a relative path is made out of the hardwired absolute paths.
+@item
+GCOV_PREFIX_STRIP indicates path prefix to strip off
+the hardwired absolute paths.
+
+@emph{Note:} If GCOV_PREFIX_STRIP_COMPONENTS (or GCOV_PREFIX_STRIP)
+is set without GCOV_PREFIX, then a relative path is made
+out of the hardwired absolute paths.
@end itemize
For example, if the object file @file{/user/build/foo.o} was built with
@@ -963,8 +968,8 @@ For example, if the object file @file{/user/build/foo.o} was built with
@file{/user/build/foo.gcda} when running on the target system. This will
fail if the corresponding directory does not exist and it is unable to create
it. This can be overcome by, for example, setting the environment as
-@samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP=1}. Such a
-setting will name the data file @file{/target/run/build/foo.gcda}.
+@samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP_COMPONENTS=1}.
+Such a setting will name the data file @file{/target/run/build/foo.gcda}.
You must move the data files to the expected directory tree in order to
use them for profile directed optimizations (@option{-fprofile-use}), or to
@@ -218,7 +218,7 @@ allocate_filename_struct (struct gcov_filename *gf)
{
/* Check if the level of dirs to strip off specified. */
- char *tmp = getenv("GCOV_PREFIX_STRIP");
+ char *tmp = getenv ("GCOV_PREFIX_STRIP_COMPONENTS");
if (tmp)
{
strip = atoi (tmp);
@@ -228,6 +228,7 @@ allocate_filename_struct (struct gcov_filename *gf)
}
}
gf->strip = strip;
+ gf->strip_prefix = getenv ("GCOV_PREFIX_STRIP");
/* Get file name relocation prefix. Non-absolute values are ignored. */
gcov_prefix = getenv("GCOV_PREFIX");
@@ -239,7 +240,7 @@ allocate_filename_struct (struct gcov_filename *gf)
/* If no prefix was specified and a prefix stip, then we assume
relative. */
- if (!prefix_length && gf->strip)
+ if (!prefix_length && (gf->strip || gf->strip_prefix))
{
gcov_prefix = ".";
prefix_length = 1;
@@ -286,6 +287,8 @@ gcov_exit_open_gcda_file (struct gcov_info *gi_ptr,
level--;
}
}
+ else if (gf->strip_prefix && strstr (fname, gf->strip_prefix) == fname)
+ fname += strlen (gf->strip_prefix);
/* Update complete filename with stripped original. */
if (gf->prefix)
@@ -76,6 +76,7 @@ struct gcov_filename
{
char *filename; /* filename buffer */
int strip; /* leading chars to strip from filename */
+ char *strip_prefix; /* leading path prefix that should be stripped */
char *prefix; /* prefix string */
};