aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/gdbstub.c
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-01-14 16:58:54 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-01-14 16:58:54 +0100
commit360a1871b545a65aed9fb2e346ecf13e7b2040d2 (patch)
tree48c657d274daf4f3792918a55b05eb0b54d8f16b /xen/arch/x86/gdbstub.c
parent843f4eb4357891dd4278ed46d7032b27282998a3 (diff)
downloadxen-360a1871b545a65aed9fb2e346ecf13e7b2040d2.tar.gz
xen-360a1871b545a65aed9fb2e346ecf13e7b2040d2.tar.bz2
xen-360a1871b545a65aed9fb2e346ecf13e7b2040d2.zip
Rename cdb to gdbstub and split it into arch dependent/neutral part.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Diffstat (limited to 'xen/arch/x86/gdbstub.c')
-rw-r--r--xen/arch/x86/gdbstub.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/xen/arch/x86/gdbstub.c b/xen/arch/x86/gdbstub.c
new file mode 100644
index 0000000000..0c34e07fd4
--- /dev/null
+++ b/xen/arch/x86/gdbstub.c
@@ -0,0 +1,146 @@
+/*
+ * x86-specific gdb stub routines
+ * based on x86 cdb(xen/arch/x86/cdb.c), but Extensively modified.
+ *
+ * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
+ * VA Linux Systems Japan. K.K.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <asm/debugger.h>
+
+u16
+gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie)
+{
+ /* XXX */
+ return 1;
+}
+
+void
+gdb_arch_read_reg_array(struct cpu_user_regs *regs, struct gdb_context *ctx)
+{
+#define GDB_REG(r) gdb_write_to_packet_hex(r, sizeof(r), ctx);
+ GDB_REG(regs->eax);
+ GDB_REG(regs->ecx);
+ GDB_REG(regs->edx);
+ GDB_REG(regs->ebx);
+ GDB_REG(regs->esp);
+ GDB_REG(regs->ebp);
+ GDB_REG(regs->esi);
+ GDB_REG(regs->edi);
+ GDB_REG(regs->eip);
+ GDB_REG(regs->eflags);
+#undef GDB_REG
+#define GDB_SEG_REG(s) gdb_write_to_packet_hex(s, sizeof(u32), ctx);
+ /* sizeof(segment) = 16bit */
+ /* but gdb requires its return value as 32bit value */
+ GDB_SEG_REG(regs->cs);
+ GDB_SEG_REG(regs->ss);
+ GDB_SEG_REG(regs->ds);
+ GDB_SEG_REG(regs->es);
+ GDB_SEG_REG(regs->fs);
+ GDB_SEG_REG(regs->gs);
+#undef GDB_SEG_REG
+ gdb_send_packet(ctx);
+}
+
+void
+gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char* buf,
+ struct gdb_context *ctx)
+{
+ /* XXX TODO */
+ gdb_send_reply("E02", ctx);
+}
+
+void
+gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
+ struct gdb_context *ctx)
+{
+ gdb_send_reply("", ctx);
+}
+
+/* Like copy_from_user, but safe to call with interrupts disabled.
+ Trust me, and don't look behind the curtain. */
+unsigned
+gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
+{
+ int __d0, __d1, __d2;
+ ASSERT(!local_irq_is_enabled());
+ __asm__ __volatile__(
+ "1: rep; movsb\n"
+ "2:\n"
+ ".section .fixup,\"ax\"\n"
+ "3: addl $4, %%esp\n"
+ " jmp 2b\n"
+ ".previous\n"
+ ".section __pre_ex_table,\"a\"\n"
+ " .align 4\n"
+ " .long 1b,3b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 4\n"
+ " .long 1b,2b\n"
+ ".previous\n"
+ : "=c"(__d2), "=D" (__d0), "=S" (__d1)
+ : "0"(len), "1"(dest), "2"(src)
+ : "memory");
+ ASSERT(!local_irq_is_enabled());
+ return __d2;
+}
+
+unsigned int
+gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
+{
+ /* XXX */
+ return len;
+}
+
+void
+gdb_arch_resume(struct cpu_user_regs *regs,
+ unsigned long addr, unsigned long type,
+ struct gdb_context *ctx)
+{
+ /* XXX */
+ if (type == GDB_STEP) {
+ gdb_send_reply("S01", ctx);
+ }
+}
+
+void
+gdb_arch_print_state(struct cpu_user_regs *regs)
+{
+ /* XXX */
+}
+
+void
+gdb_arch_enter(struct cpu_user_regs *regs)
+{
+ /* nothing */
+}
+
+void
+gdb_arch_exit(struct cpu_user_regs *regs)
+{
+ /* nothing */
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */