mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 08:31:55 +00:00
196779b9b4
Both dump_stack() and show_stack() are currently implemented by each architecture. show_stack(NULL, NULL) dumps the backtrace for the current task as does dump_stack(). On some archs, dump_stack() prints extra information - pid, utsname and so on - in addition to the backtrace while the two are identical on other archs. The usages in arch-independent code of the two functions indicate show_stack(NULL, NULL) should print out bare backtrace while dump_stack() is used for debugging purposes when something went wrong, so it does make sense to print additional information on the task which triggered dump_stack(). There's no reason to require archs to implement two separate but mostly identical functions. It leads to unnecessary subtle information. This patch expands the dummy fallback dump_stack() implementation in lib/dump_stack.c such that it prints out debug information (taken from x86) and invokes show_stack(NULL, NULL) and drops arch-specific dump_stack() implementations in all archs except blackfin. Blackfin's dump_stack() does something wonky that I don't understand. Debug information can be printed separately by calling dump_stack_print_info() so that arch-specific dump_stack() implementation can still emit the same debug information. This is used in blackfin. This patch brings the following behavior changes. * On some archs, an extra level in backtrace for show_stack() could be printed. This is because the top frame was determined in dump_stack() on those archs while generic dump_stack() can't do that reliably. It can be compensated by inlining dump_stack() but not sure whether that'd be necessary. * Most archs didn't use to print debug info on dump_stack(). They do now. An example WARN dump follows. WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505() Hardware name: empty Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #9 0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48 ffffffff8108f50f ffffffff82228240 0000000000000040 ffffffff8234a03c 0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58 Call Trace: [<ffffffff81c614dc>] dump_stack+0x19/0x1b [<ffffffff8108f50f>] warn_slowpath_common+0x7f/0xc0 [<ffffffff8108f56a>] warn_slowpath_null+0x1a/0x20 [<ffffffff8234a071>] init_workqueues+0x35/0x505 ... v2: CPU number added to the generic debug info as requested by s390 folks and dropped the s390 specific dump_stack(). This loses %ksp from the debug message which the maintainers think isn't important enough to keep the s390-specific dump_stack() implementation. dump_stack_print_info() is moved to kernel/printk.c from lib/dump_stack.c. Because linkage is per objecct file, dump_stack_print_info() living in the same lib file as generic dump_stack() means that archs which implement custom dump_stack() - at this point, only blackfin - can't use dump_stack_print_info() as that will bring in the generic version of dump_stack() too. v1 The v1 patch broke build on blackfin due to this issue. The build breakage was reported by Fengguang Wu. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Vineet Gupta <vgupta@synopsys.com> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: Vineet Gupta <vgupta@synopsys.com> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com> [s390 bits] Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Sam Ravnborg <sam@ravnborg.org> Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon bits] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
167 lines
3.9 KiB
C
167 lines
3.9 KiB
C
/*
|
|
* linux/arch/h8300/boot/traps.c -- general exception handling code
|
|
* H8/300 support Yoshinori Sato <ysato@users.sourceforge.jp>
|
|
*
|
|
* Cloned from Linux/m68k.
|
|
*
|
|
* No original Copyright holder listed,
|
|
* Probable original (C) Roman Zippel (assigned DJD, 1999)
|
|
*
|
|
* Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file COPYING in the main directory of this archive
|
|
* for more details.
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/bug.h>
|
|
|
|
#include <asm/irq.h>
|
|
#include <asm/traps.h>
|
|
#include <asm/page.h>
|
|
|
|
static DEFINE_SPINLOCK(die_lock);
|
|
|
|
/*
|
|
* this must be called very early as the kernel might
|
|
* use some instruction that are emulated on the 060
|
|
*/
|
|
|
|
void __init base_trap_init(void)
|
|
{
|
|
}
|
|
|
|
void __init trap_init (void)
|
|
{
|
|
}
|
|
|
|
asmlinkage void set_esp0 (unsigned long ssp)
|
|
{
|
|
current->thread.esp0 = ssp;
|
|
}
|
|
|
|
/*
|
|
* Generic dumping code. Used for panic and debug.
|
|
*/
|
|
|
|
static void dump(struct pt_regs *fp)
|
|
{
|
|
unsigned long *sp;
|
|
unsigned char *tp;
|
|
int i;
|
|
|
|
printk("\nCURRENT PROCESS:\n\n");
|
|
printk("COMM=%s PID=%d\n", current->comm, current->pid);
|
|
if (current->mm) {
|
|
printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
|
|
(int) current->mm->start_code,
|
|
(int) current->mm->end_code,
|
|
(int) current->mm->start_data,
|
|
(int) current->mm->end_data,
|
|
(int) current->mm->end_data,
|
|
(int) current->mm->brk);
|
|
printk("USER-STACK=%08x KERNEL-STACK=%08lx\n\n",
|
|
(int) current->mm->start_stack,
|
|
(int) PAGE_SIZE+(unsigned long)current);
|
|
}
|
|
|
|
show_regs(fp);
|
|
printk("\nCODE:");
|
|
tp = ((unsigned char *) fp->pc) - 0x20;
|
|
for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
|
|
if ((i % 0x10) == 0)
|
|
printk("\n%08x: ", (int) (tp + i));
|
|
printk("%08x ", (int) *sp++);
|
|
}
|
|
printk("\n");
|
|
|
|
printk("\nKERNEL STACK:");
|
|
tp = ((unsigned char *) fp) - 0x40;
|
|
for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
|
|
if ((i % 0x10) == 0)
|
|
printk("\n%08x: ", (int) (tp + i));
|
|
printk("%08x ", (int) *sp++);
|
|
}
|
|
printk("\n");
|
|
if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
|
|
printk("(Possibly corrupted stack page??)\n");
|
|
|
|
printk("\n\n");
|
|
}
|
|
|
|
void die(const char *str, struct pt_regs *fp, unsigned long err)
|
|
{
|
|
static int diecount;
|
|
|
|
oops_enter();
|
|
|
|
console_verbose();
|
|
spin_lock_irq(&die_lock);
|
|
report_bug(fp->pc, fp);
|
|
printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
|
|
dump(fp);
|
|
|
|
spin_unlock_irq(&die_lock);
|
|
do_exit(SIGSEGV);
|
|
}
|
|
|
|
extern char _start, _etext;
|
|
#define check_kernel_text(addr) \
|
|
((addr >= (unsigned long)(&_start)) && \
|
|
(addr < (unsigned long)(&_etext)))
|
|
|
|
static int kstack_depth_to_print = 24;
|
|
|
|
void show_stack(struct task_struct *task, unsigned long *esp)
|
|
{
|
|
unsigned long *stack, addr;
|
|
int i;
|
|
|
|
if (esp == NULL)
|
|
esp = (unsigned long *) &esp;
|
|
|
|
stack = esp;
|
|
|
|
printk("Stack from %08lx:", (unsigned long)stack);
|
|
for (i = 0; i < kstack_depth_to_print; i++) {
|
|
if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
|
|
break;
|
|
if (i % 8 == 0)
|
|
printk("\n ");
|
|
printk(" %08lx", *stack++);
|
|
}
|
|
|
|
printk("\nCall Trace:");
|
|
i = 0;
|
|
stack = esp;
|
|
while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) {
|
|
addr = *stack++;
|
|
/*
|
|
* If the address is either in the text segment of the
|
|
* kernel, or in the region which contains vmalloc'ed
|
|
* memory, it *may* be the address of a calling
|
|
* routine; if so, print it so that someone tracing
|
|
* down the cause of the crash will be able to figure
|
|
* out the call path that was taken.
|
|
*/
|
|
if (check_kernel_text(addr)) {
|
|
if (i % 4 == 0)
|
|
printk("\n ");
|
|
printk(" [<%08lx>]", addr);
|
|
i++;
|
|
}
|
|
}
|
|
printk("\n");
|
|
}
|
|
|
|
void show_trace_task(struct task_struct *tsk)
|
|
{
|
|
show_stack(tsk,(unsigned long *)tsk->thread.esp0);
|
|
}
|