Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic RESOLVED: Statements are optimized away despite "No Optimization" (Read 1147 times)
cfeied
Junior Member
**
Offline


Posts: 49
Joined: May 18th, 2016
RESOLVED: Statements are optimized away despite "No Optimization"
Dec 24th, 2021 at 8:51pm
Print Post  
Hi, I'm running GDB on Teensy3.6 Dual Serial mode. I'm having problems with breakpoints when testing the TeensyDebug library example gdb.ino. I do have an additional variable being incremented in a FOR loop and a few arithmetic calculations. The problems appear to be related to optimization.

I've set Optimize: debug and also selected No Optimization, and also marked variables as volatile. The original example includes #pragma GCC optimize ("O0"), but this also doesn't seem to make any difference. Micro Build output is attached.

Here is why I think optimization is still occurring: breakpoints work on certain lines, but on others I get a message that the line does not exist due to compiler optimization. 

If I simply have a single breakpoint somewhere in the main loop(), watched variables increment correctly, but if I hover on the code statements when stopped at a breakpoint, certain variables have already been incremented before the incrementing line of code would be executed. 

Stepping causes the cursor position to cycle around lines that aren't in a loop, while watched variables that are in a loop elsewhere increment. 

I conclude that optimization probably isn't suppressed, and the execution arrows showing in VS don't match the lines where the execution is actually occurring.

Google suggests that gcc is known to ignore requests to suppress optimization. The workarounds people propose on StackOverflow  don't seem to have any effect here.

Am I overlooking something, or are there any suggestions?

Thx!!
« Last Edit: Dec 25th, 2021 at 7:16pm by cfeied »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
cfeied
Junior Member
**
Offline


Posts: 49
Joined: May 18th, 2016
Re: under GDB statements are optimized away despite "No Optimization"
Reply #1 - Dec 25th, 2021 at 7:14pm
Print Post  
cfeied wrote on Dec 24th, 2021 at 8:51pm:

Am I overlooking something, or are there any suggestions?


Update: 
I updated to the latest version of Arduino (.19) and the latest version of Teensyduino (1.56 just released) and the problem has 'magically' vanished. Perhaps there was something in core that caused optimization to be switched on. 
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint