Debug and control registers in kdb.
- From: stas.ibragimov@xxxxxxxxx
- Date: Wed, 2 May 2007 02:17:48 +0400
Hello everybody.
In ddb(4) we can read/write only cs-ss,eax-edx,esp,ebp,esi,edi,eip and efl registers of CPU?
Why not implemented reding/writing to the dr0-dr7 and cr0-cr4 registers?
In attach there are small patch, that implements it.
*** db_trace.c.org Wed May 2 00:12:22 2007
--- db_trace.c Wed May 2 01:04:01 2007
***************
*** 59,64 ****
--- 59,69 ----
static db_varfcn_t db_esp;
static db_varfcn_t db_frame;
static db_varfcn_t db_ss;
+ static db_varfcn_t db_cr0;
+ static db_varfcn_t db_cr1;
+ static db_varfcn_t db_cr2;
+ static db_varfcn_t db_cr3;
+ static db_varfcn_t db_cr4;
/*
* Machine register set.
***************
*** 88,95 ****
{ "dr5", NULL, db_dr5 },
{ "dr6", NULL, db_dr6 },
{ "dr7", NULL, db_dr7 },
! #define DB_N_SHOW_REGS 23 /* Don't show registers after here. */
};
struct db_variable *db_eregs = db_regs + DB_N_SHOW_REGS;
--- 93,105 ----
{ "dr5", NULL, db_dr5 },
{ "dr6", NULL, db_dr6 },
{ "dr7", NULL, db_dr7 },
+ { "cr0", NULL, db_cr0 },
+ { "cr1", NULL, db_cr1 },
+ { "cr2", NULL, db_cr2 },
+ { "cr3", NULL, db_cr3 },
+ { "cr4", NULL, db_cr4 },
! #define DB_N_SHOW_REGS 28 /* Don't show registers after here. */
};
struct db_variable *db_eregs = db_regs + DB_N_SHOW_REGS;
***************
*** 106,111 ****
--- 116,122 ----
load_ ## reg (*valuep); \
return (1); \
}
+
DB_DRX_FUNC(dr0)
DB_DRX_FUNC(dr1)
DB_DRX_FUNC(dr2)
***************
*** 114,119 ****
--- 125,135 ----
DB_DRX_FUNC(dr5)
DB_DRX_FUNC(dr6)
DB_DRX_FUNC(dr7)
+ DB_DRX_FUNC(cr0)
+ DB_DRX_FUNC(cr1)
+ DB_DRX_FUNC(cr2)
+ DB_DRX_FUNC(cr3)
+ DB_DRX_FUNC(cr4)
static __inline int
get_esp(struct trapframe *tf)
*** cpufunc.h.org Wed May 2 01:57:40 2007
--- cpufunc.h Wed May 2 01:18:31 2007
***************
*** 388,394 ****
--- 388,414 ----
}
+ static __inline void
+ load_cr1(u_int data)
+ {
+ __asm __volatile("movl %0,%%cr1" : : "r" (data));
+ }
+ static __inline u_int
+ rcr1(void)
+ {
+ u_int data;
+
+ __asm __volatile("movl %%cr1,%0" : "=r" (data));
+ return (data);
+ }
+
+ static __inline void
+ load_cr2(u_int data)
+ {
+
+ __asm __volatile("movl %0,%%cr2" : : "r" (data));
+ }
static __inline u_int
rcr2(void)
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Debug and control registers in kdb.
- From: John Baldwin
- Re: Debug and control registers in kdb.
- Prev by Date: Re: Mono XSP & mod_mono support on FreeBSD
- Next by Date: how to configure mail server by freebsd 4.11
- Previous by thread: Re: Mono XSP & mod_mono support on FreeBSD
- Next by thread: Re: Debug and control registers in kdb.
- Index(es):