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
    Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    89

    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
    Posts
    459
    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
    Posts
    7,864
    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...e-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.

Posting Permissions

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