summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-03-27 21:17:04 +0000
committerBill Wendling <isanbard@gmail.com>2012-03-27 21:17:04 +0000
commit66e30f8db180bdc0fba637c84e7b72396a08d8f2 (patch)
treec888523dd1eede94b63df800b87b4006a89d7b65 /runtime
parentced8af11071b026bd3e03a962e467755077e1c5a (diff)
downloadllvm-66e30f8db180bdc0fba637c84e7b72396a08d8f2.tar.gz
llvm-66e30f8db180bdc0fba637c84e7b72396a08d8f2.tar.bz2
llvm-66e30f8db180bdc0fba637c84e7b72396a08d8f2.tar.xz
Try to use the CWD if the path to the GCDA output is not available (e.g., the
executable has been moved to another machine). If that's not available (read-only or something), then exit gracefully. <rdar://problem/11111686> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/libprofile/GCDAProfiling.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c
index 4ffb12b15e..712dba08be 100644
--- a/runtime/libprofile/GCDAProfiling.c
+++ b/runtime/libprofile/GCDAProfiling.c
@@ -113,6 +113,20 @@ void llvm_gcda_start_file(const char *orig_filename) {
recursive_mkdir(filename);
output_file = fopen(filename, "wb");
+ if (!output_file) {
+ filename[0] = '\0'; /* The size of filename should be big enough. */
+ char *cptr = strrchr(orig_filename, '/');
+ strcat(filename, cptr ? cptr + 1 : orig_filename);
+ output_file = fopen(filename, "wb");
+
+ if (!output_file) {
+ fprintf(stderr, "LLVM profiling runtime: while opening '%s': ",
+ filename);
+ perror("");
+ exit(1);
+ }
+ }
+
/* gcda file, version 404*, stamp LLVM. */
#ifdef __APPLE__
fwrite("adcg*204MVLL", 12, 1, output_file);