Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB, break condition, check NULL pointer

I want to set a break point, and only stop at it, when one pointer called rc is NULL.

I did like that

      b task.c:190 if rc==NULL

but gdb says, NULL would be unrecognized, so I changed to

      b task.c:190 if(!rc)

which seems worked.

But I am not very sure, correct me if I am doing wrong.

like image 623
arslan Avatar asked May 20 '14 07:05

arslan


2 Answers

try to re-compile your project with CFLAG -ggdb3, then set the break point.Or use (void *)0 instead of NULL

like image 55
MYMNeo Avatar answered Sep 20 '22 07:09

MYMNeo


NULL is a C macro whose value is set to 0 Probably the gdb is not able to resolve the macro value.

like image 32
sergico Avatar answered Sep 21 '22 07:09

sergico