diff options
author | Dave Watson <davejwatson@fb.com> | 2016-12-05 15:39:37 -0800 |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2017-01-13 08:36:33 -0800 |
commit | a51cf490318eb1f2390bcd36b77794c92107ad52 (patch) | |
tree | da9ce6c4bd892482a93ab6be98bcd9066616556e /include/dwarf.h | |
parent | 29483327bebaf6e0141a9bee8bb99552a63f1583 (diff) | |
download | libunwind-a51cf490318eb1f2390bcd36b77794c92107ad52.tar.gz |
dwarf: Configurable cache size
Add interface for configurable dwarf cache size
* Use item size and round up to nearest power of 2.
* Initial cache still exists in BSS. Without this, it means we would fail
backtrace when out of memory. The test-mem test fails without this
Diffstat (limited to 'include/dwarf.h')
-rw-r--r-- | include/dwarf.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/include/dwarf.h b/include/dwarf.h index f493de85..e29b8400 100644 --- a/include/dwarf.h +++ b/include/dwarf.h @@ -325,11 +325,11 @@ typedef struct dwarf_cursor } dwarf_cursor_t; -#define DWARF_LOG_UNW_CACHE_SIZE 7 -#define DWARF_UNW_CACHE_SIZE (1 << DWARF_LOG_UNW_CACHE_SIZE) +#define DWARF_DEFAULT_LOG_UNW_CACHE_SIZE 7 +#define DWARF_DEFAULT_UNW_CACHE_SIZE (1 << DWARF_DEFAULT_LOG_UNW_CACHE_SIZE) -#define DWARF_LOG_UNW_HASH_SIZE (DWARF_LOG_UNW_CACHE_SIZE + 1) -#define DWARF_UNW_HASH_SIZE (1 << DWARF_LOG_UNW_HASH_SIZE) +#define DWARF_DEFAULT_LOG_UNW_HASH_SIZE (DWARF_DEFAULT_LOG_UNW_CACHE_SIZE + 1) +#define DWARF_DEFAULT_UNW_HASH_SIZE (1 << DWARF_DEFAULT_LOG_UNW_HASH_SIZE) typedef unsigned char unw_hash_index_t; @@ -339,13 +339,20 @@ struct dwarf_rs_cache unsigned short lru_head; /* index of lead-recently used rs */ unsigned short lru_tail; /* index of most-recently used rs */ + unsigned short log_size; + unsigned short prev_log_size; + /* hash table that maps instruction pointer to rs index: */ - unsigned short hash[DWARF_UNW_HASH_SIZE]; + unsigned short *hash; uint32_t generation; /* generation number */ /* rs cache: */ - dwarf_reg_state_t buckets[DWARF_UNW_CACHE_SIZE]; + dwarf_reg_state_t *buckets; + + /* default memory, loaded in BSS segment */ + unsigned short default_hash[DWARF_DEFAULT_UNW_HASH_SIZE]; + dwarf_reg_state_t default_buckets[DWARF_DEFAULT_UNW_CACHE_SIZE]; }; /* A list of descriptors for loaded .debug_frame sections. */ @@ -395,6 +402,7 @@ struct dwarf_callback_data #define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info) #define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer) #define dwarf_step UNW_OBJ (dwarf_step) +#define dwarf_flush_rs_cache UNW_OBJ (dwarf_flush_rs_cache) extern int dwarf_init (void); #ifndef UNW_REMOTE_ONLY @@ -443,5 +451,6 @@ extern int dwarf_read_encoded_pointer (unw_addr_space_t as, const unw_proc_info_t *pi, unw_word_t *valp, void *arg); extern int dwarf_step (struct dwarf_cursor *c); +extern int dwarf_flush_rs_cache (struct dwarf_rs_cache *cache); #endif /* dwarf_h */ |