aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-05-04 22:34:29 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-05-04 22:34:29 +0000
commit5e436b3b0ef06258ed2d7929946eb00684973183 (patch)
tree4bc2017a592a29170bac09865103d838dfdcbe90 /runtime
parentbaf717a08a0bc8cb0a7931ea3ce51d063a8fe6f0 (diff)
Create the parent directories to place the .gcda files in if they don't exist.
That's kinda weird because the .gcno files are supposed to already be there, but libgcov does this and somehow Google has managed to depend on it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130879 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/libprofile/GCDAProfiling.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c
index 13fe0fd873..dcf57ab9ed 100644
--- a/runtime/libprofile/GCDAProfiling.c
+++ b/runtime/libprofile/GCDAProfiling.c
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
/* #define DEBUG_GCDAPROFILING */
@@ -64,6 +66,21 @@ static char *mangle_filename(const char *orig_filename) {
return filename;
}
+static void recursive_mkdir(const char *filename) {
+ char *pathname;
+ int i, e;
+
+ for (i = 1, e = strlen(filename); i != e; ++i) {
+ if (filename[i] == '/') {
+ pathname = malloc(i + 1);
+ strncpy(pathname, filename, i);
+ pathname[i] = '\0';
+ mkdir(pathname, 0750); /* some of these will fail, ignore it. */
+ free(pathname);
+ }
+ }
+}
+
/*
* --- LLVM line counter API ---
*/
@@ -75,6 +92,7 @@ static char *mangle_filename(const char *orig_filename) {
void llvm_gcda_start_file(const char *orig_filename) {
char *filename;
filename = mangle_filename(orig_filename);
+ recursive_mkdir(filename);
output_file = fopen(filename, "wb");
/* gcda file, version 404*, stamp LLVM. */