debuggers.hg

view xen/arch/x86/extable.c @ 3770:d21fbb46b9d8

bitkeeper revision 1.1159.253.1 (4208f8a54Zaz-XgC11YTHeLxPHPoZg)

Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
author kaf24@scramble.cl.cam.ac.uk
date Tue Feb 08 17:36:37 2005 +0000 (2005-02-08)
parents 96f143b7c63d cb87fd290eb0
children 12104922e743
line source
2 #include <xen/config.h>
3 #include <xen/spinlock.h>
4 #include <asm/uaccess.h>
6 extern struct exception_table_entry __start___ex_table[];
7 extern struct exception_table_entry __stop___ex_table[];
8 extern struct exception_table_entry __start___pre_ex_table[];
9 extern struct exception_table_entry __stop___pre_ex_table[];
11 static void sort_exception_table(struct exception_table_entry *start,
12 struct exception_table_entry *end)
13 {
14 struct exception_table_entry *p, *q, tmp;
16 for ( p = start; p < end; p++ )
17 {
18 for ( q = p-1; q > start; q-- )
19 if ( p->insn > q->insn )
20 break;
21 if ( ++q != p )
22 {
23 tmp = *p;
24 memmove(q+1, q, (p-q)*sizeof(*p));
25 *q = tmp;
26 }
27 }
28 }
30 void sort_exception_tables(void)
31 {
32 sort_exception_table(__start___ex_table, __stop___ex_table);
33 sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table);
34 }
36 static inline unsigned long
37 search_one_table(const struct exception_table_entry *first,
38 const struct exception_table_entry *last,
39 unsigned long value)
40 {
41 const struct exception_table_entry *mid;
42 long diff;
44 while ( first <= last )
45 {
46 mid = (last - first) / 2 + first;
47 diff = mid->insn - value;
48 if (diff == 0)
49 return mid->fixup;
50 else if (diff < 0)
51 first = mid+1;
52 else
53 last = mid-1;
54 }
55 return 0;
56 }
58 unsigned long
59 search_exception_table(unsigned long addr)
60 {
61 return search_one_table(
62 __start___ex_table, __stop___ex_table-1, addr);
63 }
65 unsigned long
66 search_pre_exception_table(unsigned long addr)
67 {
68 unsigned long fixup = search_one_table(
69 __start___pre_ex_table, __stop___pre_ex_table-1, addr);
70 DPRINTK("Pre-exception: %p -> %p\n", addr, fixup);
71 return fixup;
72 }