diff options
author | Mark Wielaard <mwielaard@redhat.com> | 2008-09-09 21:11:21 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2008-09-10 13:58:06 +0200 |
commit | 09fa543f68b023479fb3705fe2544ec257368201 (patch) | |
tree | 3c715da7dfc9741c0bc256e555f1812f3057a6a0 /runtime/sym.c | |
parent | 63265337e2b74c4a34fb9b4d67d0a695c88e7d5e (diff) | |
download | systemtap-steved-09fa543f68b023479fb3705fe2544ec257368201.tar.gz systemtap-steved-09fa543f68b023479fb3705fe2544ec257368201.tar.xz systemtap-steved-09fa543f68b023479fb3705fe2544ec257368201.zip |
Add new function _stp_mod_sec_lookup extracted from _stp_kallsyms_lookup.
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; |