Skip to content

Commit

Permalink
x86: dumpstack: Clean up the x86_stack_ids[][] initalization and othe…
Browse files Browse the repository at this point in the history
…r details

Make the initialization more readable, plus tidy up a few small
visual details as well.

No change in functionality.

LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Nov 26, 2009
1 parent 27c13ec commit b803090
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
9 changes: 4 additions & 5 deletions arch/x86/kernel/dumpstack_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/kexec.h>
#include <linux/sysfs.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

Expand All @@ -35,6 +35,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,

if (!stack) {
unsigned long dummy;

stack = &dummy;
if (task && task != current)
stack = (unsigned long *)task->thread.sp;
Expand All @@ -57,8 +58,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,

context = (struct thread_info *)
((unsigned long)stack & (~(THREAD_SIZE - 1)));
bp = print_context_stack(context, stack, bp, ops,
data, NULL, &graph);
bp = print_context_stack(context, stack, bp, ops, data, NULL, &graph);

stack = (unsigned long *)context->previous_esp;
if (!stack)
Expand All @@ -72,7 +72,7 @@ EXPORT_SYMBOL(dump_trace);

void
show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
unsigned long *sp, unsigned long bp, char *log_lvl)
unsigned long *sp, unsigned long bp, char *log_lvl)
{
unsigned long *stack;
int i;
Expand Down Expand Up @@ -156,4 +156,3 @@ int is_valid_bugaddr(unsigned long ip)

return ud2 == 0x0b0f;
}

25 changes: 13 additions & 12 deletions arch/x86/kernel/dumpstack_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,36 @@
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/kexec.h>
#include <linux/sysfs.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

#include "dumpstack.h"

#define N_EXCEPTION_STACKS_END \
(N_EXCEPTION_STACKS + DEBUG_STKSZ/EXCEPTION_STKSZ - 2)

static char x86_stack_ids[][8] = {
[DEBUG_STACK - 1] = "#DB",
[NMI_STACK - 1] = "NMI",
[DOUBLEFAULT_STACK - 1] = "#DF",
[STACKFAULT_STACK - 1] = "#SS",
[MCE_STACK - 1] = "#MC",
[ DEBUG_STACK-1 ] = "#DB",
[ NMI_STACK-1 ] = "NMI",
[ DOUBLEFAULT_STACK-1 ] = "#DF",
[ STACKFAULT_STACK-1 ] = "#SS",
[ MCE_STACK-1 ] = "#MC",
#if DEBUG_STKSZ > EXCEPTION_STKSZ
[N_EXCEPTION_STACKS ...
N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
[ N_EXCEPTION_STACKS ...
N_EXCEPTION_STACKS_END ] = "#DB[?]"
#endif
};
};

int x86_is_stack_id(int id, char *name)
{
return x86_stack_ids[id - 1] == name;
}

static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
unsigned *usedp, char **idp)
unsigned *usedp, char **idp)
{
unsigned k;

Expand Down Expand Up @@ -202,7 +204,7 @@ EXPORT_SYMBOL(dump_trace);

void
show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
unsigned long *sp, unsigned long bp, char *log_lvl)
unsigned long *sp, unsigned long bp, char *log_lvl)
{
unsigned long *stack;
int i;
Expand Down Expand Up @@ -303,4 +305,3 @@ int is_valid_bugaddr(unsigned long ip)

return ud2 == 0x0b0f;
}

0 comments on commit b803090

Please sign in to comment.