When I type x/xw 0x208c
it gives me back error which says Cannot access memory at address 0x208c
The disassembly for your program says that it does something like this:
puts("some string");
int i;
scanf("%d", &i); // I don't know what the actual format string is.
// You can find out with x/s 0x8048555
if (i == 0x208c) { ... } else { ... }
In other words, the 0x208c
is a value (8332
) that your program has hard-coded in it, and is not a pointer. Therefore, GDB is entirely correct in telling you that if you interpret 0x208c
as a pointer, that pointer does not point to readable memory.
i finally figured out to use print statement instead of x/xw
You appear to not understand the difference between print
and examine
commands. Consider this example:
int foo = 42;
int *pfoo = &foo;
With above, print pfoo
will give you the address of foo
, and x pfoo
will give you the value stored at that address (i.e. the value of foo
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…