dmitrystu / sboot_stm32

Secure USB DFU1.1 bootloader for STM32
Apache License 2.0
303 stars 63 forks source link

Add flag to allow debugging #33

Closed alexispolti closed 3 years ago

alexispolti commented 3 years ago

Simple MR to allow debugging when porting on a new architecture. -g doesn't harm, as debugging infos are not flashed and the generated code is the same.
Feel free to include or not! :-)

dmitrystu commented 3 years ago

I'm not sure that this is a good idea to add debug symbols with Os and LTO optimization settings.

alexispolti commented 3 years ago

Well, debug symbols are completely separated from code generation / lto : the generated code is the same with ou without -g. It's just some additional sections in the ELF file which are added to tell the debugger where to find a specific instruction. What problem do you see?

dmitrystu commented 3 years ago

I see no problems, but also I see no reasons to use -g option without -O0 or -Og optimization settings. I have a negative experience using debug symbols with high optimization levels. I'll think about adding a variable like OPTFLAGS ?= -Os -flto to the makefile that can be changed from the command line to get debug/release code.

alexispolti commented 3 years ago

IIRC, on ARM 32bits, gcc with -Os doesn't generate "undebuggable" code. I did some debug and made some modifications these last few days without any problem. But your approach (OPTFLAGS ?= -Os -flto) is perfect, thanx :-)

dmitrystu commented 3 years ago

I will close this PR. And Thank you for the contribution.