aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgcc/libgcov-driver-system.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libgcc/libgcov-driver-system.c')
-rw-r--r--gcc-4.9/libgcc/libgcov-driver-system.c91
1 files changed, 54 insertions, 37 deletions
diff --git a/gcc-4.9/libgcc/libgcov-driver-system.c b/gcc-4.9/libgcc/libgcov-driver-system.c
index 1bb740281..d0bed4975 100644
--- a/gcc-4.9/libgcc/libgcov-driver-system.c
+++ b/gcc-4.9/libgcc/libgcov-driver-system.c
@@ -134,70 +134,87 @@ allocate_filename_struct (struct gcov_filename_aux *gf)
gf->gcov_prefix_strip = gcov_prefix_strip;
}
-/* Open a gcda file specified by GI_FILENAME.
- Return -1 on error. Return 0 on success. */
-
static int
-gcov_exit_open_gcda_file (struct gcov_info *gi_ptr, struct gcov_filename_aux *gf)
+gcov_open_by_filename (char *gi_filename)
{
- int gcov_prefix_strip;
- size_t prefix_length;
- char *gi_filename_up;
- const char *fname, *s;
+ if (!gcov_open (gi_filename))
+ {
+ /* Open failed likely due to missed directory.
+ Create directory and retry to open file. */
+ if (create_file_directory (gi_filename))
+ {
+ fprintf (stderr, "profiling:%s:Skip\n", gi_filename);
+ return -1;
+ }
+ if (!gcov_open (gi_filename))
+ {
+ fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
+ return -1;
+ }
+ }
+ return 0;
+}
- gcov_prefix_strip = gf->gcov_prefix_strip;
- gi_filename_up = gf->gi_filename_up;
- prefix_length = gf->prefix_length;
- fname = gi_ptr->filename;
+#define GCOV_GET_FILENAME gcov_strip_leading_dirs
+
+/* Strip GCOV_PREFIX_STRIP levels of leading '/' from FILENAME and
+ put the result into GI_FILENAME_UP. */
+
+static void
+gcov_strip_leading_dirs (int prefix_length, int gcov_prefix_strip,
+ const char *filename, char *gi_filename_up)
+{
/* Avoid to add multiple drive letters into combined path. */
- if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
- fname += 2;
+ if (prefix_length != 0 && HAS_DRIVE_SPEC(filename))
+ filename += 2;
/* Build relocated filename, stripping off leading
directories from the initial filename if requested. */
if (gcov_prefix_strip > 0)
{
int level = 0;
-
- s = fname;
+ const char *s = filename;
if (IS_DIR_SEPARATOR(*s))
- ++s;
+ ++s;
/* Skip selected directory levels. */
for (; (*s != '\0') && (level < gcov_prefix_strip); s++)
if (IS_DIR_SEPARATOR(*s))
{
- fname = s;
+ filename = s;
level++;
}
}
/* Update complete filename with stripped original. */
- if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
+ if (prefix_length != 0 && !IS_DIR_SEPARATOR (*filename))
{
/* If prefix is given, add directory separator. */
strcpy (gi_filename_up, "/");
- strcpy (gi_filename_up + 1, fname);
+ strcpy (gi_filename_up + 1, filename);
}
else
- strcpy (gi_filename_up, fname);
+ strcpy (gi_filename_up, filename);
+}
- if (!gcov_open (gi_filename))
- {
- /* Open failed likely due to missed directory.
- Create directory and retry to open file. */
- if (create_file_directory (gi_filename))
- {
- fprintf (stderr, "profiling:%s:Skip\n", gi_filename);
- return -1;
- }
- if (!gcov_open (gi_filename))
- {
- fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
- return -1;
- }
- }
- return 0;
+/* Open a gcda file specified by GI_FILENAME.
+ Return -1 on error. Return 0 on success. */
+
+static int
+gcov_exit_open_gcda_file (struct gcov_info *gi_ptr, struct gcov_filename_aux *gf)
+{
+ int gcov_prefix_strip;
+ size_t prefix_length;
+ char *gi_filename_up;
+
+ gcov_prefix_strip = gf->gcov_prefix_strip;
+ gi_filename_up = gf->gi_filename_up;
+ prefix_length = gf->prefix_length;
+
+ GCOV_GET_FILENAME (prefix_length, gcov_prefix_strip, gi_ptr->filename,
+ gi_filename_up);
+
+ return gcov_open_by_filename (gi_filename);
}