diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-04-02 18:42:38 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-04-02 18:42:38 +0200 |
commit | b2b336288ce9e92a21efe7dcd314f604bc97be29 (patch) | |
tree | b2a9b34d783aca93dfba67dbe93401102cd90eba /runtime/sym.c | |
parent | 15a78144473940a4e7c685cc57ba09a92f2293c6 (diff) | |
download | systemtap-steved-b2b336288ce9e92a21efe7dcd314f604bc97be29.tar.gz systemtap-steved-b2b336288ce9e92a21efe7dcd314f604bc97be29.tar.xz systemtap-steved-b2b336288ce9e92a21efe7dcd314f604bc97be29.zip |
PR6580: Implement symname, symdata and modname context functions.
This adds a couple of the suggested context/stack revamp functions
from PR6580. In particular it replaces the symbolname() function that
sneaked in with the pr6866 branch merge with the suggested symname().
* runtime/sym.c (_stp_mod_sec_lookup): Make section optional.
(_stp_symbol_snprint): Provide a way to get optional module info.
* tapset/context-symbols.stp: Replace symbolname() with symname(),
add modname() and symdata().
(probemod): Implement pc based fallback.
* tapset/context-unwind.stp (caller): Adjust for _stp_symbol_snprint
change.
* testsuite/systemtap.context/usymbols.exp: Use new symname.
* testsuite/buildok/modname.stp: New test.
* testsuite/buildok/symdata.stp: Likewise.
* testsuite/buildok/symname.stp: Likewise.
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index d0c5d9fd..ecd64fee 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -106,8 +106,8 @@ static unsigned long _stp_module_relocate(const char *module, const char *sectio } -/* Return module owner and fills in closest section of the address - if found, return NULL otherwise. +/* Return module owner and, if sec != NULL, 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 task_struct *task, @@ -151,7 +151,8 @@ static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr, { closest_section_offset = this_section_offset; m = _stp_modules[midx]; - *sec = & m->sections[secidx]; + if (sec) + *sec = & m->sections[secidx]; } } } @@ -338,8 +339,15 @@ static int _stp_func_print(unsigned long address, int verbose, int exact) return 0; } +/** Puts symbolic information of an address in a string. + * @param src The string to fill in. + * @param len The length of the given src string. + * @param address The address to lookup. + * @param add_mod Whether to include module name information if found. + */ + static void _stp_symbol_snprint(char *str, size_t len, unsigned long address, - struct task_struct *task) + struct task_struct *task, int add_mod) { const char *modname; const char *name; @@ -347,9 +355,13 @@ static void _stp_symbol_snprint(char *str, size_t len, unsigned long address, name = _stp_kallsyms_lookup(address, &size, &offset, &modname, NULL, task); - if (name) - strlcpy(str, name, len); - else + if (name) { + if (add_mod && modname && *modname) + _stp_printf("%s %s+%#lx/%#lx\n", + name, modname, offset, size); + else + strlcpy(str, name, len); + } else _stp_snprintf(str, len, "%p", (int64_t) address); } |