cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMonitor 1.2.0 does not parse global variables in .elf files compiled in Release mode (with optimizations). Why?

BlueMOSFET
Associate II

It does parse global variables in the corresponding .elf file of the same project, compiled in Debug mode (without optimizations). The introductory video (of Cube Monitor) said it can parse debug and release .elf files, but it does not seem to be the case.

1 ACCEPTED SOLUTION

Accepted Solutions
Radosław
Senior II

Check in GCC compiler settings in debugging page.

Global variable, in some cases can be simple removed, but this usually don't happen,

View solution in original post

4 REPLIES 4
Radosław
Senior II

If variable will be optimized, than it can't be monitored, also, in release debug information are not included to elf file, check your compiler settings.

BlueMOSFET
Associate II

Why would it be not possible to monitor a global variable of some code that is not optimized? That variable still sits in a defined place, in SRAM, that place is known at the moment of compilation, STM32CubeMonitor could perfectly know where to look for it, and JTAG/SWD should have no problem reading from/writing to that variable. It should have nothing to do.

The .elf file created in Debug mode is much larger than the .elf file created in Release file.

I checked my (GNU) compiler settings, and I found nothing that it would tell it not to embed in the .elf file the info regarding where each global variable is, in the case of Release compilation (with optimizations for speed). Of course, there is a setting that tells it to optimize for speed, in that case (of Release). In Release mode, I want code optimized for speed, and I would like the .elf to also include the info about where each global variable is (so that CubeMonitor can parse them).

Is there a way to tell the compiler that has to create code that is optimized for speed AND that includes in the .elf file the location of each global variable?

Radosław
Senior II

Check in GCC compiler settings in debugging page.

Global variable, in some cases can be simple removed, but this usually don't happen,

BlueMOSFET
Associate II

Yes, I found it. For STM32CubeIDE, it is in (Project) Properties -> C/C++ Build -> Settings -> (Tab) Tool Settings -> MCU G++ Compiler -> Debugging -> Select configuration "Release" -> Debug level: "Maximum (-g3)".

And that is independent on the optimization level. The .elf file from compilation in Release mode is now much larger (not because it is not optimized --which it is-- but because it now includes debug info.

Thank you.