summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-17 16:18:34 +0100
committerTim Moore <timoore@redhat.com>2009-12-17 17:37:37 +0100
commitd5a2bd44d30b45b6829eb27d70ffb6ceaa70c5bd (patch)
tree0eced4c394d1e576932c5739bc5f819f8d584a6e /runtime
parent4c5ce7a55108edb5203b3d69949f09c2284f1963 (diff)
downloadsystemtap-steved-d5a2bd44d30b45b6829eb27d70ffb6ceaa70c5bd.tar.gz
systemtap-steved-d5a2bd44d30b45b6829eb27d70ffb6ceaa70c5bd.tar.xz
systemtap-steved-d5a2bd44d30b45b6829eb27d70ffb6ceaa70c5bd.zip
support for a brief backtrace format
This only prints symbol+offset, or an address if the symbol isn't known. * runtime/runtime.h (SYM_VERBOSE_NO, SYM_VERBOSE_FULL, SYM_VERBOSE_BRIEF): new constants * runtime/stack.c (_stp_stack_print): support brief format * runtime/sym.c (_stp_func_print): ditto * tapset/ucontext-unwind.stp (print_ubacktrace_brief): new function * testsuite/systemtap.context/fib.c: new test program * testsuite/systemtap.context/fib.stp: new test * testsuite/systemtap.context/fib.exp: new test
Diffstat (limited to 'runtime')
-rw-r--r--runtime/runtime.h10
-rw-r--r--runtime/stack-i386.c2
-rw-r--r--runtime/stack-x86_64.c2
-rw-r--r--runtime/stack.c22
-rw-r--r--runtime/sym.c24
5 files changed, 46 insertions, 14 deletions
diff --git a/runtime/runtime.h b/runtime/runtime.h
index a7ee962c..0fd2a380 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -126,6 +126,16 @@ static struct
#endif
#endif
+#ifndef SYM_VERBOSE_NO
+#define SYM_VERBOSE_NO 0
+#endif
+#ifndef SYM_VERBOSE_FULL
+#define SYM_VERBOSE_FULL 1
+#endif
+#ifndef SYM_VERBOSE_BRIEF
+#define SYM_VERBOSE_BRIEF 2
+#endif
+
#include "alloc.c"
#include "print.c"
#include "string.c"
diff --git a/runtime/stack-i386.c b/runtime/stack-i386.c
index fef11871..4bd3cc53 100644
--- a/runtime/stack-i386.c
+++ b/runtime/stack-i386.c
@@ -63,6 +63,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
while (levels && (tsk || !arch_unw_user_mode(&info))) {
int ret = unwind(&info, tsk);
+#if UPROBES_API_VERSION > 1
unsigned long maybe_pc = 0;
if (ri) {
maybe_pc = uprobe_get_pc(ri, UNW_PC(&info),
@@ -72,6 +73,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
else
UNW_PC(&info) = maybe_pc;
}
+#endif
dbug_unwind(1, "ret=%d PC=%lx SP=%lx\n", ret, UNW_PC(&info), UNW_SP(&info));
if (ret == 0) {
_stp_func_print(UNW_PC(&info), verbose, 1, tsk);
diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c
index 3fc203f7..80ebd3e7 100644
--- a/runtime/stack-x86_64.c
+++ b/runtime/stack-x86_64.c
@@ -38,6 +38,7 @@ static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels,
while (levels && (tsk || !arch_unw_user_mode(&info))) {
int ret = unwind(&info, tsk);
+#if UPROBES_API_VERSION > 1
unsigned long maybe_pc = 0;
if (ri) {
maybe_pc = uprobe_get_pc(ri, UNW_PC(&info),
@@ -47,6 +48,7 @@ static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels,
else
UNW_PC(&info) = maybe_pc;
}
+#endif
dbug_unwind(1, "ret=%d PC=%lx SP=%lx\n", ret, UNW_PC(&info), UNW_SP(&info));
if (ret == 0) {
_stp_func_print(UNW_PC(&info), verbose, 1, tsk);
diff --git a/runtime/stack.c b/runtime/stack.c
index 27abee7e..3d907a7f 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -112,15 +112,20 @@ static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe
if (verbose) {
/* print the current address */
if (pi) {
- _stp_print("Returning from: ");
- _stp_symbol_print((unsigned long)_stp_probe_addr_r(pi));
- _stp_print("\nReturning to : ");
+ if (verbose == SYM_VERBOSE_FULL) {
+ _stp_print("Returning from: ");
+ _stp_symbol_print((unsigned long)_stp_probe_addr_r(pi));
+ _stp_print("\nReturning to : ");
+ }
_stp_symbol_print((unsigned long)_stp_ret_addr_r(pi));
} else if (ri) {
- _stp_print("Returning from: ");
- _stp_usymbol_print(ri->rp->u.vaddr, tsk);
- _stp_print("\nReturning to : ");
- _stp_usymbol_print(ri->ret_addr, tsk);
+ if (verbose == SYM_VERBOSE_FULL) {
+ _stp_print("Returning from: ");
+ _stp_usymbol_print(ri->rp->u.vaddr, tsk);
+ _stp_print("\nReturning to : ");
+ _stp_usymbol_print(ri->ret_addr, tsk);
+ } else
+ _stp_func_print(ri->ret_addr, verbose, 0, tsk);
} else {
_stp_print_char(' ');
if (tsk)
@@ -128,7 +133,8 @@ static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe
else
_stp_symbol_print(REG_IP(regs));
}
- _stp_print_char('\n');
+ if (verbose != SYM_VERBOSE_BRIEF)
+ _stp_print_char('\n');
} else if (pi)
_stp_printf("%p %p ", (int64_t)(long)_stp_ret_addr_r(pi), (int64_t) REG_IP(regs));
else
diff --git a/runtime/sym.c b/runtime/sym.c
index 953161bc..cd0c8a71 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -374,19 +374,31 @@ static int _stp_func_print(unsigned long address, int verbose, int exact,
else
exstr = " (inexact)";
- name = _stp_kallsyms_lookup(address, &size, &offset, &modname, NULL, task);
+ name = _stp_kallsyms_lookup(address, &size, &offset, &modname, NULL,
+ task);
if (name) {
- if (verbose) {
+ switch (verbose) {
+ case SYM_VERBOSE_FULL:
if (modname && *modname)
_stp_printf(" %p : %s+%#lx/%#lx [%s]%s\n",
- (int64_t) address, name, offset, size, modname, exstr);
+ (int64_t) address, name, offset,
+ size, modname, exstr);
else
- _stp_printf(" %p : %s+%#lx/%#lx%s\n", (int64_t) address, name, offset, size, exstr);
- } else
+ _stp_printf(" %p : %s+%#lx/%#lx%s\n",
+ (int64_t) address, name, offset, size,
+ exstr);
+ break;
+ case SYM_VERBOSE_BRIEF:
+ _stp_printf("%s+%#lx\n", name, offset);
+ break;
+ case SYM_VERBOSE_NO:
+ default:
_stp_printf("%p ", (int64_t) address);
+ }
return 1;
- }
+ } else if (verbose == SYM_VERBOSE_BRIEF)
+ _stp_printf("%p\n", (int64_t) address);
return 0;
}