]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add ccache debugging option, for included files
authorAnders F Björklund <anders.f.bjorklund@gmail.com>
Sat, 25 Aug 2018 17:26:38 +0000 (19:26 +0200)
committerAnders F Björklund <anders.f.bjorklund@gmail.com>
Sat, 25 Aug 2018 18:06:34 +0000 (20:06 +0200)
To be able to compare the preprocessor and depend modes.

src/ccache.c

index 106226fb22f9a3f69918c27c2456cc2e7647fa69..6dd11854d5d74028300b875d6ed9a2d027526e39 100644 (file)
@@ -696,6 +696,16 @@ ignore:
        free(path);
 }
 
+static void
+print_included_files(FILE *fp)
+{
+       struct hashtable_itr *iter = hashtable_iterator(included_files);
+       do {
+               char *path = hashtable_iterator_key(iter);
+               fprintf(fp, "%s\n", path);
+       } while (hashtable_iterator_advance(iter));
+}
+
 // Make a relative path from current working directory to path if path is under
 // the base directory. Takes over ownership of path. Caller frees.
 static char *
@@ -946,6 +956,11 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump)
                remember_include_file(path, hash, false, NULL);
        }
 
+       bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
+       if (debug_included) {
+               print_included_files(stdout);
+       }
+
        return true;
 }
 
@@ -1058,6 +1073,11 @@ object_hash_from_depfile(const char *depfile, struct mdfour *hash) {
                }
        }
 
+       bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
+       if (debug_included) {
+               print_included_files(stdout);
+       }
+
        struct file_hash *result = x_malloc(sizeof(*result));
        hash_result_as_bytes(hash, result->hash);
        result->size = hash->totalN;