Whamcloud - gitweb
LU-4199 libcfs: add wrapper of dump_trace() 72/8872/5
authorLi Xi <lixi@ddn.com>
Thu, 27 Feb 2014 17:02:12 +0000 (12:02 -0500)
committerAndreas Dilger <andreas.dilger@intel.com>
Mon, 10 Mar 2014 17:49:48 +0000 (17:49 +0000)
dump_trace() is a X86 specific function. It will cause
compilation failure if the architecture is not X86. A more
general function dump_stack() should be called under that
environment.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I8a5fffa6dec15dc8c779a22e24c10b364c77f9a0
Reviewed-on: http://review.whamcloud.com/8872
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
libcfs/libcfs/linux/linux-debug.c

index fe93f0c..3fb9797 100644 (file)
@@ -184,6 +184,7 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
 
 #ifdef __KERNEL__
 
+#ifdef CONFIG_X86
 #include <linux/nmi.h>
 #include <asm/stacktrace.h>
 
@@ -229,6 +230,28 @@ static const struct stacktrace_ops print_trace_ops = {
 #endif
 };
 
+static void libcfs_call_trace(struct task_struct *tsk)
+{
+       dump_trace(tsk, NULL, NULL,
+#ifdef HAVE_DUMP_TRACE_ADDRESS
+                  0,
+#endif /* HAVE_DUMP_TRACE_ADDRESS */
+                  &print_trace_ops, NULL);
+       printk("\n");
+}
+
+#else /* !CONFIG_X86 */
+
+static void libcfs_call_trace(struct task_struct *tsk)
+{
+       if ((tsk == NULL) || (tsk == current))
+               dump_stack();
+       else
+               CWARN("can't show stack: kernel doesn't export show_task\n");
+}
+
+#endif /* CONFIG_X86 */
+
 void libcfs_debug_dumpstack(struct task_struct *tsk)
 {
         /* dump_stack() */
@@ -238,12 +261,7 @@ void libcfs_debug_dumpstack(struct task_struct *tsk)
        printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm);
         /* show_trace_log_lvl() */
        printk("\nCall Trace:\n");
-       dump_trace(tsk, NULL, NULL,
-#ifdef HAVE_DUMP_TRACE_ADDRESS
-                   0,
-#endif /* HAVE_DUMP_TRACE_ADDRESS */
-                   &print_trace_ops, NULL);
-       printk("\n");
+       libcfs_call_trace(tsk);
 }
 
 struct task_struct *libcfs_current(void)
@@ -268,10 +286,10 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1,
         if (in_interrupt()) {
                 cfs_trace_debug_print();
         } else {
-# ifdef HAVE_KERNEL_LOCKED
+#ifdef HAVE_KERNEL_LOCKED
                while (kernel_locked())
                        unlock_kernel();
-# endif
+#endif
                libcfs_debug_dumplog_internal((void *)(long)current_pid());
         }
 #endif