1 Index: linux-2.4.21-273/arch/i386/kernel/process.c
2 ===================================================================
3 --- linux-2.4.21-273.orig/arch/i386/kernel/process.c 2005-01-17 07:08:16.000000000 -0500
4 +++ linux-2.4.21-273/arch/i386/kernel/process.c 2005-04-05 20:11:38.391253492 -0400
8 #endif /* CONFIG_KDB */
9 +#include <linux/version.h>
11 #include <asm/uaccess.h>
12 #include <asm/pgtable.h>
14 void show_regs(struct pt_regs * regs)
16 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
17 + static char buffer[512];
19 + lookup_symbol(regs->eip, buffer, 512);
22 printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
23 printk("EIP: %04x:[<%08lx>] CPU: %d",0xffff & regs->xcs,regs->eip, smp_processor_id());
24 + printk("\nEIP is at %s (" UTS_RELEASE ")\n", buffer);
26 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
27 printk(" EFLAGS: %08lx %s\n",regs->eflags, print_tainted());
28 Index: linux-2.4.21-273/arch/i386/kernel/traps.c
29 ===================================================================
30 --- linux-2.4.21-273.orig/arch/i386/kernel/traps.c 2005-04-05 20:11:27.381848523 -0400
31 +++ linux-2.4.21-273/arch/i386/kernel/traps.c 2005-04-05 20:11:38.392253347 -0400
33 #include <linux/spinlock.h>
34 #include <linux/interrupt.h>
35 #include <linux/highmem.h>
36 +#include <linux/version.h>
38 #include <linux/rashooks.h>
44 - unsigned long *prev = NULL;
45 + /* static to not take up stackspace; if we race here too bad */
46 + static char buffer[512];
49 stack = (unsigned long*)&stack;
51 while (((long) stack & (THREAD_SIZE-1)) != 0) {
53 if (kernel_text_address(addr)) {
55 - printk(" (%02d)", (stack-prev)*sizeof(*stack));
59 - printk(" [<%08lx>]", addr);
60 + lookup_symbol(addr, buffer, 512);
61 + printk(" [<%08lx>] %s (0x%p)\n",
62 + addr, buffer, stack - 1);
67 - printk(" (%02d)", (stack-prev)*sizeof(*stack));
72 printk("Code: <0>\n"); /* tell ksymoops trace ends here */
76 +#define ARCHIT "/athlon"
78 +#define ARCHIT "/i686"
81 void show_registers(struct pt_regs *regs)
87 + static char buffer[512];
89 esp = (unsigned long) (®s->esp);
93 ss = regs->xss & 0xffff;
96 + lookup_symbol(regs->eip, buffer, 512);
97 module_oops_tracking_init();
98 kernel_text_address(regs->eip);
99 printk("CPU: %d\nEIP: %04x:[<%08lx>] %s\nEFLAGS: %08lx\n",
100 smp_processor_id(), 0xffff & regs->xcs, regs->eip, print_tainted(), regs->eflags);
101 + printk("\nEIP is at %s (" UTS_RELEASE ARCHIT ")\n", buffer);
102 printk("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
103 regs->eax, regs->ebx, regs->ecx, regs->edx);
104 printk("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
106 (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
107 file = "<bad filename>";
109 + printk("-----------[ cut here ]------------\n");
110 printk("kernel BUG at %s:%d!\n", file, line);
113 Index: linux-2.4.21-273/include/linux/kernel.h
114 ===================================================================
115 --- linux-2.4.21-273.orig/include/linux/kernel.h 2005-01-17 07:09:09.000000000 -0500
116 +++ linux-2.4.21-273/include/linux/kernel.h 2005-04-05 20:11:38.393253203 -0400
119 extern void dump_stack(void);
121 +extern int lookup_symbol(unsigned long address, char *buffer, int buflen);
122 +extern void print_modules(void);
124 extern char *oops_id;
127 Index: linux-2.4.21-273/kernel/Makefile
128 ===================================================================
129 --- linux-2.4.21-273.orig/kernel/Makefile 2005-01-17 07:08:59.000000000 -0500
130 +++ linux-2.4.21-273/kernel/Makefile 2005-04-05 20:12:04.410483855 -0400
133 export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \
134 printk.o cpufreq.o rcupdate.o syscall_ksyms.o fork.o hook.o \
135 - rashooks.o module.o
136 + rashooks.o module.o kksymoops.o
138 obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
139 module.o exit.o itimer.o info.o time.o softirq.o resource.o \
140 sysctl.o acct.o capability.o ptrace.o timer.o user.o \
141 - signal.o sys.o kmod.o context.o rcupdate.o futex.o syscall_ksyms.o
142 + signal.o sys.o kmod.o context.o rcupdate.o futex.o \
143 + syscall_ksyms.o kksymoops.o
145 obj-$(CONFIG_UID16) += uid16.o
146 obj-$(CONFIG_MODULES) += ksyms.o
147 Index: linux-2.4.21-273/kernel/kksymoops.c
148 ===================================================================
149 --- linux-2.4.21-273.orig/kernel/kksymoops.c 1969-12-31 19:00:00.000000000 -0500
150 +++ linux-2.4.21-273/kernel/kksymoops.c 2005-04-05 20:11:38.394253058 -0400
152 +#include <linux/module.h>
153 +#include <linux/string.h>
154 +#include <linux/errno.h>
155 +#include <linux/kernel.h>
156 +#include <linux/config.h>
157 +#ifdef CONFIG_KALLSYMS
158 +#include <linux/kallsyms.h>
163 +int lookup_symbol(unsigned long address, char *buffer, int buflen)
165 + struct module *this_mod;
166 + unsigned long bestsofar;
168 + const char *mod_name = NULL, *sec_name = NULL, *sym_name = NULL;
169 + unsigned long mod_start,mod_end,sec_start,sec_end,sym_start,sym_end;
177 + memset(buffer,0,buflen);
179 +#ifdef CONFIG_KALLSYMS
180 + if (!kallsyms_address_to_symbol(address,&mod_name,&mod_start,&mod_end,&sec_name,
181 + &sec_start, &sec_end, &sym_name, &sym_start, &sym_end)) {
182 + /* kallsyms doesn't have a clue; lets try harder */
184 + snprintf(buffer,buflen-1,"[unresolved]");
186 + this_mod = module_list;
188 + while (this_mod != NULL) {
190 + /* walk the symbol list of this module. Only symbols
191 + who's address is smaller than the searched for address
192 + are relevant; and only if it's better than the best so far */
193 + for (i=0; i< this_mod->nsyms; i++)
194 + if ((this_mod->syms[i].value<=address) &&
195 + (bestsofar<this_mod->syms[i].value)) {
196 + snprintf(buffer,buflen-1,"%s [%s] 0x%x",
197 + this_mod->syms[i].name,
199 + (unsigned int)(address - this_mod->syms[i].value));
200 + bestsofar = this_mod->syms[i].value;
202 + this_mod = this_mod->next;
205 + } else { /* kallsyms success */
206 + snprintf(buffer,buflen-1,"%s [%s] 0x%x",sym_name,mod_name,(unsigned int)(address-sym_start));
209 + return strlen(buffer);
211 +EXPORT_SYMBOL(lookup_symbol);
213 +static char modlist[4096];
214 +/* this function isn't smp safe but that's not really a problem; it's called from
215 + * oops context only and any locking could actually prevent the oops from going out;
216 + * the line that is generated is informational only and should NEVER prevent the real oops
219 +void print_modules(void)
221 + struct module *this_mod;
223 + memset(modlist,0,4096);
225 +#ifdef CONFIG_KALLSYMS
226 + this_mod = module_list;
227 + while (this_mod != NULL) {
228 + if (this_mod->name != NULL)
229 + pos +=snprintf(modlist+pos,160-pos-1,"%s ",this_mod->name);
230 + this_mod = this_mod->next;
232 + printk("%s\n",modlist);