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) How to view array contents in debugger? (Read 9116 times)
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
How to view array contents in debugger?
Jul 28th, 2017 at 10:28am
Print Post  
I have a structure and an Array that I want to monitor in Visual Studio project for Mega 2560.

I have tried breakpoint and set value like {rxbuff} but cannot see the value when program stops at breakpoint.

The other is a structure below...

typedef struct {
     int  adcLow;
     int  adcHigh;
     int  sensorLow;
     int  sensorHigh;
     char units[20];
     char title[20];
}inputType;
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #1 - Jul 28th, 2017 at 11:15am
Print Post  
it doesn't support complex types at the moment. you have to do it the boring way naming each element or use gdb
  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #2 - Jul 28th, 2017 at 9:16pm
Print Post  
So, the debugger only supports simple, single variables like int and char?

Can gdb be made to work with Mega 2560?
« Last Edit: Jul 28th, 2017 at 9:27pm by orbitcoms »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #3 - Jul 29th, 2017 at 12:30pm
Print Post  
Hi,

Yes only simple data types because it uses similar to serial.print()

You can buy a hardware debugger for the atmel boards but they can be tricky standard arduino boards. Gdb is a debugging standard. If you buy a hardware debugger for an AVR board I suggest you use Visual Micro in Atmel Studio instead of vs.



« Last Edit: Jul 29th, 2017 at 12:30pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #4 - Jul 29th, 2017 at 10:09pm
Print Post  
Do I need to make changes in visual micro settings to use the Atmel Ice (ie. prevent it from using the serial debug and use the hardware debugger instead)? Or do I simply select the debugger hardware in Atmel studio and it will use this instead of serial debug?

Thanks
« Last Edit: Jul 29th, 2017 at 10:42pm by orbitcoms »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #5 - Jul 30th, 2017 at 2:22pm
Print Post  
1) Upload

In Atmel Studio you will see a new programmer in the visual studio programmers list called "Atmel Studio Device Programming". Using that programmer tells Visual Micro to leave uploading to the standard Atmel Studio Project Properties (device).

This will give you the standard Visual Micro Arduino build but upload will jump into atmel.

2) Debug

If you check the menu item called "vMicro>Debugger>Atmel Studio Debugging" then the Visual Micro Serial debugger will be disabled and the Atmel Studio debugger will be launched. The atmel debugger will be the one you have selected in the project properties so it's out of Visual Micros hands and fully within your/atmel control.

...

You can mix and match 1) and 2) with most atmel debuggers but enabling both will cause the least confusion and allow you to follow standard atmel studio upload and debug documentation.

  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #6 - Jul 30th, 2017 at 9:30pm
Print Post  
Thank you
  
Back to top
 
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #7 - Jul 31st, 2017 at 3:28am
Print Post  
I went to Visual Micro -> Debug and checked "Atmel Studio Debugger".
When I compile I get a lengthy note "Atmel Degugging for Arduino is Enabled...."
When I attempt to start debugging I get errors that look like it is still trying to use COM4 (the VM port I was using for serial debugging).

In Projet -> Properties -> Tool: I see the Atmel-ICE. J4xxx debugger and have selected "ISP" interface (I am connecting Ice via the 6-pin connector to the ISP header near USB port on Mega 2560)

The uploader returned an error

avrdude: ser_open(): can't open device "\\.\COM4": The system cannot find the file specified.
avrdude: ser_drain(): read error: The handle is invalid.
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail


« Last Edit: Jul 31st, 2017 at 3:31am by orbitcoms »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #8 - Jul 31st, 2017 at 1:13pm
Print Post  
Get the upload working first, ignore the debugger settings. Check the box below the Visual Micro programmer that says "Always use programmer for upload"

If you post an upload error then post all of the output not just a part. 

Please read ...

http://www.visualmicro.com/page/Arduino-for-Atmel-Studio-7.aspx
« Last Edit: Jul 31st, 2017 at 1:16pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #9 - Jul 31st, 2017 at 9:35pm
Print Post  
This turned out to be more hassle than I expected.

Once I got the ICE talking to the board I find it can only be used for programming and not debugging. Then after google search I find I need to use JTAG if I want debugger. This involved making connections to Analog pins that double as JTAG connections and setting JTAG fuses using ISP first. But still did not get debugger working after trying that. So, I ended up back with VM and not being able to use the debugger to view most of my variables. Now I am reverting to putting print statements and breaking up arrays into simple variables to be able to "suck it and see"
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #10 - Jul 31st, 2017 at 10:56pm
Print Post  
Yes sorry you wasted your time. For Atmel avr boards hardware debug has always been difficult, that's why I wrote the serial debugger. It's simpler but easier in most cases.
« Last Edit: Jul 31st, 2017 at 10:58pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: How to view array contents in debugger?
Reply #11 - Jul 31st, 2017 at 11:23pm
Print Post  
The other issue is that unless I put a breakpoint on every line of code, I cannot single step through my code.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to view array contents in debugger?
Reply #12 - Aug 18th, 2017 at 10:50pm
Print Post  
No serial debug does not support single step. It has to do it's best to inject serial messages into the temp copy of the code during compile. Adding a break-point to every line would be complicated and more prone to the wrong type of breakage.

Arduino are looking at debug so maybe they will come up with a better solution. The alternative is hardware debug but it's not always easy.




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