summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-16 12:00:55 +0100
committerTim Moore <timoore@redhat.com>2009-12-16 15:03:22 +0100
commit5e562a69a5432566c6ae78344ae51b80ced7f15b (patch)
tree3c8101132cad09ef61b0ccc89d1d0be0dc324fd8 /runtime
parent39a3e39706a18dbf3698b52fc1cc7532d94078e8 (diff)
downloadsystemtap-steved-5e562a69a5432566c6ae78344ae51b80ced7f15b.tar.gz
systemtap-steved-5e562a69a5432566c6ae78344ae51b80ced7f15b.tar.xz
systemtap-steved-5e562a69a5432566c6ae78344ae51b80ced7f15b.zip
set the IP in return probes to the returned-to instruction
It's easily available in kretprobes and uretprobes and is consistent with the rest of the program state. * translate.cxx (emit_common_header) : add uretprobe_instance to context. * tapsets.cxx (common_probe_entryfn_prologue): Initialize ri in context to 0. (dwarf_derived_probe_group::emit_module_decls): Change IP to return address in kretprobes. (uprobe_derived_probe_group::emit_module_decls): enter_uretprobe_probe: set ri (uretprobe_instance) in context. Change IP to return address in uretprobes. Don't emit uprobe include and #define * runtime/runtime.h : Add includes and #define for uprobes. * runtime/stack.c (_stp_stack_print, _stp_stack_snprint): Add extra argument for uretprobe_instance. * tapset/context-unwind.stp (print_backtrace, backtrace): Pass NULL for uretprobe_instance to _stp_stack_print. * tapset/ucontext-unwind.stp (print_ubacktrace, ubacktrace): pass uretprobe_instance to _stp_stack_print * testsuite/systemtap.context/uprobe_uaddr.exp : new test for uaddr in function probes * testsuite/systemtap.context/uprobe_uaddr.stp : new file
Diffstat (limited to 'runtime')
-rw-r--r--runtime/runtime.h11
-rw-r--r--runtime/stack.c11
2 files changed, 19 insertions, 3 deletions
diff --git a/runtime/runtime.h b/runtime/runtime.h
index ba583aeb..a7ee962c 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -31,6 +31,17 @@
#include <linux/sched.h>
#include <linux/mm.h>
+/* If uprobes isn't in the kernel, pull it in from the runtime. */
+#if defined(CONFIG_UPROBES) || defined(CONFIG_UPROBES_MODULE)
+#include <linux/uprobes.h>
+#else
+#include "uprobes/uprobes.h"
+#endif
+#ifndef UPROBES_API_VERSION
+#define UPROBES_API_VERSION 1
+#endif
+
+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
#if !defined (CONFIG_DEBUG_FS) && !defined (CONFIG_DEBUG_FS_MODULE)
#error "DebugFS is required and was not found in the kernel."
diff --git a/runtime/stack.c b/runtime/stack.c
index 25dbdbbd..9c23d530 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -107,7 +107,7 @@ static void _stp_stack_print_fallback(unsigned long stack, int verbose, int leve
* @param regs A pointer to the struct pt_regs.
*/
-static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe_instance *pi, int levels, struct task_struct *tsk)
+static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe_instance *pi, int levels, struct task_struct *tsk, struct uretprobe_instance *ri)
{
if (verbose) {
/* print the current address */
@@ -116,6 +116,11 @@ static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe
_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);
} else {
_stp_print_char(' ');
if (tsk)
@@ -138,14 +143,14 @@ static void _stp_stack_print(struct pt_regs *regs, int verbose, struct kretprobe
* @param regs A pointer to the struct pt_regs.
* @returns void
*/
-static void _stp_stack_snprint(char *str, int size, struct pt_regs *regs, int verbose, struct kretprobe_instance *pi, int levels, struct task_struct *tsk)
+static void _stp_stack_snprint(char *str, int size, struct pt_regs *regs, int verbose, struct kretprobe_instance *pi, int levels, struct task_struct *tsk, struct uretprobe_instance *ri)
{
/* To get a string, we use a simple trick. First flush the print buffer, */
/* then call _stp_stack_print, then copy the result into the output string */
/* and clear the print buffer. */
_stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
_stp_print_flush();
- _stp_stack_print(regs, verbose, pi, levels, tsk);
+ _stp_stack_print(regs, verbose, pi, levels, tsk, ri);
strlcpy(str, pb->buf, size < (int)pb->len ? size : (int)pb->len);
pb->len = 0;
}