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) Unable to figure out how to use debugger (Read 10870 times)
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Unable to figure out how to use debugger
Jun 17th, 2014 at 9:58am
Print Post  
I have enabled a trial period for the debugger. I find that this debugger is nothing like debuggers I'm used to before.
When I start a debug session I expect the program to pause with a program cursor at each line and execute them one after one if single stepping or stop at the next breakpoint if I continue to run the code.
With Atmel Studio and Visual Micro I get an message that my sketch has started and nothing more. I don't see which program line is next and selecting step or step into or start debugging with break makes the code recompile (and no stepping or break seem to happen).
I have opened the project windows properties and set micro debug to full and enabled break pause. I have also  enabled 'when hit' on my breakpoints and checked 'print a message' and unchecked 'continue execution'.
But I see no messages in debug trace or any sign of what is happening. I can't step through the program and I can't see which code lines are being executed and step or run to next breakpoint. How is that supposed to work ?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #1 - Jun 17th, 2014 at 12:08pm
Print Post  
Hi,

Please close the ide and install the latest version http://visualmicro.codeplex.com/releases/view/106554

the new release adds some useful tips and info for new users.

Please also confirm the line of code that you have placed your breakpoint on. Does it start with an "if" or "switch" etc.? If so I will give you extra advice

Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Unable to figure out how to use debugger
Reply #2 - Jun 17th, 2014 at 1:00pm
Print Post  
Tim@Visual Micro wrote on Jun 17th, 2014 at 12:08pm:
Hi,

Please close the ide and install the latest version http://visualmicro.codeplex.com/releases/view/106554

the new release adds some useful tips and info for new users.

Please also confirm the line of code that you have placed your breakpoint on. Does it start with an "if" or "switch" etc.? If so I will give you extra advice

Thanks


I have installed that suggested update. Some of code lines with breakpoint starts with if. I'm still unable to step through the program or seeing the program flow. Where is the cursor indicating the current code line being executed ?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #3 - Jun 17th, 2014 at 1:59pm
Print Post  
Hi Jan,

The cursor flashes the line of code is highlighted when visual micro stops at a breakpoint.

The breakpoints on "If" statements will only execute inside the If so unless the If resolves to true then the brealpoint will not be hit.

Might I suggest you see how the debugger works with a simple sketch such as blink which does not have conditional 'if' statements.

Question

Can you also confirm if your sketch uses Serial and if so does it initialize the serial at 115200? If not this would stop the debugger working unless you set the RemoteSpeed property

Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Unable to figure out how to use debugger
Reply #4 - Jun 18th, 2014 at 7:08am
Print Post  
Tim@Visual Micro wrote on Jun 17th, 2014 at 1:59pm:
Hi Jan,

The cursor flashes the line of code is highlighted when visual micro stops at a breakpoint.

The breakpoints on "If" statements will only execute inside the If so unless the If resolves to true then the brealpoint will not be hit.

Might I suggest you see how the debugger works with a simple sketch such as blink which does not have conditional 'if' statements.

Question

Can you also confirm if your sketch uses Serial and if so does it initialize the serial at 115200? If not this would stop the debugger working unless you set the RemoteSpeed property

Thanks


I see all my code lines with a break as highlighted and no cursor.

Why can't we have breakpoints on if statements lines ? No problem in MPLAB.

Yes my sketch uses serial and serial1. Serial at 9600 baud and Serial1 at 2400 baud (Arduino Mega 2560)
My first breakpoint was at
Code (C++)
Select All
  Serial.begin(9600);  


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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #5 - Jun 18th, 2014 at 8:35pm
Print Post  
Hi Jan,

You can put a breakpoint on an 'if', I simply pointed out that the breakpoint will only be hit if the 'if' evaluates to true.

Arduino does not have debugging so Visual Micro uses serial in the background. This means that during the compile process we have to inject serial.print() statements into the temporary copy of the code used by the compiler. The breakpoints are in a known format so that Visual Micro can intercept the messages and update running debugger status/trace/expressions windows.

Because serial messages are injected it was easier to inject at the end of a line. You have to think of a breakpoint in the same way as you would have done if you had manually added your own serial.print() debug statements throughout your code.

This means you can put breakpoints on blank lines and code lines which is weird but flexible. It's not a perfect solution but often better than hacking your code.

So the breakpoint on an 'if' executes inside the 'if' allowing you to put the breakpoint the line before to halt on the 'if'

Something important that appears to be lost somewhere within the depths of the new documentation is a note to explain that the default speed for the debugger is 115k. If your sketch code is sharing the same serial port that the debugger uses then you will see that the serial monitor shows a speed of 115k when the debugger opens.

Because your code has elected to use 9600 then you need to tell Visual Micro to use 9600. You do this using the LocalSpeed and RemoteSpeed project property. You will see that in your case you can just fill in one of the properties and the other will automatically populate with the same value. Either that or alter your sketch serial.begin() to 115k

So the fact that your arduino is sending at 9600 but the pc is using 115k is the reason why no breakpoint data is appearing. 

How to find the project properties window is here http://www.visualmicro.com/page/User-Guide.aspx?doc=Project-Properties-window.ht...

nb: You will also see that you can use one or two digital pins or other serial ports should in the future you find that your code design and/or the debugger need exclusive access to a port. This is immediately the case if your own code uses the Serial.read() functions and Visual Micro is allowed to break/pause or wait at start-up.



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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #6 - Jun 19th, 2014 at 11:15am
Print Post  
Hi Dave,

I was wrong all of the above is explained in the debugger section of our documentation and the FAQ specifically mentions how to ensure the correct serial speed.
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Unable to figure out how to use debugger
Reply #7 - Jun 23rd, 2014 at 12:05pm
Print Post  
Tim@Visual Micro wrote on Jun 18th, 2014 at 8:35pm:

Re: Unable to figure out how to use debugger
Reply #5 - Yesterday at 21:35:17 Mark & Quote Quote 
Hi Jan,

You can put a breakpoint on an 'if', I simply pointed out that the breakpoint will only be hit if the 'if' evaluates to true.

Arduino does not have debugging so Visual Micro uses serial in the background. This means that during the compile process we have to inject serial.print() statements into the temporary copy of the code used by the compiler. The breakpoints are in a known format so that Visual Micro can intercept the messages and update running debugger status/trace/expressions windows.

Because serial messages are injected it was easier to inject at the end of a line. You have to think of a breakpoint in the same way as you would have done if you had manually added your own serial.print() debug statements throughout your code.


But does not the atmel cpu have debugging ? There are debuggers sold for atmel.
I suppose this mean that I can't single step or step into a function unless I put breakpoints at every code line. Also
in order to examine variables and registers I must configure the breakpoint to print them.
  
Back to top
 
IP Logged
 
Jo Sto
Ex Member
*


Re: Unable to figure out how to use debugger
Reply #8 - Jun 23rd, 2014 at 3:44pm
Print Post  
Quote:
But does not the atmel cpu have debugging ? There are debuggers sold for atmel.
I suppose this mean that I can't single step or step into a function unless I put breakpoints at every code line. Also
in order to examine variables and registers I must configure the breakpoint to print them.

But not in an Arduino development environment and not on unmodified hardware.
http://automation.binarysage.net/?p=1515
And as noted in a post in November, which is not the goal of this project. It is intended to facilitate debugging in an original Arduino environment.
A built-in software Arduino simulator would be useful.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #9 - Jun 24th, 2014 at 12:58pm
Print Post  
Hi Jan,

Most Arduino users are debugging by adding Serial.print statements to their code. The Visual Micro debugger helps to avoid the need to do that.

If you read about the tools you are using, Atmel Studio you will find you can buy a hardware debugger then use it with Atmel Studio (after making small changes to the hardware).

Atmel Studio also has a simulator. After compiling your program with Visual Micro the simulator can run the resulting .elf
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Unable to figure out how to use debugger
Reply #10 - Jun 25th, 2014 at 10:29am
Print Post  
Since we can't single step line by line through the code what is the function of Step Into (F11) and Step Over (F10)  ?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to figure out how to use debugger
Reply #11 - Jun 25th, 2014 at 7:30pm
Print Post  
Hi Jan,

You can step between breakpoints but many of the start commands do the same thing (start the debug)

The menu items are all standard vs menus, Visual Micro uses serial and tries to replicate as many debug commands as possible. 

By the way of you have a hardware debugger then you might be able to use the native atmel debugger.

Thanks
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint