2018-02-27 02:22:24 +03:00
/*
* Copyright ( c ) 2013 - 2018 The strace developers .
*
2018-12-10 03:00:00 +03:00
* SPDX - License - Identifier : LGPL - 2.1 - or - later
2018-02-27 02:22:24 +03:00
*/
# ifndef STRACE_MMAP_CACHE_H
2018-12-30 18:35:21 +03:00
# define STRACE_MMAP_CACHE_H
2018-02-27 02:22:24 +03:00
/*
* Keep a sorted array of cache entries ,
* so that we can binary search through it .
*/
2018-05-04 17:45:44 +03:00
2018-02-27 02:22:24 +03:00
struct mmap_cache_t {
2018-05-04 17:45:44 +03:00
struct mmap_cache_entry_t * entry ;
void ( * free_fn ) ( struct tcb * , const char * caller ) ;
unsigned int size ;
unsigned int generation ;
} ;
struct mmap_cache_entry_t {
2018-02-27 02:22:24 +03:00
/**
* example entry :
* 7f abbb09b000 - 7f abbb09f000 r - xp 0017 9000 fc : 00 1180246 / lib / libc - 2.11 .1 . so
*
* start_addr is 0x7fabbb09b000
* end_addr is 0x7fabbb09f000
* mmap_offset is 0x179000
* protections is MMAP_CACHE_PROT_READABLE | MMAP_CACHE_PROT_EXECUTABLE
* major is 0xfc
* minor is 0x00
* binary_filename is " /lib/libc-2.11.1.so "
*/
unsigned long start_addr ;
unsigned long end_addr ;
unsigned long mmap_offset ;
unsigned char protections ;
unsigned long major , minor ;
char * binary_filename ;
} ;
enum mmap_cache_protection {
MMAP_CACHE_PROT_READABLE = 1 < < 0 ,
MMAP_CACHE_PROT_WRITABLE = 1 < < 1 ,
MMAP_CACHE_PROT_EXECUTABLE = 1 < < 2 ,
MMAP_CACHE_PROT_SHARED = 1 < < 3 ,
} ;
enum mmap_cache_rebuild_result {
MMAP_CACHE_REBUILD_NOCACHE ,
MMAP_CACHE_REBUILD_READY ,
MMAP_CACHE_REBUILD_RENEWED ,
} ;
2018-07-07 10:49:10 +03:00
typedef bool ( * mmap_cache_search_fn ) ( struct mmap_cache_entry_t * , void * ) ;
2018-02-27 02:22:24 +03:00
extern void
mmap_cache_enable ( void ) ;
extern enum mmap_cache_rebuild_result
mmap_cache_rebuild_if_invalid ( struct tcb * , const char * caller ) ;
2018-05-04 17:45:44 +03:00
extern struct mmap_cache_entry_t *
2018-02-27 02:22:24 +03:00
mmap_cache_search ( struct tcb * , unsigned long ip ) ;
2018-07-07 10:49:10 +03:00
extern struct mmap_cache_entry_t *
mmap_cache_search_custom ( struct tcb * , mmap_cache_search_fn , void * ) ;
2018-02-27 02:22:24 +03:00
# endif /* !STRACE_MMAP_CACHE_H */