Conditional Breakpoints with Pointers
Chun, Eric Y
eric.y.chun@intel.com
Mon May 4 21:12:00 GMT 2015
in gdb, how do i set a conditional breakpoint depending on value of pointer keeping in mind that i have to check if pointer is null before dereferencing pointer?
here is an example of code i'm trying to debug:
#include <iostream>
using namespace std;
int main () {
int *i[10];
int *j = NULL;
int k;
i[4] = new int;
*i[4] = 8;
for (k=0; k < 10; k++) {
j = i[k];
}
return 0;
}
i set conditional breakpoint at line "j=i[k]" but i got a seg fault:
(gdb) b 14 if j && *j == 8
(gdb) r
Starting program: /nfs/blahblah/a.out
Failed to read a valid object file image from memory.
Program received signal SIGSEGV, Segmentation fault.
does anybody know why there is a segfault?
More information about the Gdb
mailing list