summaryrefslogtreecommitdiffstats
path: root/runtime/sym.c
diff options
context:
space:
mode:
authorhunt <hunt>2006-10-12 18:19:18 +0000
committerhunt <hunt>2006-10-12 18:19:18 +0000
commitfabf5ed4db3cce35725023ebc424ffe28a7dd74a (patch)
treeba5eb2e481c668c502df62fa078ebecae5e3a596 /runtime/sym.c
parent40cfa2bce2cf09160da6b767603e11a2cfac3a3e (diff)
downloadsystemtap-steved-fabf5ed4db3cce35725023ebc424ffe28a7dd74a.tar.gz
systemtap-steved-fabf5ed4db3cce35725023ebc424ffe28a7dd74a.tar.xz
systemtap-steved-fabf5ed4db3cce35725023ebc424ffe28a7dd74a.zip
2006-10-12 Martin Hunt <hunt@redhat.com>
* stack.c: Reorganize and split arch-specific functions to separate files. (_stp_kta): Better checking. (_stp_stack_sprint): Better handling of return probes. * stack-i386.c: New file. Uses 2.6.18 DWARF unwinder if available. * stack-x86_64.c: New file. Uses 2.6.18 DWARF unwinder if available. * stack-ppc64.c: New file. * stack-ia64.c: New file. * sym.c (_stp_kallsyms_lookup_name): New function. Like kallsyms_lookup_name() except use our internal lookup table.
Diffstat (limited to 'runtime/sym.c')
-rw-r--r--runtime/sym.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/runtime/sym.c b/runtime/sym.c
index 3843a3a5..c10e89fd 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -20,6 +20,25 @@
* @{
*/
+/* Lookup the kernel address for this symbol. Returns 0 if not found. */
+static unsigned long _stp_kallsyms_lookup_name(const char *name)
+{
+ struct stap_symbol *s = &stap_symbols[0];
+ unsigned num = stap_num_symbols;
+
+ /* Warning: Linear search. If this function ends up being used in */
+ /* time-critical places, maybe we need to create a new symbol table */
+ /* sorted by name. */
+
+ while (num--) {
+ if ((strcmp(name, s->symbol) == 0) && (strcmp(s->modname,"") == 0))
+ return s->addr;
+ s++;
+ }
+
+ return 0;
+}
+
static const char * _stp_kallsyms_lookup (
unsigned long addr,
unsigned long *symbolsize,
@@ -80,7 +99,7 @@ String _stp_symbol_sprint (String str, unsigned long address)
name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
- _stp_sprintf (str, "0x%lx", address);
+ _stp_sprintf (str, "%p", (void *)address);
if (name) {
if (modname)
@@ -119,13 +138,13 @@ const char *_stp_symbol_sprint_basic (char *str, size_t len, unsigned long addre
if (len > KSYM_NAME_LEN) {
name = _stp_kallsyms_lookup(address, &size, &offset, &modname, str);
if (!name)
- snprintf(str, len, "0x%lx", address);
+ snprintf(str, len, "%p", (void *)address);
} else {
name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
if (name)
strlcpy(str, namebuf, len);
else
- snprintf(str, len, "0x%lx", address);
+ snprintf(str, len, "%p", (void *)address);
}
return str;