diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index b77bde2..2c082d5 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -784,12 +784,13 @@ HIDDEN int dwarf_find_save_locs (struct dwarf_cursor *c) { dwarf_state_record_t sr; - dwarf_reg_state_t *rs; + dwarf_reg_state_t *rs, rs_copy; struct dwarf_rs_cache *cache; int ret = 0; intrmask_t saved_mask; + const unw_caching_policy_t caching_policy = c->as->caching_policy; - if (c->as->caching_policy == UNW_CACHE_NONE) + if (caching_policy == UNW_CACHE_NONE) return uncached_dwarf_find_save_locs (c); cache = get_rs_cache(c->as, &saved_mask); @@ -816,6 +817,12 @@ dwarf_find_save_locs (struct dwarf_cursor *c) put_unwind_info (c, &c->pi); } + if (likely (caching_policy == UNW_CACHE_GLOBAL)) + { + memcpy (&rs_copy, rs, sizeof (rs_copy)); + rs = &rs_copy; + } + put_rs_cache (c->as, cache, &saved_mask); if ((ret = apply_reg_state (c, rs)) < 0) return ret;