diff options
author | ddomingo <ddomingo@redhat.com> | 2008-09-11 12:07:38 +1000 |
---|---|---|
committer | ddomingo <ddomingo@redhat.com> | 2008-09-11 12:07:38 +1000 |
commit | 936eeb672167eaec2e5d8e9d7cf7fe9e962efe58 (patch) | |
tree | f340b3f78479294491e76e6533c28160b3cc2ee1 /runtime/sym.c | |
parent | 6f57b072898d1858e0af448169c759dd44efddca (diff) | |
parent | 223f5b6b6e2c945c442a5dde7e63e637237f575b (diff) | |
download | systemtap-steved-936eeb672167eaec2e5d8e9d7cf7fe9e962efe58.tar.gz systemtap-steved-936eeb672167eaec2e5d8e9d7cf7fe9e962efe58.tar.xz systemtap-steved-936eeb672167eaec2e5d8e9d7cf7fe9e962efe58.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index b594d9c2..1a9e26b2 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -73,6 +73,37 @@ unsigned long _stp_module_relocate(const char *module, const char *section, unsi } +/* Return module owner and fills in closest section of the address + if found, return NULL otherwise. + XXX: needs to be address-space-specific. */ +static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr, + struct _stp_section **sec) +{ + struct _stp_module *m = NULL; + unsigned midx = 0; + unsigned long closest_section_offset = ~0; + for (midx = 0; midx < _stp_num_modules; midx++) + { + unsigned secidx; + for (secidx = 0; secidx < _stp_modules[midx]->num_sections; secidx++) + { + unsigned long this_section_addr; + unsigned long this_section_offset; + this_section_addr = _stp_modules[midx]->sections[secidx].addr; + if (addr < this_section_addr) continue; + this_section_offset = addr - this_section_addr; + if (this_section_offset < closest_section_offset) + { + closest_section_offset = this_section_offset; + m = _stp_modules[midx]; + *sec = & m->sections[secidx]; + } + } + } + return m; +} + + /* XXX: needs to be address-space-specific. */ static const char *_stp_kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, @@ -86,29 +117,7 @@ static const char *_stp_kallsyms_lookup(unsigned long addr, unsigned long *symbo unsigned long flags; unsigned end, begin = 0; - /* Find the closest section (and its owner module); fill in m & sec. */ - { - unsigned midx = 0; - unsigned long closest_section_offset = ~0; - for (midx = 0; midx < _stp_num_modules; midx++) - { - unsigned secidx; - for (secidx = 0; secidx < _stp_modules[midx]->num_sections; secidx++) - { - unsigned long this_section_addr = _stp_modules[midx]->sections[secidx].addr; - unsigned long this_section_offset; - if (addr < this_section_addr) continue; - this_section_offset = addr - this_section_addr; - if (this_section_offset < closest_section_offset) - { - closest_section_offset = this_section_offset; - m = _stp_modules[midx]; - sec = & m->sections[secidx]; - } - } - } - } - + m = _stp_mod_sec_lookup(addr, &sec); if (unlikely (m == NULL || sec == NULL)) return NULL; |