diff --git a/sys/amd64/amd64/gdb_machdep.c b/sys/amd64/amd64/gdb_machdep.c index 820824b1731a..770e9038e4e9 100644 --- a/sys/amd64/amd64/gdb_machdep.c +++ b/sys/amd64/amd64/gdb_machdep.c @@ -36,39 +36,46 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include +#include +#include #include 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; } }