Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • 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
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Serial debugging - watch a variable globally (Read 1807 times)
tfact129
Junior Member
**
Offline


Posts: 14
Joined: May 30th, 2019
Serial debugging - watch a variable globally
Jan 3rd, 2021 at 2:22pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: Serial debugging - watch a variable globally
Reply #1 - Jan 3rd, 2021 at 4:31pm
Print Post  
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
Joined: May 30th, 2019
Re: Serial debugging - watch a variable globally
Reply #2 - Jan 3rd, 2021 at 9:08pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: Serial debugging - watch a variable globally
Reply #3 - Jan 4th, 2021 at 9:50am
Print Post  
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
Joined: May 30th, 2019
Re: Serial debugging - watch a variable globally
Reply #4 - Jan 4th, 2021 at 1:42pm
Print Post  
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: 2145
Joined: Feb 13th, 2019
Re: Serial debugging - watch a variable globally
Reply #5 - Jan 4th, 2021 at 2:15pm
Print Post  
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
Joined: May 30th, 2019
Re: Serial debugging - watch a variable globally
Reply #6 - Jan 4th, 2021 at 2:36pm
Print Post  
Thank you!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint