Debug registers on FreeBSD
Anderson Eduardo
anderson_underground at hotmail.com
Thu Feb 18 04:19:37 UTC 2010
Hello Folks,
First, I'm starting in the world of the debugging FreeBSD Kernel and, I don't know to use kgdb and ddb properly and, I need set breakpoints using debug register. Those breakpoints in the all tasks.
Second, I'm reading some articles about Debug Registers on Intel Architecture and, I'm using AMD processors.
Third, It's only the begin of the my questions.
Sorry my poor English.
TIA
Follow in attached a old C file that I coded.
_________________________________________________________________
Quer deixar seus vídeos mais divertidos? Com o Movie Maker isso fica fácil.
http://www.windowslive.com.br/public/tip.aspx/view/87?product=4&ocid=Windows Live:Dicas - Movie Maker:Hotmail:Tagline:1x1:Titulo Legendas Creditos
-------------- next part --------------
#include <sys/kenv.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/syscall.h>
#include <sys/sysproto.h>
static int my_function(void)
{
unsigned int r_dr0,r_dr1,r_dr2,r_dr3,r_dr4,r_dr5,r_dr6,r_dr7;
long *w_dr0,*w_dr1,*w_dr4,*w_dr5;
w_dr0 = 0x2815dc7c;
w_dr1 = 0x280e7294;
w_dr4 = 0xffff4ff2
w_dr5 = 0x400;
/*
DR0 = 0x2815dc7c
DR1 = 0x280e7294
DR2 = 0x0
DR3 = 0x0
DR4 = 0xffff4ff2
DR5 = 0x400
DR6 = 0xffff4ff2
DR7 = 0x400
*/
__asm__ __volatile("mov %0,%%dr0": :"a"( w_dr0 ));
__asm__ __volatile("mov %0,%%dr1": :"a"( w_dr1 ));
__asm__ __volatile("mov %0,%%dr4": :"a"( w_dr4 ));
__asm__ __volatile("mov %0,%%dr5": :"a"( w_dr5 ));
__asm__ __volatile("mov %%dr0,%0": "=a"( r_dr0 ));
__asm__ __volatile("mov %%dr1,%0": "=a"( r_dr1 ));
__asm__ __volatile("mov %%dr2,%0": "=a"( r_dr2 ));
__asm__ __volatile("mov %%dr3,%0": "=a"( r_dr3 ));
__asm__ __volatile("mov %%dr4,%0": "=a"( r_dr4 ));
__asm__ __volatile("mov %%dr5,%0": "=a"( r_dr5 ));
__asm__ __volatile("mov %%dr6,%0": "=a"( r_dr6 ));
__asm__ __volatile("mov %%dr7,%0": "=a"( r_dr7 ));
uprintf("DR0 = 0x%x\n",r_dr0);
uprintf("DR1 = 0x%x\n",r_dr1);
uprintf("DR2 = 0x%x\n",r_dr2);
uprintf("DR3 = 0x%x\n",r_dr3);
uprintf("DR4 = 0x%x\n",r_dr4);
uprintf("DR5 = 0x%x\n",r_dr5);
uprintf("DR6 = 0x%x\n",r_dr6);
uprintf("DR7 = 0x%x\n",r_dr7);
return 0;
}
static int load(struct module *module, int cmd, char *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD:
my_function();
break;
case MOD_UNLOAD:
break;
default:
error = EOPNOTSUPP;
break;
}
return(error);
}
static moduledata_t DR_FreeBSD_mod = {
"DR_FreeBSD", /* module name */
(modeventhand_t)load, /* event handler */
NULL /* extra data */
};
DECLARE_MODULE(DR_FreeBSD, DR_FreeBSD_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
More information about the freebsd-hackers
mailing list