Merge with Linux 2.5.48.
[linux-2.6/linux-mips.git] / arch / um / kernel / sysrq.c
blob5a05d66a125f79167264b7a1425bcffa3ae18b7b
1 /*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include "linux/sched.h"
7 #include "linux/kernel.h"
8 #include "linux/module.h"
9 #include "asm/page.h"
10 #include "asm/processor.h"
11 #include "sysrq.h"
12 #include "user_util.h"
15 * If the address is either in the .text section of the
16 * kernel, or in the vmalloc'ed module regions, it *may*
17 * be the address of a calling routine
20 #ifdef CONFIG_MODULES
22 extern struct module *module_list;
23 extern struct module kernel_module;
25 static inline int kernel_text_address(unsigned long addr)
27 int retval = 0;
28 struct module *mod;
30 if (addr >= (unsigned long) &_stext &&
31 addr <= (unsigned long) &_etext)
32 return 1;
34 for (mod = module_list; mod != &kernel_module; mod = mod->next) {
35 /* mod_bound tests for addr being inside the vmalloc'ed
36 * module area. Of course it'd be better to test only
37 * for the .text subset... */
38 if (mod_bound(addr, 0, mod)) {
39 retval = 1;
40 break;
44 return retval;
47 #else
49 static inline int kernel_text_address(unsigned long addr)
51 return (addr >= (unsigned long) &_stext &&
52 addr <= (unsigned long) &_etext);
55 #endif
57 void show_trace(unsigned long * stack)
59 int i;
60 unsigned long addr;
62 if (!stack)
63 stack = (unsigned long*) &stack;
65 printk("Call Trace: ");
66 i = 1;
67 while (((long) stack & (THREAD_SIZE-1)) != 0) {
68 addr = *stack++;
69 if (kernel_text_address(addr)) {
70 if (i && ((i % 6) == 0))
71 printk("\n ");
72 printk("[<%08lx>] ", addr);
73 i++;
76 printk("\n");
80 * The architecture-independent dump_stack generator
82 void dump_stack(void)
84 unsigned long stack;
86 show_trace(&stack);
89 void show_trace_task(struct task_struct *tsk)
91 unsigned long esp = PT_REGS_SP(&tsk->thread.regs);
93 /* User space on another CPU? */
94 if ((esp ^ (unsigned long)tsk) & (PAGE_MASK<<1))
95 return;
96 show_trace((unsigned long *)esp);
100 * Overrides for Emacs so that we follow Linus's tabbing style.
101 * Emacs will notice this stuff at the end of the file and automatically
102 * adjust the settings for this buffer only. This must remain at the end
103 * of the file.
104 * ---------------------------------------------------------------------------
105 * Local variables:
106 * c-file-style: "linux"
107 * End: