From bdcbc045037d65174b473557413a8f5062467b36 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 25 May 2012 21:55:06 +0000 Subject: [PATCH] Open in read/write mode, creating the file if it doesn't exist. llvm-svn: 157501 --- llvm/runtime/libprofile/GCDAProfiling.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/runtime/libprofile/GCDAProfiling.c b/llvm/runtime/libprofile/GCDAProfiling.c index 2c373484bb39..32d19ad7742b 100644 --- a/llvm/runtime/libprofile/GCDAProfiling.c +++ b/llvm/runtime/libprofile/GCDAProfiling.c @@ -110,14 +110,14 @@ void llvm_gcda_start_file(const char *orig_filename) { char *filename; filename = mangle_filename(orig_filename); recursive_mkdir(filename); - output_file = fopen(filename, "wb"); + output_file = fopen(filename, "w+b"); if (!output_file) { const char *cptr = strrchr(orig_filename, '/'); - output_file = fopen(cptr ? cptr + 1 : orig_filename, "wb"); + output_file = fopen(cptr ? cptr + 1 : orig_filename, "w+b"); if (!output_file) { - fprintf(stderr, "LLVM profiling runtime: while opening '%s': ", + fprintf(stderr, "LLVM profiling runtime: cannot open '%s': ", cptr ? cptr + 1 : orig_filename); perror(""); return;