debuggers.hg

view xen/arch/x86/x86_64/gdbstub.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /*
2 * x86_64 -specific gdb stub routines
3 *
4 * Copyright (C) 2007 Dan Doucette ddoucette@teradici.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 #include <asm/debugger.h>
23 #define GDB_REG64(r) gdb_write_to_packet_hex(r, sizeof(u64), ctx)
24 #define GDB_REG32(r) gdb_write_to_packet_hex(r, sizeof(u32), ctx)
26 void
27 gdb_arch_read_reg_array(struct cpu_user_regs *regs, struct gdb_context *ctx)
28 {
29 GDB_REG64(regs->rax);
30 GDB_REG64(regs->rbx);
31 GDB_REG64(regs->rcx);
32 GDB_REG64(regs->rdx);
33 GDB_REG64(regs->rsi);
34 GDB_REG64(regs->rdi);
35 GDB_REG64(regs->rbp);
36 GDB_REG64(regs->rsp);
38 GDB_REG64(regs->r8);
39 GDB_REG64(regs->r9);
40 GDB_REG64(regs->r10);
41 GDB_REG64(regs->r11);
42 GDB_REG64(regs->r12);
43 GDB_REG64(regs->r13);
44 GDB_REG64(regs->r14);
45 GDB_REG64(regs->r15);
47 GDB_REG64(regs->rip);
48 GDB_REG32(regs->eflags);
50 GDB_REG32(regs->cs);
51 GDB_REG32(regs->ss);
52 GDB_REG32(regs->ds);
53 GDB_REG32(regs->es);
54 GDB_REG32(regs->fs);
55 GDB_REG32(regs->gs);
57 gdb_send_packet(ctx);
58 }
60 void
61 gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char* buf,
62 struct gdb_context *ctx)
63 {
64 gdb_send_reply("", ctx);
65 }
67 void
68 gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
69 struct gdb_context *ctx)
70 {
71 switch (regnum)
72 {
73 case 0: GDB_REG64(regs->rax); break;
74 case 1: GDB_REG64(regs->rbx); break;
75 case 2: GDB_REG64(regs->rcx); break;
76 case 3: GDB_REG64(regs->rdx); break;
77 case 4: GDB_REG64(regs->rsi); break;
78 case 5: GDB_REG64(regs->rdi); break;
79 case 6: GDB_REG64(regs->rbp); break;
80 case 7: GDB_REG64(regs->rsp); break;
82 case 8: GDB_REG64(regs->r8); break;
83 case 9: GDB_REG64(regs->r9); break;
84 case 10: GDB_REG64(regs->r10); break;
85 case 11: GDB_REG64(regs->r11); break;
86 case 12: GDB_REG64(regs->r12); break;
87 case 13: GDB_REG64(regs->r13); break;
88 case 14: GDB_REG64(regs->r14); break;
89 case 15: GDB_REG64(regs->r15); break;
91 case 16: GDB_REG64(regs->rip); break;
92 case 17: GDB_REG32(regs->rflags); break;
93 case 18: GDB_REG32(regs->cs); break;
94 case 19: GDB_REG32(regs->ss); break;
95 case 20: GDB_REG32(regs->ds); break;
96 case 21: GDB_REG32(regs->es); break;
97 case 22: GDB_REG32(regs->fs); break;
98 case 23: GDB_REG32(regs->gs); break;
99 default:
100 GDB_REG64(0xbaadf00ddeadbeef);
101 break;
102 }
103 gdb_send_packet(ctx);
104 }
106 void
107 gdb_arch_write_reg(unsigned long regnum, unsigned long val,
108 struct cpu_user_regs *regs, struct gdb_context *ctx)
109 {
110 switch (regnum)
111 {
112 case 0: regs->rax = val; break;
113 case 1: regs->rbx = val; break;
114 case 2: regs->rcx = val; break;
115 case 3: regs->rdx = val; break;
116 case 4: regs->rsi = val; break;
117 case 5: regs->rdi = val; break;
118 case 6: regs->rbp = val; break;
119 case 7: regs->rsp = val; break;
121 case 8: regs->r8 = val; break;
122 case 9: regs->r9 = val; break;
123 case 10: regs->r10 = val; break;
124 case 11: regs->r11 = val; break;
125 case 12: regs->r12 = val; break;
126 case 13: regs->r13 = val; break;
127 case 14: regs->r14 = val; break;
128 case 15: regs->r15 = val; break;
130 case 16: regs->rip = val; break;
131 case 17: regs->rflags = (u32)val; break;
132 case 18: regs->cs = (u16)val; break;
133 case 19: regs->ss = (u16)val; break;
134 case 20: regs->ds = (u16)val; break;
135 case 21: regs->es = (u16)val; break;
136 case 22: regs->fs = (u16)val; break;
137 case 23: regs->gs = (u16)val; break;
138 default:
139 break;
140 }
141 gdb_send_reply("OK", ctx);
142 }
144 /*
145 * Local variables:
146 * mode: C
147 * c-set-style: "BSD"
148 * c-basic-offset: 4
149 * tab-width: 4
150 * End:
151 */