tags:

views:

72

answers:

1

I have a bug where a char pointer is turning out NULL. I've been all over gdb with the program, watching read/write at the memory address, and stepping through the instructions, but so far the bug stumps me. I've ran valgrind and the only thing coming up is the read at the crash (strcmp). What else can I do to track this down?

+8  A: 

You can try a watchpoint. You watch an expression and when the value of that expression changes, gdb will stop execution.

You can watch a variable:

watch charptr

This will break every time charptr changes. If you just wanted to know when it changes from non-NULL to NULL (or vice versa), you can use:

watch charptr == 0
R Samuel Klatchko
That got it! I didn't realize I could watch the variable. I was only watching addresses. :) Thanks, man.
Scott