VS Arduino
Visual Micro >> Usb/Serial/WiFi Debugging >> Serial debugging - watch a variable globally
https://www.visualmicro.com/forums/YaBB.pl?num=1609683756

Message started by tfact129 on Jan 3rd, 2021 at 2:22pm

Title: Serial debugging - watch a variable globally
Post by tfact129 on Jan 3rd, 2021 at 2:22pm
Hi, I have a global 'int status' variable that is changed in some different parts/functions of my sketch.
I'm interested how this variable globally changes during execution of the sketch.
Where and how should I set a BP to watch the change of this variable?

Title: Re: Serial debugging - watch a variable globally
Post by Simon@Visual Micro on Jan 3rd, 2021 at 4:31pm
This can be watched using the Breakpoint Actions, and you can add the variable name in curly braces e.g. {status} to output its value when that break/trace point is hit, which will also add it to the Expressions window.

See the section "More on Breakpoint Action Message Texts" on the below page for further information:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Working-With-Breakpoints-When-Hit.html

Title: Re: Serial debugging - watch a variable globally
Post by tfact129 on Jan 3rd, 2021 at 9:08pm
Thank you, but if I understand correctly this shows only the current value of the variable when the debugger hits exactly this one breakpoint. I have something in mind that the expressions window shows the current value of the variable wherever the variable is changed in the sketch. I have dozens of places in the sketch where the variable changes.
I did a workaround by placing 'status = status;' in the loop and put there a breakpoint {status}.
Do I understand something wrong?

Title: Re: Serial debugging - watch a variable globally
Post by Simon@Visual Micro on Jan 4th, 2021 at 9:50am
You understand this correctly, and the breakpoints need to be set wherever you want to stop or trace the value of the variable, and a single break in loop allows it to be checked each time loop runs.

Title: Re: Serial debugging - watch a variable globally
Post by tfact129 on Jan 4th, 2021 at 1:42pm
Ok - but it would be helpful if I could define a variable in VM expressions to be observed globally without putting that variable in the sketch loop where I actually don't need it.
Maybe you could think about such a feature?

Title: Re: Serial debugging - watch a variable globally
Post by Simon@Visual Micro on Jan 4th, 2021 at 2:15pm
You can just watch the variable value on a breakpoint expression in loop(), without having to add the additional line of code into loop.

Title: Re: Serial debugging - watch a variable globally
Post by tfact129 on Jan 4th, 2021 at 2:36pm
Thank you!

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