Problem with manual watchpoints

Aravinda aravindakidambi@gmail.com
Thu Dec 24 20:47:00 GMT 2009


Hi,

Im facing a very wierd problem. Its nothing to do with GDB, but i was
just wondering if theres something about 'hardware watchpoints' im
missing here.

I have a kernel module that can add watchpoints for a process. The
module can be invoked by __add_watchpoint(pid, address).
I wrote the program below to test the module. In the below program, I
have allocated a buffer 'a' and access 'a[0], a[1] .... a[25]'. I have
the address of a[20] loaded in one of the debug register.

a = malloc(20);
__add_watchpoint(getpid(), &a[20]);

for (i = 0; i < 25; i ++) {
	/* getc(stdin); ----> without this, no SIGTRAP is getting generated */
	printf("Accessing now %x\n", &a[i]);
	a[i]++;
}

While I expect the program to be interrupted by a tracepoint exception
on accessing a[20], it actually does not. It runs to completion
without catching any trap exception. However, if I just add a
'getc(stdin)' before accessing every element, it does get the
exception on accessing a[20].

Does anyone know what could be going on ?

Thanks,
Aravinda



More information about the Gdb mailing list