Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
thethunderingcolt
PostPosted: Dec 17, 2011 - 02:11 AM
Wannabe


Joined: Dec 03, 2010
Posts: 70


When I am setting breakpoints during debugging.....
many times I get the message in the watch window that a variable is 'INVALID LOCATION'.....
(and, I can't see it.....)

Is there a method to avoid this?
I remember in the past, I was able to turn of the compiler optimization...and it fixed them...
but, I have tried it now, and it does not.
(plus...I have no room in my AVR for non-optimized code...)

I'd really like to step thru the code and examine various variables as it runs on my target.

Any advice?
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Dec 17, 2011 - 03:05 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20325
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
Is there a method to avoid this?
May try and declare the variables as volatile for the time being.

But you can simply go to the disassembly view and see which registers are being used for the variables.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Dec 17, 2011 - 10:59 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62220
Location: (using avr-gcc in) Finchingfield, Essex, England

I wrote this for you:

Optimization and the importance of volatile in GCC

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Dec 17, 2011 - 02:14 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18522
Location: Lund, Sweden

Read Cliffs article.

Still, the short answer is "you can't have the cake and eat it". By definition the optimizer mangles the generated assembly around so that it does not map line-by-line to the source code. This in turn leads to stepping through it as you want is not possible.

We understand that you want to debug this way. It would have been comfortable - had it been possible. We've all been there. And we've realized that for some debugging purposes there is only one way: Learn how to read assembler, and debug on that level.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
thethunderingcolt
PostPosted: Dec 17, 2011 - 08:10 PM
Wannabe


Joined: Dec 03, 2010
Posts: 70


Wow...Clawson....you....are astounding.
Razz
 
 View user's profile Send private message  
Reply with quote Back to top
thethunderingcolt
PostPosted: Dec 17, 2011 - 08:11 PM
Wannabe


Joined: Dec 03, 2010
Posts: 70


..and, Johan......you, too...buddy!!!!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits