From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: [PATCH 4/7] gdbstub for x86-64 Date: Fri, 03 Nov 2006 00:29:09 -0600 Message-ID: <454AE1B5.7010208@cs.utexas.edu> References: <454AE007.5070905@cs.utexas.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000307050608040209060909" Return-path: To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org In-Reply-To: <454AE007.5070905-NZpS4cJIG2HvQtjrzfazuQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org This is a multi-part message in MIME format. --------------000307050608040209060909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This is from Avi's original patch. Enables gdbstub for x86-64. Regards, Anthony Liguori --------------000307050608040209060909 Content-Type: text/x-patch; name="gdbstubs-x86_64.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdbstubs-x86_64.diff" diff -r 439455affc9a gdbstub.c --- a/gdbstub.c Thu Nov 02 19:13:52 2006 -0600 +++ b/gdbstub.c Thu Nov 02 19:14:35 2006 -0600 @@ -185,7 +185,141 @@ static int put_packet(GDBState *s, char return 0; } -#if defined(TARGET_I386) +#if defined(TARGET_X86_64) + +static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) +{ + uint8_t *p = mem_buf; + int i, fpus; + +#define PUTREG(x) do { \ + target_ulong reg = tswapl(x); \ + memcpy(p, ®, sizeof reg); \ + p += sizeof reg; \ + } while (0) +#define PUTREG32(x) do { \ + uint32_t reg = tswap32(x); \ + memcpy(p, ®, sizeof reg); \ + p += sizeof reg; \ + } while (0) +#define PUTREGF(x) do { \ + memcpy(p, &(x), 10); \ + p += sizeof (x); \ + } while (0) + + PUTREG(env->regs[R_EAX]); + PUTREG(env->regs[R_EBX]); + PUTREG(env->regs[R_ECX]); + PUTREG(env->regs[R_EDX]); + PUTREG(env->regs[R_ESI]); + PUTREG(env->regs[R_EDI]); + PUTREG(env->regs[R_EBP]); + PUTREG(env->regs[R_ESP]); + PUTREG(env->regs[8]); + PUTREG(env->regs[9]); + PUTREG(env->regs[10]); + PUTREG(env->regs[11]); + PUTREG(env->regs[12]); + PUTREG(env->regs[13]); + PUTREG(env->regs[14]); + PUTREG(env->regs[15]); + + PUTREG(env->eip); + PUTREG32(env->eflags); + PUTREG32(env->segs[R_CS].selector); + PUTREG32(env->segs[R_SS].selector); + PUTREG32(env->segs[R_DS].selector); + PUTREG32(env->segs[R_ES].selector); + PUTREG32(env->segs[R_FS].selector); + PUTREG32(env->segs[R_GS].selector); + /* XXX: convert floats */ + for(i = 0; i < 8; i++) { + PUTREGF(env->fpregs[i]); + } + PUTREG32(env->fpuc); + fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; + PUTREG32(fpus); + PUTREG32(0); /* XXX: convert tags */ + PUTREG32(0); /* fiseg */ + PUTREG32(0); /* fioff */ + PUTREG32(0); /* foseg */ + PUTREG32(0); /* fooff */ + PUTREG32(0); /* fop */ + +#undef PUTREG +#undef PUTREG32 +#undef PUTREGF + + return p - mem_buf; +} + +static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) +{ + uint8_t *p = mem_buf; + uint32_t junk; + int i, fpus; + +#define GETREG(x) do { \ + target_ulong reg; \ + memcpy(®, p, sizeof reg); \ + x = tswapl(reg); \ + p += sizeof reg; \ + } while (0) +#define GETREG32(x) do { \ + uint32_t reg; \ + memcpy(®, p, sizeof reg); \ + x = tswap32(reg); \ + p += sizeof reg; \ + } while (0) +#define GETREGF(x) do { \ + memcpy(&(x), p, 10); \ + p += 10; \ + } while (0) + + GETREG(env->regs[R_EAX]); + GETREG(env->regs[R_EBX]); + GETREG(env->regs[R_ECX]); + GETREG(env->regs[R_EDX]); + GETREG(env->regs[R_ESI]); + GETREG(env->regs[R_EDI]); + GETREG(env->regs[R_EBP]); + GETREG(env->regs[R_ESP]); + GETREG(env->regs[8]); + GETREG(env->regs[9]); + GETREG(env->regs[10]); + GETREG(env->regs[11]); + GETREG(env->regs[12]); + GETREG(env->regs[13]); + GETREG(env->regs[14]); + GETREG(env->regs[15]); + + GETREG(env->eip); + GETREG32(env->eflags); + GETREG32(env->segs[R_CS].selector); + GETREG32(env->segs[R_SS].selector); + GETREG32(env->segs[R_DS].selector); + GETREG32(env->segs[R_ES].selector); + GETREG32(env->segs[R_FS].selector); + GETREG32(env->segs[R_GS].selector); + /* XXX: convert floats */ + for(i = 0; i < 8; i++) { + GETREGF(env->fpregs[i]); + } + GETREG32(env->fpuc); + GETREG32(fpus); /* XXX: convert fpus */ + GETREG32(junk); /* XXX: convert tags */ + GETREG32(junk); /* fiseg */ + GETREG32(junk); /* fioff */ + GETREG32(junk); /* foseg */ + GETREG32(junk); /* fooff */ + GETREG32(junk); /* fop */ + +#undef GETREG +#undef GETREG32 +#undef GETREGF +} + +#elif defined(TARGET_I386) static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) { --------------000307050608040209060909 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 --------------000307050608040209060909 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --------------000307050608040209060909--