Reputation: 25558
I'm debugging a program with GDB.
unsigned int example = ~0;
gives me:
(gdb) x/4bt example
0xffd99788: 10101000 10010111 11011001 11111111
why is this not all 1's? i defined it as ~0... then the next line of code is:
example>>=(31);
and GDB gives me this when I try to examine the memory at bits:
(gdb) x/4bt example
0xffffffff: Cannot access memory at address 0xffffffff
what is going on???
Upvotes: 4
Views: 857
Reputation: 79820
I haven't checked the gdb command format but looking at the last statement it seems like you want to see what is at the address stored in example
instead of printing example
... it seems that example
is all 1s
(0xffffffff
) and you are trying to look at that location in memory when you get the error.
Upvotes: 0
Reputation: 29174
I think that the x
command examines memory, so example
would be interpreted as pointer. Try
x/4bt &example
or simply
print /x example
Upvotes: 5
Reputation: 6018
You need to take the address of example in the gdb statement:
(gdb) x/4bt &example
Upvotes: 8