diff options
author | hunt <hunt> | 2007-07-02 07:14:36 +0000 |
---|---|---|
committer | hunt <hunt> | 2007-07-02 07:14:36 +0000 |
commit | 8885da7591dad014c6815e25729d93c40624d7f1 (patch) | |
tree | e343e310fdc74572b418e425d7f83da99606b455 /runtime/sym.c | |
parent | b5f107a1a125e58385341e2da7030bd73e92a922 (diff) | |
download | systemtap-steved-8885da7591dad014c6815e25729d93c40624d7f1.tar.gz systemtap-steved-8885da7591dad014c6815e25729d93c40624d7f1.tar.xz systemtap-steved-8885da7591dad014c6815e25729d93c40624d7f1.zip |
2007-07-02 Martin Hunt <hunt@redhat.com>
* sym.c (_stp_kallsyms_lookup): Improve heuristic
for determining when a pointer is in a function.
(_stp_func_print): New function.
* stack-i386.c, stack-x86_64.c: Remove obsolete
unwind code. Use _stp_func_print().
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index d8ad3f2c..c40f48db 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -32,7 +32,7 @@ unsigned long _stp_module_relocate (const char *module, const char *section, uns return 0; } - dbug("_stp_relocate_module: %s, %s, %lx\n", module, section, offset); + dbug("%s, %s, %lx\n", module, section, offset); STP_LOCK_MODULES; if (! module @@ -47,6 +47,7 @@ unsigned long _stp_module_relocate (const char *module, const char *section, uns if (!strcmp (module, last->name) && !strcmp (section, last_sec->symbol)) { offset += last_sec->addr; STP_UNLOCK_MODULES; + dbug("offset = %lx\n", offset); return offset; } } @@ -71,6 +72,7 @@ unsigned long _stp_module_relocate (const char *module, const char *section, uns if (!strcmp (section, last_sec->symbol)) { offset += last_sec->addr; STP_UNLOCK_MODULES; + dbug("offset = %lx\n", offset); return offset; } } @@ -127,6 +129,14 @@ static const char * _stp_kallsyms_lookup ( begin = 0; end = m->num_symbols; + /* m->data is the lowest address of a data section. It should be */ + /* after the text section. */ + /* If our address is in the data section, then return now. */ + if (m->data > m->text && addr >= m->data) { + STP_UNLOCK_MODULES; + return NULL; + } + /* binary search for symbols within the module */ do { unsigned mid = (begin + end) / 2; @@ -190,6 +200,29 @@ void _stp_symbol_print (unsigned long address) } } +/* Like _stp_symbol_print, except only print if the address is a valid function address */ + +void _stp_func_print (unsigned long address, int verbose) +{ + char *modname; + const char *name; + unsigned long offset, size; + + name = _stp_kallsyms_lookup(address, &size, &offset, &modname, NULL); + + if (name) { + if (verbose) { + if (modname) + _stp_printf (" %p : %s+%#lx/%#lx [%s]\n", + (int64_t)address, name, offset, size, modname); + else + _stp_printf (" %p : %s+%#lx/%#lx\n", + (int64_t)address, name, offset, size); + } else + _stp_printf ("%p ", (int64_t)address); + } +} + void _stp_symbol_snprint (char *str, size_t len, unsigned long address) { char *modname; |