diff options
author | hunt <hunt> | 2006-09-27 18:32:03 +0000 |
---|---|---|
committer | hunt <hunt> | 2006-09-27 18:32:03 +0000 |
commit | a0ccc04fd2b9744facb48e779d6357d3b7096ee0 (patch) | |
tree | 7925af2c516beb39f9e6a5584839dfff7173037e /runtime/sym.c | |
parent | a63a95dc1994d08176b63f0a133749b531f22b80 (diff) | |
download | systemtap-steved-a0ccc04fd2b9744facb48e779d6357d3b7096ee0.tar.gz systemtap-steved-a0ccc04fd2b9744facb48e779d6357d3b7096ee0.tar.xz systemtap-steved-a0ccc04fd2b9744facb48e779d6357d3b7096ee0.zip |
2006-09-27 Martin Hunt <hunt@redhat.com>
* stack.c (_stp_kta): Rewrite. Use the _stap_symbols
struct instead of calling into the kernel.
* sym.c (_stp_kallsyms_lookup): Move here from runtime.h
* runtime.h: Get rid of all the symbol stuff that
did not belong here.
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index 763af16d..3843a3a5 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -20,6 +20,50 @@ * @{ */ +static const char * _stp_kallsyms_lookup ( + unsigned long addr, + unsigned long *symbolsize, + unsigned long *offset, + char **modname, + char *namebuf) +{ + unsigned begin = 0; + unsigned end = stap_num_symbols; + /*const*/ struct stap_symbol* s; + + /* binary search on index [begin,end) */ + do { + unsigned mid = (begin + end) / 2; + if (addr < stap_symbols[mid].addr) + end = mid; + else + begin = mid; + } while (begin + 1 < end); + /* result index in $begin, guaranteed between [0,stap_num_symbols) */ + + s = & stap_symbols [begin]; + if (addr < s->addr) + return NULL; + else { + if (offset) *offset = addr - s->addr; + if (modname) *modname = (char *) s->modname; + if (symbolsize) { + if ((begin + 1) < stap_num_symbols) + *symbolsize = stap_symbols[begin+1].addr - s->addr; + else + *symbolsize = 0; + // NB: This is only a heuristic. Sometimes there are large + // gaps between text areas of modules. + } + if (namebuf) { + strlcpy (namebuf, s->symbol, KSYM_NAME_LEN+1); + return namebuf; + } + else + return s->symbol; + } +} + /** Write addresses symbolically into a String * @param str String * @param address The address to lookup. |