diff options
author | julian <julian@FreeBSD.org> | 2004-09-15 23:26:49 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2004-09-15 23:26:49 +0000 |
commit | 3f6dedb4491a725e1face028b6a4981d67e12595 (patch) | |
tree | 5b245475895d0e6c725672021bb28e839b74d0c1 | |
parent | 2188870a35a8ab3655b1bd5fe2128ba88f51d304 (diff) | |
download | FreeBSD-src-3f6dedb4491a725e1face028b6a4981d67e12595.zip FreeBSD-src-3f6dedb4491a725e1face028b6a4981d67e12595.tar.gz |
Fix breakpoint handling for i386.
not sure yet about 5.x... MFC if needed.
Also fixes small problems with examining some registers and
some specific gdb transfer problems.
As the patch says:
This is not a pretty patch and only meant as a temporary
fix until a better solution is committed.
PR: i386/71715
Submitted by: Stephan Uphoff <ups@tree.com>
MFC after: 1 week
-rw-r--r-- | sys/i386/i386/gdb_machdep.c | 16 | ||||
-rw-r--r-- | sys/i386/include/db_machdep.h | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/sys/i386/i386/gdb_machdep.c b/sys/i386/i386/gdb_machdep.c index 81df8d1..836b13e 100644 --- a/sys/i386/i386/gdb_machdep.c +++ b/sys/i386/i386/gdb_machdep.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include <machine/gdb_machdep.h> #include <machine/pcb.h> #include <machine/trap.h> +#include <machine/frame.h> +#include <machine/endian.h> #include <gdb/gdb.h> @@ -45,6 +47,14 @@ gdb_cpu_getreg(int regnum, size_t *regsz) { *regsz = gdb_cpu_regsz(regnum); + + if (kdb_thread == curthread) { + switch (regnum) { + case 0: return (&kdb_frame->tf_eax); + case 1: return (&kdb_frame->tf_ecx); + case 2: return (&kdb_frame->tf_edx); + } + } switch (regnum) { case 3: return (&kdb_thrctx->pcb_ebx); case 4: return (&kdb_thrctx->pcb_esp); @@ -60,8 +70,12 @@ void gdb_cpu_setreg(int regnum, register_t val) { + val = __bswap32(val); switch (regnum) { - case GDB_REG_PC: kdb_thrctx->pcb_eip = val; break; + case GDB_REG_PC: + kdb_thrctx->pcb_eip = val; + if (kdb_thread == curthread) + kdb_frame->tf_eip = val; } } diff --git a/sys/i386/include/db_machdep.h b/sys/i386/include/db_machdep.h index 6922908..567f3ce 100644 --- a/sys/i386/include/db_machdep.h +++ b/sys/i386/include/db_machdep.h @@ -41,9 +41,17 @@ typedef int db_expr_t; /* expression - signed */ #define BKPT_SIZE (1) /* size of breakpoint inst */ #define BKPT_SET(inst) (BKPT_INST) -#define BKPT_SKIP kdb_frame->tf_eip += 1 +#define BKPT_SKIP \ +do { \ + kdb_frame->tf_eip += 1; \ + kdb_thrctx->pcb_eip += 1; \ +} while(0) -#define FIXUP_PC_AFTER_BREAK kdb_frame->tf_eip -= 1; +#define FIXUP_PC_AFTER_BREAK \ +do { \ + kdb_frame->tf_eip -= 1; \ + kdb_thrctx->pcb_eip -= 1; \ +} while(0); #define db_clear_single_step kdb_cpu_clear_singlestep #define db_set_single_step kdb_cpu_set_singlestep |