Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Serial debugging - watch a variable globally (Read 484 times)
tfact129
Junior Member
**
Offline



Posts: 14
Serial debugging - watch a variable globally
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?
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 1014
Re: Serial debugging - watch a variable globally
Reply #1 - 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-Wh...
Back to top
 
 
IP Logged
 
tfact129
Junior Member
**
Offline



Posts: 14
Re: Serial debugging - watch a variable globally
Reply #2 - 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?
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 1014
Re: Serial debugging - watch a variable globally
Reply #3 - 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.
Back to top
 
 
IP Logged
 
tfact129
Junior Member
**
Offline



Posts: 14
Re: Serial debugging - watch a variable globally
Reply #4 - 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?
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 1014
Re: Serial debugging - watch a variable globally
Reply #5 - 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.
Back to top
 
 
IP Logged
 
tfact129
Junior Member
**
Offline



Posts: 14
Re: Serial debugging - watch a variable globally
Reply #6 - Jan 4th, 2021 at 2:36pm
 
Thank you!
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print