Say I have some C code which goes along the lines of:
void fun_1(unsigned int *age)
[...]
int main() { unsigned int age[24]; }
In GDB, how can I find the address of age?
Finding address is as simple as:
p &age
Both age
s are not the same in case if you are not aware. One is local in main
and another is local to fun_1()
. So unless you pass the address of age
in main
to fun_1()
they are not going to have the same address. Just set a break point in main and see the address of age.
(gdb) break main
(gdb) p &age
.....
(gdb) break fun_1
(gdb) p &age
.....
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