Scott
Scott

Reputation: 5263

What can I do to track this bug down?

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?

Upvotes: 1

Views: 101

Answers (1)

R Samuel Klatchko
R Samuel Klatchko

Reputation: 76541

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

Upvotes: 8

Related Questions