summaryrefslogtreecommitdiff
path: root/gcc/gcov-tool.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gcov-tool.c')
-rw-r--r--gcc/gcov-tool.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index f628b603a80..911d9249321 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);