diff options
author | Martin Liska <mliska@suse.cz> | 2017-04-18 09:24:20 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2017-04-18 07:24:20 +0000 |
commit | 6397118495f65a03a0d13114cf2c72d4a66f9cb1 (patch) | |
tree | ac43d0906533b0c67821043f6ec71cb902f5f12b /gcc | |
parent | 4c6a5d87fdff2d1fca72789eb0fb1860f463958b (diff) | |
download | gcc-6397118495f65a03a0d13114cf2c72d4a66f9cb1.zip gcc-6397118495f65a03a0d13114cf2c72d4a66f9cb1.tar.gz gcc-6397118495f65a03a0d13114cf2c72d4a66f9cb1.tar.bz2 |
Validate that destination gcov file does not exist for gcov-tool (PR gcov-profile/78783).
2017-04-18 Martin Liska <mliska@suse.cz>
PR gcov-profile/78783
* libgcov-driver.c (gcov_get_filename): New function.
2017-04-18 Martin Liska <mliska@suse.cz>
PR gcov-profile/78783
* gcov-tool.c (gcov_output_files): Validate that destination
file is either removed by the tool or by a user.
From-SVN: r246961
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gcov-tool.c | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2807eb2..f7eecc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-18 Martin Liska <mliska@suse.cz> + + PR gcov-profile/78783 + * gcov-tool.c (gcov_output_files): Validate that destination + file is either removed by the tool or by a user. + 2017-04-14 Andrew Burgess <andrew.burgess@embecosm.com> Guy Benyei <guybe@mellanox.com> diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c index cadf093..80c0835 100644 --- a/gcc/gcov-tool.c +++ b/gcc/gcov-tool.c @@ -46,6 +46,7 @@ extern int gcov_profile_normalize (struct gcov_info*, gcov_type); extern int gcov_profile_scale (struct gcov_info*, float, int, int); extern struct gcov_info* gcov_read_profile_dir (const char*, int); extern void gcov_do_dump (struct gcov_info *, int); +extern const char *gcov_get_filename (struct gcov_info *list); extern void gcov_set_verbose (void); /* Set to verbose output mode. */ @@ -114,6 +115,14 @@ gcov_output_files (const char *out, struct gcov_info *profile) if (ret) fatal_error (input_location, "Cannot change directory to %s", out); + /* Verify that output file does not exist (either was removed by + unlink_profile_data or removed by user). */ + const char *filename = gcov_get_filename (profile); + + if (access (filename, F_OK) != -1) + fatal_error (input_location, "output file %s already exists in folder %s", + filename, out); + gcov_do_dump (profile, 0); ret = chdir (pwd); |