From 9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 9 Sep 2009 15:45:28 -0700 Subject: PR10594: Provide a cached dwarf_getscopes_die This avoids repeated DIE traversal by caching all parents on the first call, so future calls are just a simple walk up parent links. * dwflpp.cxx (dwflpp::getscopes_die): New cached function that mimics libdw's dwarf_getscopes_die using cached parent links. (dwflpp::cache_die_parents): New function to build the parent cache. (dwflpp::~dwflpp): Clean up the parent caches. (dwflpp::iterate_over_labels): Use the cached getscopes_die. (dwflpp::find_variable_and_frame_base): Ditto. * tapsets.cxx (dwarf_derived_probe::saveargs): Ditto. (uprobe_derived_probe::saveargs): Ditto. (dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto. --- dwflpp.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index 74a3ae00..e047fcba 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -65,6 +65,12 @@ typedef unordered_map mod_cu_function_cache_t; // inline function die -> instance die[] typedef unordered_map*> cu_inl_function_cache_t; +// die -> parent die +typedef unordered_map cu_die_parent_cache_t; + +// cu die -> (die -> parent die) +typedef unordered_map mod_cu_die_parent_cache_t; + typedef std::vector func_info_map_t; typedef std::vector inline_instance_map_t; @@ -201,6 +207,8 @@ struct dwflpp void iterate_over_inline_instances (int (* callback)(Dwarf_Die * die, void * arg), void * data); + std::vector getscopes_die(Dwarf_Die* die); + Dwarf_Die *declaration_resolve(const char *name); mod_cu_function_cache_t cu_function_cache; @@ -292,6 +300,9 @@ private: cu_inl_function_cache_t cu_inl_function_cache; void cache_inline_instances (Dwarf_Die* die); + mod_cu_die_parent_cache_t cu_die_parent_cache; + void cache_die_parents(cu_die_parent_cache_t* parents, Dwarf_Die* die); + /* The global alias cache is used to resolve any DIE found in a * module that is stubbed out with DW_AT_declaration with a defining * DIE found in a different module. The current assumption is that -- cgit