Date: Sun, 25 Apr 2004 14:05:16 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 51729 for review Message-ID: <200404252105.i3PL5G0d064267@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=51729 Change 51729 by marcel@marcel_sledge on 2004/04/25 14:05:13 Implement gdb_cpu_getreg() and gdb_cpu_regsz() accordingly. Don't implement gdb_cpu_signal() the same as on i386. It's a mistake to translate trap types to signal numbers. Affected files ... .. //depot/projects/gdb/sys/amd64/amd64/gdb_machdep.c#2 edit .. //depot/projects/gdb/sys/amd64/include/gdb_machdep.h#3 edit Differences ... ==== //depot/projects/gdb/sys/amd64/amd64/gdb_machdep.c#2 (text+ko) ==== @@ -29,7 +29,9 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/kdb.h> #include <sys/kernel.h> +#include <sys/proc.h> #include <sys/signal.h> #include <machine/frame.h> @@ -40,73 +42,43 @@ #include <gdb/gdb.h> -uintmax_t -gdb_cpu_getreg(int regnum, struct trapframe *tf) +void * +gdb_cpu_getreg(int regnum, size_t *regsz) { + struct trapframe *tf = kdb_frame; + + *regsz = gdb_cpu_regsz(regnum); switch (regnum) { - case GDB_REG_FP: return ((unsigned int)tf->tf_ebp); - case GDB_REG_PC: return ((unsigned int)tf->tf_eip); - case GDB_REG_SP: return ((unsigned int)tf->tf_esp); + 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); } - return (0); + return (NULL); } -ssize_t -gdb_cpu_getregs(struct trapframe *tf, void *buf, size_t bufsz) +void +gdb_cpu_setreg(int regnum, register_t val) { - struct reg *r = buf; - - if (sizeof(*r) > bufsz) - return (-1); - r->r_cs = tf->tf_cs; - r->r_ds = tf->tf_ds; - r->r_eax = tf->tf_eax; - r->r_ebp = tf->tf_ebp; - r->r_ebx = tf->tf_ebx; - r->r_ecx = tf->tf_ecx; - r->r_edi = tf->tf_edi; - r->r_edx = tf->tf_edx; - r->r_eflags = tf->tf_eflags; - r->r_eip = tf->tf_eip; - r->r_es = tf->tf_es; - r->r_esi = tf->tf_esi; - r->r_esp = tf->tf_esp; - r->r_fs = tf->tf_fs; - r->r_gs = 0; - r->r_ss = tf->tf_ss; - return (sizeof(*r)); -} + struct trapframe *tf = kdb_frame; -int -gdb_cpu_regsz(int regnum) -{ - return (4); /* XXX not really. */ -} - -void -gdb_cpu_setreg(int regnum, struct trapframe *tf, uintmax_t val) -{ switch (regnum) { - case GDB_REG_FP: tf->tf_ebp = val; break; - case GDB_REG_PC: tf->tf_eip = val; break; - case GDB_REG_SP: tf->tf_esp = val; break; + case GDB_REG_PC: tf->tf_rip = val; break; } } - -int -gdb_cpu_signal(int type, int code) -{ - return (type & ~T_USER); -} - -void -gdb_cpu_singlestep(int on, struct trapframe *tf) -{ - tf->tf_eflags &= ~PSL_T; - tf->tf_eflags |= (on) ? PSL_T : 0; -} - -void -gdb_cpu_trap(int type, int code, struct trapframe *tf) -{ -} ==== //depot/projects/gdb/sys/amd64/include/gdb_machdep.h#3 (text+ko) ==== @@ -29,14 +29,20 @@ #ifndef _MACHINE_GDB_MACHDEP_H_ #define _MACHINE_GDB_MACHDEP_H_ -#define GDB_BUFSZ 400 -#define GDB_NREGS 14 -#define GDB_REG_PC 8 +#define GDB_BUFSZ 500 +#define GDB_NREGS 56 +#define GDB_REG_PC 18 static __inline size_t -gdb_cpu_regsz(int regnum __unused) +gdb_cpu_regsz(int regnum) +{ + return ((regnum > 16 && regnum < 24) ? 4 : 8); +} + +static __inline int +gdb_cpu_signal(int type, int code __unused) { - return (sizeof(int)); + return (type); } static __inline int @@ -47,6 +53,5 @@ void *gdb_cpu_getreg(int, size_t *); void gdb_cpu_setreg(int, register_t); -int gdb_cpu_signal(int, int); #endif /* !_MACHINE_GDB_MACHDEP_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404252105.i3PL5G0d064267>