This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Problem with manual watchpoints
- From: Aravinda <aravindakidambi at gmail dot com>
- To: gdb at sourceware dot org
- Date: Thu, 24 Dec 2009 15:47:06 -0500
- Subject: Problem with manual watchpoints
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