diff options
author | Andreas Gunnarsson <andreas@cvs.openbsd.org> | 2003-05-18 02:43:14 +0000 |
---|---|---|
committer | Andreas Gunnarsson <andreas@cvs.openbsd.org> | 2003-05-18 02:43:14 +0000 |
commit | 061b70250f637e58737334e11c088df97d2031fa (patch) | |
tree | 85083a1d8488cc3adb892ade04fddd554fea8692 | |
parent | 24ddfeb7d4704f6599170ca32bf94706b3ca511e (diff) |
Add 'machine sysregs' command to ddb for 1386; show idtr, gdtr, ldtr, tr
and cr0-ct4
OK by niklas@ and more or less by ho@
-rw-r--r-- | sys/arch/i386/i386/db_interface.c | 53 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 3 | ||||
-rw-r--r-- | sys/arch/i386/include/db_machdep.h | 6 |
3 files changed, 59 insertions, 3 deletions
diff --git a/sys/arch/i386/i386/db_interface.c b/sys/arch/i386/i386/db_interface.c index edaa3d6fd42..c9d55df065e 100644 --- a/sys/arch/i386/i386/db_interface.c +++ b/sys/arch/i386/i386/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.11 2002/03/14 01:26:32 millert Exp $ */ +/* $OpenBSD: db_interface.c,v 1.12 2003/05/18 02:43:12 andreas Exp $ */ /* $NetBSD: db_interface.c,v 1.22 1996/05/03 19:42:00 christos Exp $ */ /* @@ -57,6 +57,7 @@ extern int trap_types; int db_active = 0; void kdbprinttrap(int, int); +void db_sysregs_cmd(db_expr_t, int, db_expr_t, char *); /* * Print trap reason. @@ -141,6 +142,56 @@ kdb_trap(type, code, regs) } void +db_sysregs_cmd(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char *modif; +{ + int64_t idtr, gdtr; + uint32_t cr; + uint16_t ldtr, tr; + + __asm__ __volatile__("sidt %0" : "=m" (idtr)); + db_printf("idtr: 0x%08x/%04x\n", + (unsigned int)(idtr >> 16), idtr & 0xffff); + + __asm__ __volatile__("sgdt %0" : "=m" (gdtr)); + db_printf("gdtr: 0x%08x/%04x\n", + (unsigned int)(gdtr >> 16), gdtr & 0xffff); + + __asm__ __volatile__("sldt %0" : "=g" (ldtr)); + db_printf("ldtr: 0x%04x\n", ldtr); + + __asm__ __volatile__("str %0" : "=g" (tr)); + db_printf("tr: 0x%04x\n", tr); + + __asm__ __volatile__("movl %%cr0,%0" : "=r" (cr)); + db_printf("cr0: 0x%08x\n", cr); + + __asm__ __volatile__("movl %%cr2,%0" : "=r" (cr)); + db_printf("cr2: 0x%08x\n", cr); + + __asm__ __volatile__("movl %%cr3,%0" : "=r" (cr)); + db_printf("cr3: 0x%08x\n", cr); + + __asm__ __volatile__("movl %%cr4,%0" : "=r" (cr)); + db_printf("cr4: 0x%08x\n", cr); +} + +struct db_command db_machine_command_table[] = { + { "sysregs", db_sysregs_cmd, 0, 0 }, + { (char *)0, } +}; + +void +db_machine_init() +{ + + db_machine_commands_install(db_machine_command_table); +} + +void Debugger() { asm("int $3"); diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 48edd5ae078..f3f4099b901 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.231 2003/05/14 22:53:59 tedu Exp $ */ +/* $OpenBSD: machdep.c,v 1.232 2003/05/18 02:43:12 andreas Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2442,6 +2442,7 @@ init386(paddr_t first_avail) #endif #ifdef DDB + db_machine_init(); ddb_init(); if (boothowto & RB_KDB) Debugger(); diff --git a/sys/arch/i386/include/db_machdep.h b/sys/arch/i386/include/db_machdep.h index 724ec0630fb..69fb1d2cb30 100644 --- a/sys/arch/i386/include/db_machdep.h +++ b/sys/arch/i386/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.h,v 1.8 2003/04/17 03:42:14 drahn Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.9 2003/05/18 02:43:13 andreas Exp $ */ /* $NetBSD: db_machdep.h,v 1.9 1996/05/03 19:23:59 christos Exp $ */ /* @@ -91,6 +91,8 @@ boolean_t db_check_access(vaddr_t, int, task_t); boolean_t db_phys_eq(task_t, vaddr_t, task_t, vaddr_t); #endif +#define DB_MACHINE_COMMANDS + /* macros for printing OS server dependent task name */ #define DB_TASK_NAME(task) db_task_name(task) @@ -117,4 +119,6 @@ void db_task_name(/* task_t */); int kdb_trap(int, int, db_regs_t *); +void db_machine_init(void); + #endif /* _I386_DB_MACHDEP_H_ */ |