What should I do if I want to use identifier NULL
in gdb
's call statement?
Is it because I didn't include stdio.h in gdb?
I have tried : call #include <stdio.h>
but this doesn't seem to work.
NULL
is a C define, defined somewhere as:
#define NULL ((void *) 0)
NULL
is replaced by the C pre-processor to be ((void *) 0)
. So it's never passed to the compiler, so you can not use it in gdb
.
So do as Jester suggested, and just use (void *) 0
.
Just use 0
or (void*)0
. Nothing fancy.
Current GCC and GDB can see defines, but you must compile with -ggdb3
, -g
is not enough.
Input program:
#include <stdio.h>
#define ABC 123
int main() {
return 0;
}
GDB:
# start is required.
start
print ABC
print NULL
Output:
$1 = 123
$2 = (void *) 0x0
Tested with GCC 4.8 and GDB 7.7.1 on Ubuntu 14.04.
See also: How do I print a #defined constant in GDB?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With