What does Tools: Optimize : Debug do?

Status
Not open for further replies.
What does Tools: Optimize : Debug do?
I can't find it documented anywhere!

It makes the code compatible with debugging, turning off any optimizations that would obscure or
remove debugger functionality (for instance function inlining would prevent setting a breakpoint on
the function).

gcc/g++ docs will no doubt explain more, this option is just translated to the relevant compiler flag.
 
As with most questions like this, I would suggest if you have not already done so, turn on Verbose compiler option in Arduino.
It is on the preferences page.

Then you can see exactly what commands are used to build, and you can then look up in GCC documents on what each of these flags do.
Note: you can also look at the boards.txt to see what each of these actually produce:
In this case for T4.1 you see:
Code:
teensy41.menu.opt.ogstd=Debug
teensy41.menu.opt.ogstd.build.flags.optimize=-Og
teensy41.menu.opt.ogstd.build.flags.ldspecs=
So it passes to GCC -Og

Which from GCC documentation like: https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Optimize-Options.html
You see:
Code:
-Og
Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. 
It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while 
maintaining fast compilation and a good debugging experience.
 
Status
Not open for further replies.
Back
Top