diff options
-rw-r--r-- | runtime/ChangeLog | 10 | ||||
-rw-r--r-- | runtime/runtime.h | 82 | ||||
-rw-r--r-- | runtime/stack.c | 8 | ||||
-rw-r--r-- | runtime/sym.c | 44 |
4 files changed, 63 insertions, 81 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 867dca3d..19606072 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,13 @@ +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. + 2006-09-26 David Smith <dsmith@redhat.com> * README: Changed 'stpd' references to 'staprun'. diff --git a/runtime/runtime.h b/runtime/runtime.h index 26153cb7..df7f9f13 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -1,5 +1,5 @@ /* main header file - * Copyright (C) 2005 Red Hat Inc. + * Copyright (C) 2005, 2006 Red Hat Inc. * Copyright (C) 2005 Intel Corporation. * * This file is part of systemtap, and is free software. You can @@ -83,89 +83,9 @@ static struct /************* Module Stuff ********************/ -static int (*_stp_kta)(unsigned long addr); -static const char * (*_stp_kallsyms_lookup)(unsigned long addr, - unsigned long *symbolsize, - unsigned long *offset, - char **modname, char *namebuf); - - -#ifdef SYSTEMTAP -/* This implementation is used if stap_[num_]symbols are available. */ -static const char * _stp_kallsyms_lookup_tabled (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; - } -} -#endif -#ifdef __ia64__ - struct fnptr func_entry, *pfunc_entry; -#endif int init_module (void) { -#if defined __i386__ || defined __x86_64__ - _stp_kta = (int (*)(unsigned long))kallsyms_lookup_name("__kernel_text_address"); -#endif - -#ifdef SYSTEMTAP - if (stap_num_symbols > 0) - _stp_kallsyms_lookup = & _stp_kallsyms_lookup_tabled; - else -#endif -#ifdef __ia64__ - { - func_entry.gp = ((struct fnptr *) kallsyms_lookup_name)->gp; - func_entry.ip = kallsyms_lookup_name("kallsyms_lookup"); - _stp_kallsyms_lookup = (const char * (*)(unsigned long,unsigned long *,unsigned long *,char **,char *))&func_entry; - - } -#else - _stp_kallsyms_lookup = (const char * (*)(unsigned long,unsigned long *,unsigned long *,char **,char *)) - kallsyms_lookup_name("kallsyms_lookup"); -#endif - return _stp_transport_init(); } diff --git a/runtime/stack.c b/runtime/stack.c index 73ac19cf..7037fa8f 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -30,6 +30,14 @@ #include "sym.c" #include "regs.h" +static int _stp_kta(unsigned long addr) +{ + if (addr >= stap_symbols[0].addr && + addr <= stap_symbols[stap_num_symbols-1].addr) + return 1; + return 0; +} + #if defined (__x86_64__) static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels) 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. |