From 19a70510d072e4a8e42c128abc91a730c7ab3a36 Mon Sep 17 00:00:00 2001
From: Christian Dietrich <christian.dietrich@informatik.uni-erlangen.de>
Date: Mon, 30 Jan 2017 13:35:07 +0100
Subject: [PATCH] plugin: record hits and misses to logfile

---
 src/clang-hash.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/clang-hash.cc b/src/clang-hash.cc
index 02791c1..4a2f82b 100644
--- a/src/clang-hash.cc
+++ b/src/clang-hash.cc
@@ -10,6 +10,8 @@
 #include <utime.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <fcntl.h>
+
 
 
 using namespace clang;
@@ -48,6 +50,15 @@ static void link_object_file() {
         dst = objectfile_copy;
     }
 
+    // Record Events
+    if (getenv("CLANG_HASH_LOGFILE")) {
+        int fd = open(getenv("CLANG_HASH_LOGFILE"),
+                      O_APPEND | O_WRONLY | O_CREAT,
+                      0644);
+        write(fd, atexit_mode == ATEXIT_FROM_CACHE ? "H" : "M", 1);
+        close(fd);
+    }
+
     /* If destination exists, we have to unlink it. */
     struct stat dummy;
     if (stat(dst, &dummy) == 0) { // exists
-- 
GitLab