]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Dump hashes
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 13 Aug 2013 13:31:11 +0000 (10:31 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 20 Sep 2013 19:33:38 +0000 (14:33 -0500)
libkmod/libkmod-hash.c
libkmod/libkmod-hash.h
tools/depmod.c

index dfe596fc950e52b0f7b42be101b08786859bd5b4..58918b4a53036952f5426e7b5714c63d78f070dc 100644 (file)
@@ -330,6 +330,37 @@ int hash_add(struct hash *hash, const char *key, const void *value)
        return 0;
 }
 
+void hash_dump(struct hash *hash)
+{
+       unsigned int i _unused_;
+
+       fprintf(stderr, "#####\n");
+       fprintf(stderr, "%p %d %u\n", hash, hash->count, hash->n_buckets);
+       fprintf(stderr, "#####\n");
+       for (i = 0; i < hash->n_buckets; i++) {
+               struct hash_bucket *bucket = hash->buckets + i;
+               fprintf(stderr, "%u %d\n", i, bucket->used);
+       }
+       fprintf(stderr, "#####\n");
+       hash_dump_keys(hash);
+       fprintf(stderr, "#####\n");
+}
+
+void hash_dump_keys(struct hash *hash)
+{
+       unsigned int i;
+
+       for (i = 0; i < hash->n_buckets; i++) {
+               struct hash_bucket *bucket = hash->buckets + i;
+               struct hash_entry *entry, *entry_end;
+
+               entry = bucket->entries;
+               entry_end = entry + bucket->used;
+               for (; entry < entry_end; entry++)
+                       fprintf(stderr, "%s\n", entry->key);
+       }
+}
+
 /* similar to hash_add(), but fails if key already exists */
 int hash_add_unique(struct hash *hash, const char *key, const void *value)
 {
index ca0af05724851c21fc61aa9143dd84da3af4b050..09c536c9c5ddc75703f41fdb043f94c96be195c9 100644 (file)
@@ -20,3 +20,6 @@ unsigned int hash_get_count(const struct hash *hash);
 void hash_iter_init(const struct hash *hash, struct hash_iter *iter);
 bool hash_iter_next(struct hash_iter *iter, const char **key,
                                                        const void **value);
+
+void hash_dump(struct hash *hash);
+void hash_dump_keys(struct hash *hash);
index b1b58746be4a0dcdaf373e5d8bb4fad56f5b58b2..4b6ca5b77bc3713f0348213bd0ac02ac84970db0 100644 (file)
@@ -1032,6 +1032,10 @@ static void depmod_shutdown(struct depmod *depmod)
 {
        size_t i;
 
+       hash_dump(depmod->symbols);
+       hash_dump(depmod->modules_by_name);
+       hash_dump(depmod->modules_by_uncrelpath);
+
        hash_free(depmod->symbols);
 
        hash_free(depmod->modules_by_uncrelpath);