diff options
author | Josh Stone <jistone@redhat.com> | 2009-09-16 19:57:10 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-09-16 19:57:10 -0700 |
commit | 817c605781045a578b5464e68c39461bd541d307 (patch) | |
tree | fba2f6d9f3ecdbf3ab250902f772bc357bdae768 /dwflpp.cxx | |
parent | 6ecd877049008c5abe9c6720ea8fc64732f47eb5 (diff) | |
parent | 7d6d0afc24b43829511f3f1d0aeff0fefff56b54 (diff) | |
download | systemtap-steved-817c605781045a578b5464e68c39461bd541d307.tar.gz systemtap-steved-817c605781045a578b5464e68c39461bd541d307.tar.xz systemtap-steved-817c605781045a578b5464e68c39461bd541d307.zip |
Merge branch 'function_scopes'
Diffstat (limited to 'dwflpp.cxx')
-rw-r--r-- | dwflpp.cxx | 55 |
1 files changed, 53 insertions, 2 deletions
@@ -267,9 +267,29 @@ dwflpp::function_name_matches(const string& pattern) bool -dwflpp::function_name_final_match(const string& pattern) +dwflpp::function_scope_matches(const vector<string> scopes) { - return module_name_final_match (pattern); + // walk up the containing scopes + Dwarf_Die* die = function; + for (int i = scopes.size() - 1; i >= 0; --i) + { + die = get_parent_scope(die); + + // check if this scope matches, and prepend it if so + // NB: a NULL die is the global scope, compared as "" + string name = dwarf_diename(die) ?: ""; + if (name_has_wildcard(scopes[i]) ? + function_name_matches_pattern(name, scopes[i]) : + name == scopes[i]) + function_name = name + "::" + function_name; + else + return false; + + // make sure there's no more if we're at the global scope + if (!die && i > 0) + return false; + } + return true; } @@ -598,6 +618,9 @@ dwflpp::cache_die_parents(cu_die_parent_cache_t* parents, Dwarf_Die* die) case DW_TAG_entry_point: case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: + case DW_TAG_namespace: + case DW_TAG_class_type: + case DW_TAG_structure_type: parents->insert(make_pair(child.addr, *die)); cache_die_parents(parents, &child); break; @@ -750,6 +773,34 @@ dwflpp::getscopes(Dwarf_Addr pc) } +Dwarf_Die* +dwflpp::get_parent_scope(Dwarf_Die* die) +{ + Dwarf_Die specification; + if (dwarf_attr_die(die, DW_AT_specification, &specification)) + die = &specification; + + cu_die_parent_cache_t *parents = get_die_parents(); + cu_die_parent_cache_t::iterator it = parents->find(die->addr); + while (it != parents->end()) + { + Dwarf_Die* scope = &it->second; + switch (dwarf_tag (scope)) + { + case DW_TAG_namespace: + case DW_TAG_class_type: + case DW_TAG_structure_type: + return scope; + + default: + break; + } + it = parents->find(scope->addr); + } + return NULL; +} + + int dwflpp::global_alias_caching_callback(Dwarf_Die *die, void *arg) { |