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
Hot Topic (More than 8 Replies) Breakpoints not working (Read 3348 times)
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Breakpoints not working
Feb 20th, 2013 at 3:01pm
Print Post  
I'm using the debugger in VERY simple sketches to build my understanding of various elements of the Ardunio code environment.  I've done some simple calculations in the setup() function and place a breakpoint on one of the operations. the sketch uploaded ok... the Expressions window pops up with a gray 'waiting for breakpoint data'...  and nothing happens.

I even added some (dreaded!) Serial.print statements which work under Arduino 1.0.3 - but I see no output from that - guess I may have closed it's window but can't find it...   Undecided

Anyway - I've been having this issue for some time where the breakpoints just never hit.   Is this a common issue? Have I stepped on something and 'broke' VM? 

=Alan R.
  
Back to top
 
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #1 - Feb 20th, 2013 at 4:49pm
Print Post  
UPDATE: I made a few changes to the sketch, saved it and the breakpoints started working.  Made few more changes - and now it is back to not hitting the breakpoint and printing my message... Sad

=A.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoints not working
Reply #2 - Feb 20th, 2013 at 7:23pm
Print Post  
Hi There,

Few things

1) In the current version of vm the serial monitor only outputs data when it receives a "new line" char. So if you add a serial.println() that will make the display work correctly.

2) Debugger breakpoints are shown in the Trace Output window. The only time that I know breakpoints can fail is if you have too much of your own manual serial.print() data. In this case you can either remove your serial.print() statements or use a different serial port or softwareSerial for debug. If you have too much of your own serial print data then things might appear to work sometimes and not others.

3) The "waiting for data" in the expression viewer will only show data if you have set debugger message/expression watch. Such as "Hey! Millis = {millis()}" or "{a}{b}{c}". You are correct that the "waiting for data" message will also remain if breakpoints are being lost to serial.print() overflow.

4) Breakpoints are TracePoints unless you set the project property called "Enable Break/Pause=True"

5) If you have used your own serial.print() statements then you will have probably used the "serial.begin(baud)" syntax in your arduino code. If so, then the baud that you specify in your code must be the same as the project property called "Remote Speed". When you change "RemoteSpeed", Visual Micro will automatically adjust LocalSpeed to be the same (unless you have overridden the defaults)

If your code overrides the default debugger baud (115200) and you have not adjusted the Local/Remote Speed property then breakpoints will not be hit.

6) Do not attempt to put a breakpoint on lines of code that print or read serial messages. There is little point of doing this, and, because the debugger uses serial it is just too much for the arduino and can overflow the buffer regardless of amount of data.

7) If using the setup() instead of loop() for testing or using breakpoints then you should switch on the DTR checkbox on the serial monitor window. The setting will be retained by vm when you re-start visual micro. 

The DTR setting controls if the arduino should re-boot when you open the serial monitor. Turn it on the force the re-boot.

Consider that after upload the arduino will start very quickly, before a window can be opened. In that case the arduino has already completed the setup() within a few milliseconds. 

The DTR is ON in the arduino ide by default and can not be switched off. This means that in the arduino ide every time you open the serial monitor the mcu has to re-boot which is not often what is required.


Summary

If these tips don't help then please email your .sln and all of the files and sub folders of your sketch to info[at]visualmicro.com.

Thanks
« Last Edit: Feb 20th, 2013 at 7:29pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #3 - Feb 21st, 2013 at 12:13am
Print Post  
Tim - thanks for all the various tips.  I HAVE totally removed any reference to Serial.anything - hoping to rely totally on VM and the debugger.

What has been so odd is that it works intermittently.  The comment about using breakpoints is setup() is a good one I'll need to look to - was going to ask about that!   Right now I'm just reviewing vars and counters so setting in loop() will be ok - but I'll need to learn how to break in setup().  It sounds like you can't do both at the same time?

LIGHTBULB ON:  Just found the DTR checkbox!

I will continue on with this info and keep you posted.
Thanks again    Cheesy

=Alan R.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoints not working
Reply #4 - Feb 21st, 2013 at 2:36pm
Print Post  
Great. 

The setup() works the same as loop() for breakpoints. If you are using the std serial port then vm should have automatically enabled the dtr when the debugger starts. 

However there might be a bug that if you fill in the "LocalPort" or "RemotePort" project property and it is the same as the default then the dtr might not being forced on. I need to test this.

BUT, if you have switched on the DTR manually I would expect breakpoints to ALWAYS work (if serial usually works)

Look forward to hearing how you get on.

ps: Depending on serial or serial1, Leonardo is often better at 56k, software serial is always better at 56k on all systems.
  
Back to top
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #5 - Feb 24th, 2013 at 4:53am
Print Post  
Been away from this test sketch a while...  Back at it today and the debug facility still works inconsistently.   Started as usual with no breakpoint hitting. Then it just 'began working' and was doing fine.  Several iterations were ran - the msg from BP was showing...   Then I added a simple var to the sketch, and haven't been able to hit a breakpoint since!

I am working with Timer 0 (don't care about the system stuff that may break).  I have a trivial loop() with 2 lines of code - one is an 'x=x;' statement to give a place to set a breakpoint.  I'm testing interrupts where I set OCR0A to a long count, and OCR0B to a short count.  When A completes it disables and enables B.  I just need a BP in the loop to see where I may be mis-stetting flags or masks, etc.

I don't think this code, even tho working with interrupts, should disable the debugger.  And the fact that it ran for a while and then just stopped is very puzzling. I have DTR checked but it makes no diff...    Cry

=Alan R.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoints not working
Reply #6 - Feb 24th, 2013 at 6:43am
Print Post  
Hi there,

The debugger uses serial, I think timer 0 breaks that. An ftdi cable and software serial might work better for you.
  
Back to top
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #7 - Feb 24th, 2013 at 1:21pm
Print Post  
Ah - therein lies the rub!  No debugging Timer0 work!!  I switched to Timer2 and breaks hitting just fine.  Whatever I do to 2 will apply to 0 so this will work out.

Dunno - but it might be worth mentioning in your overall docs for the debug module that breaking T0 will also break the debugger.  May be common knowledge - I'm pretty much an Arduino-noob, but might be good to mention.

Thanks again!

=A.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoints not working
Reply #8 - Feb 24th, 2013 at 6:00pm
Print Post  
We certainly need better documentation. There is a fine line between too much and too little information for many users. 

How about if I add this statement to the debugger page?

In the background, the debugger uses standard Arduino Serial. If your code will interfere with Arduino Serial then it will interfere with the debugger unless you change the "RemoteTransport" project property.
  
Back to top
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #9 - Feb 26th, 2013 at 7:28pm
Print Post  
Def a good start.  It seems it wouldn't hurt to specifically mention Timer0 use can kill breakpoints.  Advanced users may 'get' the implications of 'Standard Arduino Serial' - heh - I don't!   Cheesy  I've been programming a long time and am ok with the general C stuff, but new to the Arduino environment and VM. There may also be a lot of 'new arrival types' who, like me, may do "Bad Things"...     Undecided

=a.

PS - the debugger is working very nicely now that I'm leaving timer0 alone.  VERY helpful - thanks!

Tim@Visual Micro wrote on Feb 24th, 2013 at 6:00pm:
We certainly need better documentation. There is a fine line between too much and too little information for many users. 

How about if I add this statement to the debugger page?

In the background, the debugger uses standard Arduino Serial. If your code will interfere with Arduino Serial then it will interfere with the debugger unless you change the "RemoteTransport" project property.

  
Back to top
 
IP Logged
 
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
Re: Breakpoints not working
Reply #10 - Feb 27th, 2013 at 3:37pm
Print Post  
Found another tiny 'gotcha' - Breakpoints in setup() don't seem to hit if you do a cli() in setup.  My sketch was hitting BP's yesterday, and today I added the cli() and the debugger went to sleep!   Grin     On the odd chance I commented out that bugger and VOLIA!  my BP's were back.  Not a surprise as I think about it, but also wouldn't hurt to be part of the Debugger info...

=A.

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoints not working
Reply #11 - Feb 27th, 2013 at 5:58pm
Print Post  
Thanks, I've already extended the debugger page with the timer0 warning and will add a note that if you kill all the timers the serial debugger will not be able to transmit or receive
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint