Adding debug and optimization options to Arduino IDE v2

DOugL-
Posts: 21
Joined: Sun Dec 18, 2022 6:00 pm

Adding debug and optimization options to Arduino IDE v2

Postby DOugL- » Mon Dec 19, 2022 7:03 pm

I'm working on getting openocd debugging working on the Arduino IDE v2 and while there I've added Debugging and Optimization compiler directives.

In boards.txt file I added this to the top:
menu.Debugging=Compiler Debug Levels
menu.opt=Optimize

then in the body of the ESP32 Dev Module I added these:
esp32.menu.Debugging.none=None
esp32.menu.Debugging.enable_sym=Symbols Enabled (-g)
esp32.menu.Debugging.enable_sym.build.flags.debug=-g -DNDEBUG
esp32.menu.Debugging.enable_log=Core logs Enabled
esp32.menu.Debugging.enable_log.build.flags.debug=
esp32.menu.Debugging.enable_all=Core Logs and Symbols Enabled (-g)
esp32.menu.Debugging.enable_all.build.flags.debug=-g

esp32.menu.opt.osstd=Smallest (-Os default)
esp32.menu.opt.oslto=Smallest (-Os) with LTO
esp32.menu.opt.oslto.build.flags.optimize=-Os -flto
esp32.menu.opt.o1std=Fast (-O1)
esp32.menu.opt.o1std.build.flags.optimize=-O1
esp32.menu.opt.o1lto=Fast (-O1) with LTO
esp32.menu.opt.o1lto.build.flags.optimize=-O1 -flto
esp32.menu.opt.o2std=Faster (-O2)
esp32.menu.opt.o2std.build.flags.optimize=-O2
esp32.menu.opt.o2lto=Faster (-O2) with LTO
esp32.menu.opt.o2lto.build.flags.optimize=-O2 -flto
esp32.menu.opt.o3std=Fastest (-O3)
esp32.menu.opt.o3std.build.flags.optimize=-O3
esp32.menu.opt.o3lto=Fastest (-O3) with LTO
esp32.menu.opt.o3lto.build.flags.optimize=-O3 -flto
esp32.menu.opt.ogstd=Debug (-Og)
esp32.menu.opt.ogstd.build.flags.optimize=-Og
esp32.menu.opt.o0std=No Optimization (-O0)

And in platform.txt I replaced the hardcoded "-Os" for compiler directive with:
{build.flags.optimize} {build.flags.debug} and put the following in the same file:

# Defaults config
build.flags.optimize=-Os
build.flags.debug=-DNDEBUG

DOugL-
Posts: 21
Joined: Sun Dec 18, 2022 6:00 pm

Re: Adding debug and optimization options to Arduino IDE v2

Postby DOugL- » Thu Jan 26, 2023 4:06 pm

It would really be nice to have more control of debugging levels, compiler error/warning levels and compiler optimization levels in the Arduino Tools menu. This is what I added to get those things but the 2.0.6 release of the arduino-esp, Arduino core for ESP32, does not provide that.

Who is online

Users browsing this forum: No registered users and 57 guests