Run the command "backtrace full" after loading a core dump that occurred due to your NULL pointer. I guarantee that you would be able to fix your problem faster than you could with print statements. Even if you don't want to learn various gdb commands, the one command "backtrace full" will often times give you enough information to fix most issues. Just having the line number which caused the seg fault is extremely valuable. How long does it take you to narrow it down to the exact like with print statements? It takes me about 5 seconds with GDB.Meaning, the only way to know it was null was via printf. I am sure you can do that with gdb too, it is just 10x more awkward.
The best thing about GDB is that most of the time you don't even need to run your application in GDB to solve crash issues. Just load the core dump after your application crashed, and take a look at the backtrace.