Reputation: 419
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?
Upvotes: 10
Views: 18463
Reputation: 121347
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
.....
Upvotes: 7