]> granicus.if.org Git - strace/commitdiff
mmap_cache: add customizable search function
authorMasatake YAMATO <yamato@redhat.com>
Sat, 7 Jul 2018 07:49:10 +0000 (16:49 +0900)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 7 Jul 2018 10:29:02 +0000 (10:29 +0000)
* mmap_cache.c (mmap_cache_search_custom): New function.
* mmap_cache.h (mmap_cache_search_fn): New type.
(mmap_cache_search_custom): New function prototype.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
mmap_cache.c
mmap_cache.h

index 631133b5cc497508e8f95855b421a455bb2fb745..181005b1731036c4fa948d5cfce76458617324ef 100644 (file)
@@ -235,3 +235,13 @@ mmap_cache_search(struct tcb *tcp, unsigned long ip)
        }
        return NULL;
 }
+
+struct mmap_cache_entry_t *
+mmap_cache_search_custom(struct tcb *tcp, mmap_cache_search_fn fn, void *data)
+{
+       for (unsigned int i = 0; i < tcp->mmap_cache->size; i++) {
+               if (fn(tcp->mmap_cache->entry + i, data))
+                       return tcp->mmap_cache->entry + i;
+       }
+       return NULL;
+}
index 90a939f37e62403da4076e39663f2d70269f0a74..e03b8876015dc33e854652ad4312cceb9db03e89 100644 (file)
@@ -73,6 +73,8 @@ enum mmap_cache_rebuild_result {
        MMAP_CACHE_REBUILD_RENEWED,
 };
 
+typedef bool (*mmap_cache_search_fn)(struct mmap_cache_entry_t *, void *);
+
 extern void
 mmap_cache_enable(void);
 
@@ -82,4 +84,7 @@ mmap_cache_rebuild_if_invalid(struct tcb *, const char *caller);
 extern struct mmap_cache_entry_t *
 mmap_cache_search(struct tcb *, unsigned long ip);
 
+extern struct mmap_cache_entry_t *
+mmap_cache_search_custom(struct tcb *, mmap_cache_search_fn, void *);
+
 #endif /* !STRACE_MMAP_CACHE_H */