diff options
author | Josh Stone <jistone@redhat.com> | 2009-09-09 15:45:28 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-09-10 13:20:24 -0700 |
commit | 9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf (patch) | |
tree | a82b5fbeae54d67d9bc047bc0591c34f34c4205e /tapsets.cxx | |
parent | eaec8e2b4cf10fc293a0cb2524692ae25a810ec9 (diff) | |
download | systemtap-steved-9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf.tar.gz systemtap-steved-9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf.tar.xz systemtap-steved-9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf.zip |
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.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r-- | tapsets.cxx | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/tapsets.cxx b/tapsets.cxx index 7912ed99..346fa7f3 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -355,7 +355,7 @@ struct dwarf_derived_probe: public derived_probe void emit_probe_local_init(translator_output * o); string args; - void saveargs(Dwarf_Die* scope_die); + void saveargs(dwarf_query& q, Dwarf_Die* scope_die); void printargs(std::ostream &o) const; // Pattern registration helpers. @@ -401,7 +401,7 @@ struct uprobe_derived_probe: public derived_probe bool return_p); string args; - void saveargs(Dwarf_Die* scope_die); + void saveargs(dwarf_query& q, Dwarf_Die* scope_die); void printargs(std::ostream &o) const; void printsig (std::ostream &o) const; @@ -2110,10 +2110,8 @@ dwarf_var_expanding_visitor::visit_target_symbol_saved_return (target_symbol* e) void dwarf_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) { - Dwarf_Die *scopes; - if (dwarf_getscopes_die (scope_die, &scopes) == 0) + if (null_die(scope_die)) return; - auto_free free_scopes(scopes); target_symbol *tsym = new target_symbol; print_format* pf = new print_format; @@ -2161,6 +2159,7 @@ dwarf_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) // non-.return probe: support $$parms, $$vars, $$locals bool first = true; Dwarf_Die result; + vector<Dwarf_Die> scopes = q.dw.getscopes_die(scope_die); if (dwarf_child (&scopes[0], &result) == 0) do { @@ -2745,7 +2744,7 @@ dwarf_derived_probe::dwarf_derived_probe(const string& funcname, // Save the local variables for listing mode if (q.sess.listing_mode_vars) - saveargs(scope_die); + saveargs(q, scope_die); // Reset the sole element of the "locations" vector as a // "reverse-engineered" form of the incoming (q.base_loc) probe @@ -2812,12 +2811,10 @@ dwarf_derived_probe::dwarf_derived_probe(const string& funcname, void -dwarf_derived_probe::saveargs(Dwarf_Die* scope_die) +dwarf_derived_probe::saveargs(dwarf_query& q, Dwarf_Die* scope_die) { - Dwarf_Die *scopes; - if (!null_die(scope_die) && dwarf_getscopes_die (scope_die, &scopes) == 0) + if (null_die(scope_die)) return; - auto_free free_scopes(scopes); stringstream argstream; string type_name; @@ -2829,6 +2826,7 @@ dwarf_derived_probe::saveargs(Dwarf_Die* scope_die) argstream << " $return:" << type_name; Dwarf_Die arg; + vector<Dwarf_Die> scopes = q.dw.getscopes_die(scope_die); if (dwarf_child (&scopes[0], &arg) == 0) do { @@ -4232,7 +4230,7 @@ uprobe_derived_probe::uprobe_derived_probe (const string& function, // Save the local variables for listing mode if (q.sess.listing_mode_vars) - saveargs(scope_die); + saveargs(q, scope_die); // Reset the sole element of the "locations" vector as a // "reverse-engineered" form of the incoming (q.base_loc) probe @@ -4308,14 +4306,12 @@ uprobe_derived_probe::uprobe_derived_probe (probe *base, void -uprobe_derived_probe::saveargs(Dwarf_Die* scope_die) +uprobe_derived_probe::saveargs(dwarf_query& q, Dwarf_Die* scope_die) { // same as dwarf_derived_probe::saveargs - Dwarf_Die *scopes; - if (!null_die(scope_die) && dwarf_getscopes_die (scope_die, &scopes) == 0) + if (null_die(scope_die)) return; - auto_free free_scopes(scopes); stringstream argstream; string type_name; @@ -4327,6 +4323,7 @@ uprobe_derived_probe::saveargs(Dwarf_Die* scope_die) argstream << " $return:" << type_name; Dwarf_Die arg; + vector<Dwarf_Die> scopes = q.dw.getscopes_die(scope_die); if (dwarf_child (&scopes[0], &arg) == 0) do { |