From 38a8aecfb882072900434499696b5c32a2274515 Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Mon, 21 Jul 2014 16:47:22 -0700 Subject: [4.9] Switch gcc-4.9 to use google/gcc-4_9 branch. This source drop uses svn version r212828 of google/gcc-4.9 branch. We also cherry-picked r213062, r213063 and r213064 to fix windows build issues. All gcc-4.9 patches before July 3rd are ported to google/gcc-4.9. The following prior commits has not been merged to google branch yet. (They are included in this commit). e7af147f979e657fe2df00808e5b4319b0e088c6, baf87df3cb2683649ba7e9872362a7e721117c23, and c231900e5dcc14d8296bd9f62b45997a49d4d5e7. Change-Id: I4bea3ea470387ff751c2be4cb0d4a12059b9299b --- gcc-4.9/libgcc/libgcov-driver-system.c | 91 ++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 37 deletions(-) (limited to 'gcc-4.9/libgcc/libgcov-driver-system.c') 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); } -- cgit v1.2.3