initial import
[patches.git] / better-addr.patch
CommitLineData
5e993f12 1--- arch/blackfin/kernel/traps.c
2+++ arch/blackfin/kernel/traps.c
3@@ -94,30 +99,63 @@ static int printk_address(unsigned long
4 char *delim = ":";
5 char namebuf[128];
6
7- symname =
8- kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
9- if (!symname) {
10- if (current->mm) {
11- if ((address > current->mm->start_code) &&
12- (address < current->mm->end_code)) {
13- return printk("<%08lx>[%s+0x%lx]",
14- address,
15- current->comm,
16- (long)(address -
17- current->mm->start_code));
18+ /* look up the address and see if we are in kernel space */
19+ symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
20+
21+ if (symname) {
22+ /* yeah! kernel space! */
23+ if (!modname)
24+ modname = delim = "";
25+ return printk("<0x%p> { %s%s%s%s + 0x%lX }",
26+ (void*)address, delim, modname, delim, symname, (unsigned long)offset);
27+
28+ } else {
29+ /* looks like we're off in user-land, so let's walk all the
30+ * mappings of all our processes and see if we can't be a whee
31+ * bit more specific
32+ */
33+ struct vm_list_struct *vml;
34+ struct task_struct *p;
35+ struct mm_struct *mm;
36+
37+ write_lock_irq(&tasklist_lock);
38+ for_each_process (p) {
39+ mm = get_task_mm(p);
40+ if (!mm)
41+ continue;
42+
43+ vml = mm->context.vmlist;
44+ while (vml) {
45+ struct vm_area_struct *vma = vml->vma;
46+
47+ if ((address >= vma->vm_start) && (address < vma->vm_end)) {
48+ char *name = p->comm;
49+ struct file *file = vma->vm_file;
50+ if (file) {
51+ char _tmpbuf[256];
52+ name = d_path(file->f_dentry, file->f_vfsmnt, _tmpbuf, sizeof(_tmpbuf));
53+ }
54+
55+ write_unlock_irq(&tasklist_lock);
56+ return printk("<0x%p> [ %s + 0x%lX ]",
57+ (void*)address,
58+ name,
59+ (unsigned long)((address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT)));
60+ }
61+
62+ vml = vml->next;
63 }
64 }
65- return printk("[<%08lx>]", address);
66+ write_unlock_irq(&tasklist_lock);
67 }
68- if (!modname)
69- modname = delim = "";
70- return printk("<%08lx>{%s%s%s%s+0x%lx}",
71- address, delim, modname, delim, symname, (long)offset);
72+
73+ /* we were unable to find this address anywhere */
74+ return printk("[<0x%p>]", (void*)address);
75 }
76 #else
77 static int printk_address(unsigned long address)
78 {
79- return printk("[<%08lx>]", address);
80+ return printk("[<0x%p>]", (void*)address);
81 }
82 #endif
83