From: Jason Wessel <jason.wessel@windriver.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] x86_64 debug registers for gdb
Date: Tue, 19 Sep 2006 15:51:48 -0500 [thread overview]
Message-ID: <45105864.9090902@windriver.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
This patch fixes the registers for the 'g' and 'G' packets for the
qemu-system-x86_64 target. It allows gdb 6.5 to debug a linux kernel
and get a stack back trace.
signed-off-by: jason.wessel@windriver.com
Thanks,
Jason.
[-- Attachment #2: x86-64_gdb.patch --]
[-- Type: text/plain, Size: 2151 bytes --]
Index: qemu/gdbstub.c
===================================================================
--- qemu.orig/gdbstub.c
+++ qemu/gdbstub.c
@@ -184,9 +184,70 @@ static int put_packet(GDBState *s, char
}
return 0;
}
+#if defined(TARGET_X86_64)
+/* Defines from GDB register struct numbers */
+#define _RAX 0
+#define _RDX 1
+#define _RCX 2
+#define _RBX 3
+#define _RSI 4
+#define _RDI 5
+#define _RBP 6
+#define _RSP 7
+#define _R8 8
+#define _R9 9
+#define _R10 10
+#define _R11 11
+#define _R12 12
+#define _R13 13
+#define _R14 14
+#define _R15 15
+#define _PC 16
+#define _PS 17
-#if defined(TARGET_I386)
+static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
+{
+ uint64_t *registers = (uint64_t *)mem_buf;
+ int i;
+
+ registers[_RAX] = env->regs[R_EAX];
+ registers[_RBX] = env->regs[R_EBX];
+ registers[_RCX] = env->regs[R_ECX];
+ registers[_RDX] = env->regs[R_EDX];
+ registers[_RSI] = env->regs[R_ESI];
+ registers[_RDI] = env->regs[R_EDI];
+ registers[_RBP] = env->regs[R_EBP];
+ registers[_RSP] = env->regs[R_ESP];
+ for (i = 8; i < 16; i++)
+ registers[i] = env->regs[i];
+ registers[_PC] = env->eip;
+ registers[_PS] = env->eflags;
+ for(i = 0; i < 18; i++)
+ tswapl(registers[i]);
+
+ return 18 * 8;
+}
+
+static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
+{
+ uint32_t *registers = (uint32_t *)mem_buf;
+ int i;
+
+ env->regs[R_EAX] = tswapl(registers[_RAX]);
+ env->regs[R_EBX] = tswapl(registers[_RBX]);
+ env->regs[R_ECX] = tswapl(registers[_RCX]);
+ env->regs[R_EDX] = tswapl(registers[_RDX]);
+ env->regs[R_ESI] = tswapl(registers[_RSI]);
+ env->regs[R_EDI] = tswapl(registers[_RDI]);
+ env->regs[R_EBP] = tswapl(registers[_RBP]);
+ env->regs[R_ESP] = tswapl(registers[_RSP]);
+ for (i = 8; i < 16; i++)
+ env->regs[i] = tswapl(registers[i]);
+ env->eip = tswapl(registers[_PC]);
+ env->eflags = tswapl(registers[_PS]);
+}
+#elif defined(TARGET_I386)
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
{
uint32_t *registers = (uint32_t *)mem_buf;
next reply other threads:[~2006-09-19 20:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-19 20:51 Jason Wessel [this message]
2007-04-18 20:53 ` [Qemu-devel] Re: [PATCH] x86_64 debug registers for gdb Jan Kiszka
2007-04-19 15:11 ` Paul Brook
2007-04-19 21:30 ` Jan Kiszka
2007-04-20 12:55 ` Paul Brook
2007-04-20 22:15 ` Jan Kiszka
2007-04-20 23:13 ` Paul Brook
2007-04-21 17:45 ` Jan Kiszka
2007-04-23 9:13 ` Jan Kiszka
2007-04-23 15:47 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45105864.9090902@windriver.com \
--to=jason.wessel@windriver.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.