Linux IA64 platform development
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: linux-ia64@vger.kernel.org
Subject: [PATCH] kprobe: make kreturn probe handler stack unwind correct
Date: Tue, 13 Nov 2007 06:55:20 +0000	[thread overview]
Message-ID: <1194936920.27851.5.camel@sli10-conroe.sh.intel.com> (raw)

Restore regs->ccr_iip before kreturn probe handler runs. In this way, if
probe handler does unwind, unwind can correctly get the stack trace.

http://sourceware.org/bugzilla/show_bug.cgi?idP51

Signed-off-by: Shaohua Li <shaohua.li@intel.com>

Index: linux/arch/ia64/kernel/kprobes.c
=================================--- linux.orig/arch/ia64/kernel/kprobes.c	2007-10-17 10:33:45.000000000 +0800
+++ linux/arch/ia64/kernel/kprobes.c	2007-11-13 14:39:50.000000000 +0800
@@ -435,6 +435,23 @@ int __kprobes trampoline_probe_handler(s
 			/* another task is sharing our hash bucket */
 			continue;
 
+		orig_ret_address = (unsigned long)ri->ret_addr;
+		if (orig_ret_address != trampoline_address)
+			/*
+			 * This is the real return address. Any other
+			 * instances associated with this task are for
+			 * other calls deeper on the call stack
+			 */
+			break;
+	}
+
+	regs->cr_iip = orig_ret_address;
+
+	hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
+		if (ri->task != current)
+			/* another task is sharing our hash bucket */
+			continue;
+
 		if (ri->rp && ri->rp->handler)
 			ri->rp->handler(ri, regs);
 
@@ -452,8 +469,6 @@ int __kprobes trampoline_probe_handler(s
 
 	kretprobe_assert(ri, orig_ret_address, trampoline_address);
 
-	regs->cr_iip = orig_ret_address;
-
 	reset_current_kprobe();
 	spin_unlock_irqrestore(&kretprobe_lock, flags);
 	preempt_enable_no_resched();

                 reply	other threads:[~2007-11-13  6:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1194936920.27851.5.camel@sli10-conroe.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox