Jump to content
  • Advertisement
Sign in to follow this  
PolarWolf

ndk-gdb variable address shifted

This topic is 1049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!