Update the gdb register extraction support to use the pcb wherever

possible, like on i386.  Registers are handled differently for caller
vs callee saved registers.
This commit is contained in:
Peter Wemm 2004-11-30 00:55:49 +00:00
parent 1114f4f9a2
commit a649898dd8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138212

View File

@ -36,39 +36,46 @@ __FBSDID("$FreeBSD$");
#include <machine/frame.h>
#include <machine/gdb_machdep.h>
#include <machine/pcb.h>
#include <machine/psl.h>
#include <machine/reg.h>
#include <machine/trap.h>
#include <machine/frame.h>
#include <machine/endian.h>
#include <gdb/gdb.h>
void *
gdb_cpu_getreg(int regnum, size_t *regsz)
{
struct trapframe *tf = kdb_frame;
*regsz = gdb_cpu_regsz(regnum);
if (kdb_thread == curthread) {
switch (regnum) {
case 0: return (&kdb_frame->tf_rax);
case 2: return (&kdb_frame->tf_rcx);
case 3: return (&kdb_frame->tf_rdx);
case 4: return (&kdb_frame->tf_rsi);
case 5: return (&kdb_frame->tf_rdi);
case 8: return (&kdb_frame->tf_r8);
case 9: return (&kdb_frame->tf_r9);
case 10: return (&kdb_frame->tf_r10);
case 11: return (&kdb_frame->tf_r11);
case 18: return (&kdb_frame->tf_cs);
case 19: return (&kdb_frame->tf_ss);
}
}
switch (regnum) {
case 0: return (&tf->tf_rax);
case 1: return (&tf->tf_rbx);
case 2: return (&tf->tf_rcx);
case 3: return (&tf->tf_rdx);
case 4: return (&tf->tf_rsi);
case 5: return (&tf->tf_rdi);
case 6: return (&tf->tf_rbp);
case 7: return (&tf->tf_rsp);
case 8: return (&tf->tf_r8);
case 9: return (&tf->tf_r9);
case 10: return (&tf->tf_r10);
case 11: return (&tf->tf_r11);
case 12: return (&tf->tf_r12);
case 13: return (&tf->tf_r13);
case 14: return (&tf->tf_r14);
case 15: return (&tf->tf_r15);
case 16: return (&tf->tf_rip);
case 17: return (&tf->tf_rflags);
case 18: return (&tf->tf_cs);
case 19: return (&tf->tf_ss);
case 1: return (&kdb_thrctx->pcb_rbx);
case 6: return (&kdb_thrctx->pcb_rbp);
case 7: return (&kdb_thrctx->pcb_rsp);
case 12: return (&kdb_thrctx->pcb_r12);
case 13: return (&kdb_thrctx->pcb_r13);
case 14: return (&kdb_thrctx->pcb_r14);
case 15: return (&kdb_thrctx->pcb_r15);
case 16: return (&kdb_thrctx->pcb_rip);
case 17: return (&kdb_thrctx->pcb_rflags);
}
return (NULL);
}
@ -76,9 +83,12 @@ gdb_cpu_getreg(int regnum, size_t *regsz)
void
gdb_cpu_setreg(int regnum, register_t val)
{
struct trapframe *tf = kdb_frame;
val = __bswap64(val);
switch (regnum) {
case GDB_REG_PC: tf->tf_rip = val; break;
case GDB_REG_PC:
kdb_thrctx->pcb_rip = val;
if (kdb_thread == curthread)
kdb_frame->tf_rip = val;
}
}