debuggers.hg

view xen/arch/x86/x86_64/traps.c @ 3641:e6af5d8f8b39

bitkeeper revision 1.1159.236.1 (42000d46U0ZeCEM9d6oFhwqrTrOgDg)

Merge ssh://kaf24@scramble.cl.cam.ac.uk//usr/groups/xeno/BK/xen-unstable.bk
into viper.(none):/home/kaf24/xen-unstable.bk
author kaf24@viper.(none)
date Tue Feb 01 23:14:14 2005 +0000 (2005-02-01)
parents 9a9c5a491401
children fd1dd0663b09
line source
2 #include <xen/config.h>
3 #include <xen/init.h>
4 #include <xen/sched.h>
5 #include <xen/lib.h>
6 #include <xen/errno.h>
7 #include <xen/mm.h>
8 #include <xen/irq.h>
10 static int kstack_depth_to_print = 8*20;
12 static inline int kernel_text_address(unsigned long addr)
13 {
14 if (addr >= (unsigned long) &_stext &&
15 addr <= (unsigned long) &_etext)
16 return 1;
17 return 0;
19 }
21 void show_guest_stack(void)
22 {
23 int i;
24 execution_context_t *ec = get_execution_context();
25 unsigned long *stack = (unsigned long *)ec->rsp;
26 printk("Guest RIP is %lx\n", ec->rip);
28 for ( i = 0; i < kstack_depth_to_print; i++ )
29 {
30 if ( ((long)stack & (STACK_SIZE-1)) == 0 )
31 break;
32 if ( i && ((i % 8) == 0) )
33 printk("\n ");
34 printk("%08lx ", *stack++);
35 }
36 printk("\n");
38 }
40 void show_trace(unsigned long *rsp)
41 {
42 unsigned long *stack, addr;
43 int i;
45 printk("Call Trace from RSP=%p: ", rsp);
46 stack = rsp;
47 i = 0;
48 while (((long) stack & (STACK_SIZE-1)) != 0) {
49 addr = *stack++;
50 if (kernel_text_address(addr)) {
51 if (i && ((i % 6) == 0))
52 printk("\n ");
53 printk("[<%08lx>] ", addr);
54 i++;
55 }
56 }
57 printk("\n");
58 }
60 void show_stack(unsigned long *rsp)
61 {
62 unsigned long *stack;
63 int i;
65 printk("Stack trace from RSP=%p:\n", rsp);
67 stack = rsp;
68 for ( i = 0; i < kstack_depth_to_print; i++ )
69 {
70 if ( ((long)stack & (STACK_SIZE-1)) == 0 )
71 break;
72 if ( i && ((i % 8) == 0) )
73 printk("\n ");
74 if ( kernel_text_address(*stack) )
75 printk("[%08lx] ", *stack++);
76 else
77 printk("%08lx ", *stack++);
78 }
79 printk("\n");
81 show_trace(rsp);
82 }
84 void show_registers(struct xen_regs *regs)
85 {
86 printk("CPU: %d\nEIP: %04lx:[<%08lx>] \nEFLAGS: %08lx\n",
87 smp_processor_id(), 0xffff & regs->cs, regs->rip, regs->eflags);
88 printk("rax: %08lx rbx: %08lx rcx: %08lx rdx: %08lx\n",
89 regs->rax, regs->rbx, regs->rcx, regs->rdx);
90 printk("rsi: %08lx rdi: %08lx rbp: %08lx rsp: %08lx ss: %04x\n",
91 regs->rsi, regs->rdi, regs->rbp, regs->rsp, regs->ss);
92 printk("r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
93 regs->r8, regs->r9, regs->r10, regs->r11);
94 printk("r12: %08lx r13: %08lx r14: %08lx r15: %08lx\n",
95 regs->r12, regs->r13, regs->r14, regs->r15);
97 show_stack((unsigned long *)regs->rsp);
98 }
100 void __init doublefault_init(void)
101 {
102 }
104 void *decode_reg(struct xen_regs *regs, u8 b)
105 {
106 switch ( b )
107 {
108 case 0: return &regs->rax;
109 case 1: return &regs->rcx;
110 case 2: return &regs->rdx;
111 case 3: return &regs->rbx;
112 case 4: return &regs->rsp;
113 case 5: return &regs->rbp;
114 case 6: return &regs->rsi;
115 case 7: return &regs->rdi;
116 case 8: return &regs->r8;
117 case 9: return &regs->r9;
118 case 10: return &regs->r10;
119 case 11: return &regs->r11;
120 case 12: return &regs->r12;
121 case 13: return &regs->r13;
122 case 14: return &regs->r14;
123 case 15: return &regs->r15;
124 }
126 return NULL;
127 }