From 544174947817538d15a105fe2de4f2094079fd6c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 25 Aug 2009 18:53:40 -0700 Subject: Compute cu_name dynamically We only need cu_name for errors and verbose messages, so it's a waste to always construct it in focus_on_cu. It's now built only as-needed. * dwflpp.cxx (dwflpp::cu_name): Now a method instead of a data member. (dwflpp::focus_on_module): No cu_name to clear now. (dwflpp::focus_on_cu): No cu_name to set now. (dwflpp::declaration_resolve): Adjust to call cu_name() now. (dwflpp::iterate_over_functions): Ditto. * tapsets.cxx (query_cu): Ditto. --- dwflpp.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'dwflpp.cxx') diff --git a/dwflpp.cxx b/dwflpp.cxx index 436ee88f..9ec7a7de 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -150,7 +150,6 @@ dwflpp::focus_on_module(Dwfl_Module * m, module_info * mi) module_dwarf = NULL; - cu_name.clear(); cu = NULL; function_name.clear(); @@ -165,7 +164,6 @@ dwflpp::focus_on_cu(Dwarf_Die * c) assert(module); cu = c; - cu_name = dwarf_diename(c) ?: "CU"; // Reset existing pointers and names function_name.clear(); @@ -176,6 +174,13 @@ dwflpp::focus_on_cu(Dwarf_Die * c) } +string +dwflpp::cu_name(void) +{ + return dwarf_diename(cu) ?: ""; +} + + void dwflpp::focus_on_function(Dwarf_Die * f) { @@ -562,7 +567,7 @@ dwflpp::declaration_resolve(const char *name) global_alias_cache[cu->addr] = v; iterate_over_globals(global_alias_caching_callback, v); if (sess.verbose > 4) - clog << "global alias cache " << module_name << ":" << cu_name + clog << "global alias cache " << module_name << ":" << cu_name() << " size " << v->size() << endl; } @@ -611,7 +616,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * cu_function_cache[cu->addr] = v; dwarf_getfuncs (cu, cu_function_caching_callback, v, 0); if (sess.verbose > 4) - clog << "function cache " << module_name << ":" << cu_name + clog << "function cache " << module_name << ":" << cu_name() << " size " << v->size() << endl; mod_info->update_symtab(v); } @@ -621,7 +626,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * { Dwarf_Die& die = it->second; if (sess.verbose > 4) - clog << "function cache " << module_name << ":" << cu_name + clog << "function cache " << module_name << ":" << cu_name() << " hit " << function << endl; return (*callback)(& die, q); } @@ -635,7 +640,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * if (function_name_matches_pattern (func_name, function)) { if (sess.verbose > 4) - clog << "function cache " << module_name << ":" << cu_name + clog << "function cache " << module_name << ":" << cu_name() << " match " << func_name << " vs " << function << endl; rc = (*callback)(& die, q); -- cgit