Hi all,
I have the following code:
#include <stdlib.h>
#include <stdio.h>
#define SIZE 100
int* arr;
main()
{
int i;
arr = (int*)malloc(SIZE*sizeof(int));
if (arr == NULL) {
printf("Could not allocate SIZE(=%d)", SIZE);
}
for (i=0; i<SIZE; i++) {
arr[i] = 0;
}
free(arr);
}
I wan't to watch for arr[10]
and see when that array element is being modified.
How can I do this? gdb says the following:
$ gcc -g main.c
$ gdb a.out
...
(gdb) watch arr[10]
Cannot access memory at address 0x28
Is there a way to tell gdb to watch an invalid memory and stop only when it becomes valid?
PS: I have gdb versions 6.0, 6.3, 6.4, 6.6, 6.8, 7.0 and 7.1
Thanks