ndk-gdb variable address shifted

Started by
5 comments, last by PolarWolf 8 years, 4 months ago

I was debugging an android program using ndk-gdb,in Android Studio i got a variable's true address 0x5a1f2e24, while in ndk-gdb, the variable's address printed became 0x5a1f2d24, 256 bytes less than it's true address, how can it happen. I am new to ndk, any advice is appreciated.

Advertisement

Variables move between runs.

Variables on the stack are created wherever the stack happens to be. The stack position moves every time a function is called.

Variables on the heap are created wherever the system assigns them to be, and this is likely to be different every run of the program.

Now if you detached one debugger then attached the other without stopping/restarting the program then it would be a different instance of the variable or something fishy going on.

While i printed the variable's value with p *(int*)0x5a1f2e24, the result is right, even though i restarted the program,so i am sure the variable's address shifted 256 bytes.

Yes, if you restart the program variables will get different addresses. That is normal.

I mean i restarted the program,and it's address was still 0x5a1f2e24.btw this variable is declared in main function,it's address won't change during execution.

I am sure the address in ndk-gdb has shifted 256 bytes from true address.

Finally i found the problem, i used the lib of armeabi for debugging,but armeabi-v7a is the reight one.

This topic is closed to new replies.

Advertisement