Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: What does Tools: Optimize : Debug do?

  1. #1
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Cheltenham, UK

    What does Tools: Optimize : Debug do?

    What does Tools: Optimize : Debug do?
    I can't find it documented anywhere!

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Quote Originally Posted by BriComp View Post
    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.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    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:
    So it passes to GCC -Og

    Which from GCC documentation like:
    You see:
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts