提交 7aa89746 编写于 作者: C Chuck Ebbert 提交者: Linus Torvalds

[PATCH] i386: fix stack dump loglevel

Recent changes caused part of stack traces from SysRq-T to print at
KERN_EMERG loglevel.  Also, parts of stack dump during oops were failing to
print at that level when they should.
Signed-off-by: NChuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 ce63ad78
...@@ -112,33 +112,38 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) ...@@ -112,33 +112,38 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
p < (void *)tinfo + THREAD_SIZE - 3; p < (void *)tinfo + THREAD_SIZE - 3;
} }
static void print_addr_and_symbol(unsigned long addr, char *log_lvl)
{
printk(log_lvl);
printk(" [<%08lx>] ", addr);
print_symbol("%s", addr);
printk("\n");
}
static inline unsigned long print_context_stack(struct thread_info *tinfo, static inline unsigned long print_context_stack(struct thread_info *tinfo,
unsigned long *stack, unsigned long ebp) unsigned long *stack, unsigned long ebp,
char *log_lvl)
{ {
unsigned long addr; unsigned long addr;
#ifdef CONFIG_FRAME_POINTER #ifdef CONFIG_FRAME_POINTER
while (valid_stack_ptr(tinfo, (void *)ebp)) { while (valid_stack_ptr(tinfo, (void *)ebp)) {
addr = *(unsigned long *)(ebp + 4); addr = *(unsigned long *)(ebp + 4);
printk(KERN_EMERG " [<%08lx>] ", addr); print_addr_and_symbol(addr, log_lvl);
print_symbol("%s", addr);
printk("\n");
ebp = *(unsigned long *)ebp; ebp = *(unsigned long *)ebp;
} }
#else #else
while (valid_stack_ptr(tinfo, stack)) { while (valid_stack_ptr(tinfo, stack)) {
addr = *stack++; addr = *stack++;
if (__kernel_text_address(addr)) { if (__kernel_text_address(addr))
printk(KERN_EMERG " [<%08lx>]", addr); print_addr_and_symbol(addr, log_lvl);
print_symbol(" %s", addr);
printk("\n");
}
} }
#endif #endif
return ebp; return ebp;
} }
void show_trace(struct task_struct *task, unsigned long * stack) static void show_trace_log_lvl(struct task_struct *task,
unsigned long *stack, char *log_lvl)
{ {
unsigned long ebp; unsigned long ebp;
...@@ -157,7 +162,7 @@ void show_trace(struct task_struct *task, unsigned long * stack) ...@@ -157,7 +162,7 @@ void show_trace(struct task_struct *task, unsigned long * stack)
struct thread_info *context; struct thread_info *context;
context = (struct thread_info *) context = (struct thread_info *)
((unsigned long)stack & (~(THREAD_SIZE - 1))); ((unsigned long)stack & (~(THREAD_SIZE - 1)));
ebp = print_context_stack(context, stack, ebp); ebp = print_context_stack(context, stack, ebp, log_lvl);
stack = (unsigned long*)context->previous_esp; stack = (unsigned long*)context->previous_esp;
if (!stack) if (!stack)
break; break;
...@@ -165,7 +170,13 @@ void show_trace(struct task_struct *task, unsigned long * stack) ...@@ -165,7 +170,13 @@ void show_trace(struct task_struct *task, unsigned long * stack)
} }
} }
void show_stack(struct task_struct *task, unsigned long *esp) void show_trace(struct task_struct *task, unsigned long * stack)
{
show_trace_log_lvl(task, stack, "");
}
static void show_stack_log_lvl(struct task_struct *task, unsigned long *esp,
char *log_lvl)
{ {
unsigned long *stack; unsigned long *stack;
int i; int i;
...@@ -178,16 +189,26 @@ void show_stack(struct task_struct *task, unsigned long *esp) ...@@ -178,16 +189,26 @@ void show_stack(struct task_struct *task, unsigned long *esp)
} }
stack = esp; stack = esp;
printk(KERN_EMERG); printk(log_lvl);
for(i = 0; i < kstack_depth_to_print; i++) { for(i = 0; i < kstack_depth_to_print; i++) {
if (kstack_end(stack)) if (kstack_end(stack))
break; break;
if (i && ((i % 8) == 0)) if (i && ((i % 8) == 0)) {
printk("\n" KERN_EMERG " "); printk("\n");
printk(log_lvl);
printk(" ");
}
printk("%08lx ", *stack++); printk("%08lx ", *stack++);
} }
printk("\n" KERN_EMERG "Call Trace:\n"); printk("\n");
show_trace(task, esp); printk(log_lvl);
printk("Call Trace:\n");
show_trace_log_lvl(task, esp, log_lvl);
}
void show_stack(struct task_struct *task, unsigned long *esp)
{
show_stack_log_lvl(task, esp, "");
} }
/* /*
...@@ -238,7 +259,7 @@ void show_registers(struct pt_regs *regs) ...@@ -238,7 +259,7 @@ void show_registers(struct pt_regs *regs)
u8 __user *eip; u8 __user *eip;
printk("\n" KERN_EMERG "Stack: "); printk("\n" KERN_EMERG "Stack: ");
show_stack(NULL, (unsigned long*)esp); show_stack_log_lvl(NULL, (unsigned long *)esp, KERN_EMERG);
printk(KERN_EMERG "Code: "); printk(KERN_EMERG "Code: ");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册