dwflpp::dwflpp(systemtap_session & session, const string& user_module):
sess(session), module(NULL), module_bias(0), mod_info(NULL),
module_start(0), module_end(0), cu(NULL), dwfl(NULL),
- module_dwarf(NULL), function(NULL), blacklist_enabled(false)
+ module_dwarf(NULL), function(NULL), blacklist_enabled(false),
+ pc_cached_scopes(0), num_cached_scopes(0), cached_scopes(NULL)
{
if (user_module.empty())
setup_kernel();
dwflpp::~dwflpp()
{
+ free(cached_scopes);
if (dwfl)
dwfl_end(dwfl);
}
// Reset existing pointers and names
function_name.clear();
function = NULL;
+
+ free(cached_scopes);
+ cached_scopes = NULL;
}
assert (cu);
- nscopes = dwarf_getscopes (cu, pc, &scopes);
+ nscopes = dwarf_getscopes_cached (pc, &scopes);
int sidx;
// if pc and scope_die are disjoint then we need dwarf_getscopes_die
for (sidx = 0; sidx < nscopes; sidx++)
}
+int
+dwflpp::dwarf_getscopes_cached (Dwarf_Addr pc, Dwarf_Die **scopes)
+{
+ if (!cached_scopes || pc != pc_cached_scopes)
+ {
+ free(cached_scopes);
+ cached_scopes = NULL;
+ pc_cached_scopes = pc;
+ num_cached_scopes = dwarf_getscopes(cu, pc, &cached_scopes);
+ }
+ *scopes = cached_scopes;
+ return num_cached_scopes;
+}
+
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */