linux-mips
[Top] [All Lists]

[PATCH 1/2] MIPS: Add new unwind_stack variant

To: linux-mips@linux-mips.org
Subject: [PATCH 1/2] MIPS: Add new unwind_stack variant
From: Gergely Kis <gergely@homejinni.com>
Date: Fri, 13 May 2011 12:38:04 +0000
Cc: oprofile-list@lists.sourceforge.net, Daniel Kalmar <kalmard@homejinni.com>, Gergely Kis <gergely@homejinni.com>
In-reply-to: <1305290285-13818-1-git-send-email-gergely@homejinni.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1305290285-13818-1-git-send-email-gergely@homejinni.com>
Sender: linux-mips-bounce@linux-mips.org
From: Daniel Kalmar <kalmard@homejinni.com>

The unwind_stack_by_address variant supports unwinding based
on any kernel code address.
This symbol is also exported so it can be called from modules.

Signed-off-by: Daniel Kalmar <kalmard@homejinni.com>
Signed-off-by: Gergely Kis <gergely@homejinni.com>
---
 arch/mips/include/asm/stacktrace.h |    4 ++++
 arch/mips/kernel/process.c         |   18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/stacktrace.h 
b/arch/mips/include/asm/stacktrace.h
index 0bf8281..780ee2c 100644
--- a/arch/mips/include/asm/stacktrace.h
+++ b/arch/mips/include/asm/stacktrace.h
@@ -7,6 +7,10 @@
 extern int raw_show_trace;
 extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
                                  unsigned long pc, unsigned long *ra);
+extern unsigned long unwind_stack_by_address(unsigned long stack_page,
+                                            unsigned long *sp,
+                                            unsigned long pc,
+                                            unsigned long *ra);
 #else
 #define raw_show_trace 1
 static inline unsigned long unwind_stack(struct task_struct *task,
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index d2112d3..0acb274 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -373,18 +373,18 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 
 
 #ifdef CONFIG_KALLSYMS
-/* used by show_backtrace() */
-unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
-                          unsigned long pc, unsigned long *ra)
+/* generic stack unwinding function */
+unsigned long notrace unwind_stack_by_address(unsigned long stack_page,
+                                             unsigned long *sp,
+                                             unsigned long pc,
+                                             unsigned long *ra)
 {
-       unsigned long stack_page;
        struct mips_frame_info info;
        unsigned long size, ofs;
        int leaf;
        extern void ret_from_irq(void);
        extern void ret_from_exception(void);
 
-       stack_page = (unsigned long)task_stack_page(task);
        if (!stack_page)
                return 0;
 
@@ -443,6 +443,14 @@ unsigned long unwind_stack(struct task_struct *task, 
unsigned long *sp,
        *ra = 0;
        return __kernel_text_address(pc) ? pc : 0;
 }
+EXPORT_SYMBOL(unwind_stack_by_address);
+
+/* used by show_backtrace() */
+unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
+                          unsigned long pc, unsigned long *ra) {
+       unsigned long stack_page = (unsigned long)task_stack_page(task);
+       return unwind_stack_by_address(stack_page, sp, pc, ra);
+}
 #endif
 
 /*
-- 
1.7.0.4


<Prev in Thread] Current Thread [Next in Thread>