diff options
author | jistone <jistone> | 2006-05-24 19:17:13 +0000 |
---|---|---|
committer | jistone <jistone> | 2006-05-24 19:17:13 +0000 |
commit | cfe3fd5015c459688c00741de58713445cb5eba9 (patch) | |
tree | 916298838ae0a2cffc08bc1f8bcb1ec3c2de4979 /runtime/sym.c | |
parent | a477f3f17daab73993ce765900e95cddc3463586 (diff) | |
download | systemtap-steved-cfe3fd5015c459688c00741de58713445cb5eba9.tar.gz systemtap-steved-cfe3fd5015c459688c00741de58713445cb5eba9.tar.xz systemtap-steved-cfe3fd5015c459688c00741de58713445cb5eba9.zip |
2006-05-24 Josh Stone <joshua.i.stone@intel.com>
PR 2677
* sym.c (_stp_symbol_sprint_basic): New function that returns
just the symbol name, and doesn't bother with String.
* context.stp (probefunc): Use _stp_symbol_sprint_basic
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index 032d0e50..763af16d 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -1,6 +1,7 @@ /* -*- linux-c -*- * Symbolic Lookup Functions * Copyright (C) 2005 Red Hat Inc. + * Copyright (C) 2006 Intel Corporation. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -55,5 +56,36 @@ String _stp_symbol_sprint (String str, unsigned long address) #define _stp_symbol_print(address) _stp_symbol_sprint(_stp_stdout,address) + +/** Write addresses symbolically into a char buffer + * @param str Destination buffer + * @param len Length of destination buffer + * @param address The address to lookup. + * @note Symbolic lookups should not normally be done within + * a probe because it is too time-consuming. Use at module exit time. + */ + +const char *_stp_symbol_sprint_basic (char *str, size_t len, unsigned long address) +{ + char *modname; + const char *name; + unsigned long offset, size; + char namebuf[KSYM_NAME_LEN+1]; + + if (len > KSYM_NAME_LEN) { + name = _stp_kallsyms_lookup(address, &size, &offset, &modname, str); + if (!name) + snprintf(str, len, "0x%lx", address); + } else { + name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf); + if (name) + strlcpy(str, namebuf, len); + else + snprintf(str, len, "0x%lx", address); + } + + return str; +} + /** @} */ #endif /* _SYM_C_ */ |