diff options
author | Martin Liska <mliska@suse.cz> | 2018-06-29 16:03:36 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-06-29 14:03:36 +0000 |
commit | 1f2bb38a85710f650d1ea87f0765cb50e19c3212 (patch) | |
tree | a4cb15221ae4ad1a6c3e227f6bbb07e6328aa6fc /gcc/gcov-io.c | |
parent | 52057dc4ac5295caebf83147f688d769c93cbc8d (diff) | |
download | gcc-1f2bb38a85710f650d1ea87f0765cb50e19c3212.zip gcc-1f2bb38a85710f650d1ea87f0765cb50e19c3212.tar.gz gcc-1f2bb38a85710f650d1ea87f0765cb50e19c3212.tar.bz2 |
When using -fprofile-generate=/some/path mangle absolute path of file (PR lto/85759).
2018-06-29 Martin Liska <mliska@suse.cz>
PR lto/85759
* coverage.c (coverage_init): Mangle full path name.
* doc/invoke.texi: Document the change.
* gcov-io.c (mangle_path): New.
* gcov-io.h (mangle_path): Likewise.
* gcov.c (mangle_name): Use mangle_path for path mangling.
From-SVN: r262251
Diffstat (limited to 'gcc/gcov-io.c')
-rw-r--r-- | gcc/gcov-io.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index e07ae76..311e4d0 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -566,6 +566,55 @@ gcov_read_counter (void) return value; } +/* Mangle filename path of BASE and output new allocated pointer with + mangled path. */ + +char * +mangle_path (char const *base) +{ + /* Convert '/' to '#', convert '..' to '^', + convert ':' to '~' on DOS based file system. */ + const char *probe; + char *buffer = (char *)xmalloc (strlen (base) + 10); + char *ptr = buffer; + +#if HAVE_DOS_BASED_FILE_SYSTEM + if (base[0] && base[1] == ':') + { + ptr[0] = base[0]; + ptr[1] = '~'; + ptr += 2; + base += 2; + } +#endif + for (; *base; base = probe) + { + size_t len; + + for (probe = base; *probe; probe++) + if (*probe == '/') + break; + len = probe - base; + if (len == 2 && base[0] == '.' && base[1] == '.') + *ptr++ = '^'; + else + { + memcpy (ptr, base, len); + ptr += len; + } + if (*probe) + { + *ptr++ = '#'; + probe++; + } + } + + /* Terminate the string. */ + *ptr = '\0'; + + return buffer; +} + /* We need to expose the below function when compiling for gcov-tool. */ #if !IN_LIBGCOV || defined (IN_GCOV_TOOL) |