cancel
Showing results for 
Search instead for 
Did you mean: 

RELEASE vs DEBUG

JAlca
Senior

Hi all!,

I'm triyng to learn about differences between a debug .elf file vs a release .elf.

If I upload a debug .elf file and then, in STMStudio I import a variable from that .elf file, STMStudio shows the variable normally, as expected.

But, If I upload a release .elf file and then, in STMStudio I import the same variable from the debug .elf file, STMStudio still shows the variable...

What I'm missing here?

How can STMStudio recover info for a variable in a release uploaded file?

3 REPLIES 3
berendi
Principal

STMStudio has no way to know that you have tricked it, and the target contains a different image.

It has got the address of the variable from the debug information in the debug .elf file, and shows whatever is in the device memory at that address.

If you have not changed much between the debug and the release builds, the variables would likely end up at the same address. You can compare the .map files of the release and debug builds, and you would find that the addresses of the variables in RAM are the same.

But I would not rely on that, heavy optimization could remove some variables from the release build, and then STMStudio would find the value of some other variable at the address.

If you want to peek into the workings of the release builds, I'd recommend compiling it with the -g3 (debug level 3) option but otherwise with the release settings. It would not affect the resulting binary, but the addresses of some variables (maybe not all of them) would still be stored in the release .elf.

JAlca
Senior

Thank you very much!,

Another question is my program works well in debug configuration, but its hangs on release configuration. I use some interrupts generated by switches and timers.

Any advice?

berendi
Principal

Make sure that all variables touched by interrupt handlers (and by any function called from an interrupt handler) are declared as volatile. Do not assume that HAL or any other library you might be using got it right, check them as well.