VS Arduino
Visual Micro >> Usb/Serial/WiFi Debugging >> Compilation fail if debug is active
https://www.visualmicro.com/forums/YaBB.pl?num=1603004698

Message started by Kabron on Oct 18th, 2020 at 7:04am

Title: Compilation fail if debug is active
Post by Kabron on Oct 18th, 2020 at 7:04am
Board M5Stack-Core2, touch.ino example from M5Core2 library.
I guess it is a bug. If debug is enabled and BPs arrranged as on picture, compilation fails. See attachement.
bp.jpg ( 140 KB | 10 Downloads )

Title: Re: Compilation fail if debug is active
Post by Kabron on Oct 18th, 2020 at 7:06am
Compilation out & code.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=touch.zip ( 14 KB | 2 Downloads )

Title: Re: Compilation fail if debug is active
Post by Kabron on Oct 18th, 2020 at 7:09am
One BP is enough for compilation fail.

Title: Re: Compilation fail if debug is active
Post by Visual Micro on Oct 18th, 2020 at 12:29pm
Hi

Thanks for the info. During compilcation the serial debugger has to inject debug statements into the code (in the temp build folder). That isn't an easy process when it comes to single line if statements because it makes them multi-line yet there are no braces {}.

Visual Micro attempts to add braces in some single line "If" scenarios but in your code fomat it has failed to manage that task. Therefore the resulting code in the temp copy is wrong.

The error from your output is as follows which confirms this. It is possible that moving each of the three breakpoints in the If/Else statements up one line will work. This is because the injected serial is appended to the end of each line, or in the case of if/else then some rework is made to add {}. It might be happier injecting into rather than after.

[code]touch.ino: In function void loop()

touch.ino: 53:1: error: 'else' without a previous 'if
   else if(pos.x > 218)

touch.ino: 55:1: error: 'else' without a previous 'if
   else if(pos.x >= 109 && pos.x <= 218)
Error compiling project sources
Debug build failed for project 'touch'
[/code]

As an aside I see you have changed the optimization setting from default. That is not required and debugging with serial because the debug watch statements are compiled into the code therefore preventing the omptimizer from causing any issues. Using different  optimizations settings will only be useful for hardware debugging.

Also please note, that each serial debugger breakpoint is same as adding a few lines of serial to your code. Putting breakpoints in the setup() before an mcu has fully initialized can sometimes cause issues especially with wifi net connect. Again this is not an issue in your case but please keep this in mind.

Thanks


Title: Re: Compilation fail if debug is active
Post by Kabron on Oct 18th, 2020 at 1:37pm
Thanks a lot, Tim.
I don't really suffer from this, I just thought it would be interesting for you. In terms of optimization, I believe that the new M5Core2 library is still very crude and therefore my device does not always start up. So I'm just looking for a compile option that works.

Title: Re: Compilation fail if debug is active
Post by Visual Micro on Oct 21st, 2020 at 6:19pm
Do you feel that my answer has given you the compile option that works?

Title: Re: Compilation fail if debug is active
Post by Kabron on Oct 21st, 2020 at 8:49pm
Surelly!

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.