summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/libprofile/BasicBlockTracing.c2
-rw-r--r--runtime/libprofile/EdgeProfiling.c2
-rw-r--r--runtime/libprofile/GCDAProfiling.c44
-rw-r--r--runtime/libprofile/OptimalEdgeProfiling.c2
4 files changed, 44 insertions, 6 deletions
diff --git a/runtime/libprofile/BasicBlockTracing.c b/runtime/libprofile/BasicBlockTracing.c
index dbe81e3..0815e2e 100644
--- a/runtime/libprofile/BasicBlockTracing.c
+++ b/runtime/libprofile/BasicBlockTracing.c
@@ -30,7 +30,7 @@ static void WriteAndFlushBBTraceData () {
/* BBTraceAtExitHandler - When the program exits, just write out any remaining
* data and free the trace buffer.
*/
-static void BBTraceAtExitHandler() {
+static void BBTraceAtExitHandler(void) {
WriteAndFlushBBTraceData ();
free (ArrayStart);
}
diff --git a/runtime/libprofile/EdgeProfiling.c b/runtime/libprofile/EdgeProfiling.c
index 4a68a08..f19e188 100644
--- a/runtime/libprofile/EdgeProfiling.c
+++ b/runtime/libprofile/EdgeProfiling.c
@@ -22,7 +22,7 @@ static unsigned NumElements;
/* EdgeProfAtExitHandler - When the program exits, just write out the profiling
* data.
*/
-static void EdgeProfAtExitHandler() {
+static void EdgeProfAtExitHandler(void) {
/* Note that if this were doing something more intelligent with the
* instrumentation, we could do some computation here to expand what we
* collected into simple edge profiles. Since we directly count each edge, we
diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c
index 2dcf22d..09a1aec 100644
--- a/runtime/libprofile/GCDAProfiling.c
+++ b/runtime/libprofile/GCDAProfiling.c
@@ -24,6 +24,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#ifdef _MSC_VER
+#include <direct.h>
+#endif
/* #define DEBUG_GCDAPROFILING */
@@ -46,6 +51,17 @@ static void write_int64(uint64_t i) {
write_int32(hi);
}
+static uint32_t length_of_string(const char *s) {
+ return (strlen(s) / 4) + 1;
+}
+
+static void write_string(const char *s) {
+ uint32_t len = length_of_string(s);
+ write_int32(len);
+ fwrite(s, strlen(s), 1, output_file);
+ fwrite("\0\0\0\0", 4 - (strlen(s) % 4), 1, output_file);
+}
+
static char *mangle_filename(const char *orig_filename) {
/* TODO: handle GCOV_PREFIX_STRIP */
const char *prefix;
@@ -54,7 +70,7 @@ static char *mangle_filename(const char *orig_filename) {
prefix = getenv("GCOV_PREFIX");
if (!prefix)
- return strdup(filename);
+ return strdup(orig_filename);
filename = malloc(strlen(prefix) + 1 + strlen(orig_filename) + 1);
strcpy(filename, prefix);
@@ -64,6 +80,25 @@ 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';
+#ifdef _MSC_VER
+ _mkdir(pathname);
+#else
+ mkdir(pathname, 0750); /* some of these will fail, ignore it. */
+#endif
+ free(pathname);
+ }
+ }
+}
+
/*
* --- LLVM line counter API ---
*/
@@ -75,6 +110,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. */
@@ -111,16 +147,18 @@ void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
#endif
}
-void llvm_gcda_emit_function(uint32_t ident) {
+void llvm_gcda_emit_function(uint32_t ident, const char *function_name) {
#ifdef DEBUG_GCDAPROFILING
printf("llvmgcda: function id=%x\n", ident);
#endif
/* function tag */
fwrite("\0\0\0\1", 4, 1, output_file);
- write_int32(2);
+ write_int32(3 + 1 + length_of_string(function_name));
write_int32(ident);
write_int32(0);
+ write_int32(0);
+ write_string(function_name);
}
void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
diff --git a/runtime/libprofile/OptimalEdgeProfiling.c b/runtime/libprofile/OptimalEdgeProfiling.c
index 947da53..3a7631b 100644
--- a/runtime/libprofile/OptimalEdgeProfiling.c
+++ b/runtime/libprofile/OptimalEdgeProfiling.c
@@ -22,7 +22,7 @@ static unsigned NumElements;
/* OptEdgeProfAtExitHandler - When the program exits, just write out the
* profiling data.
*/
-static void OptEdgeProfAtExitHandler() {
+static void OptEdgeProfAtExitHandler(void) {
/* Note that, although the array has a counter for each edge, not all
* counters are updated, the ones that are not used are initialised with -1.
* When loading this information the counters with value -1 have to be
OpenPOWER on IntegriCloud