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....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Pages: 1 2 3 
Send Topic Print
Error when building with avr_gdb library (Read 1840 times)
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #20 - Jan 9th, 2020 at 4:01am
 
Version 1.6.23
Back to top
 

AVR_Boards.PNG (34 KB | )
AVR_Boards.PNG
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #21 - Jan 9th, 2020 at 9:08am
 
Thanks, rolling my system back to Arduino 1.8.9 brings this core with it (as its built in) and then I get the same errors for regs and the linking.

If you update your Arduino installation to 1.8.10 this should update the core to 1.8.1 and then it should compile as expected.
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #22 - Jan 9th, 2020 at 5:00pm
 
Thanks,
Funny, I just reinstalled VS2019 (latest) & VisualMicro (latest) and was about to check on the Arduino IDE.
Again, thanks for your help.
This was a real newbie error on my part, not keeping the Arduino IDE up to date.
Abbott Embarrassed Smiley
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #23 - Jan 9th, 2020 at 8:08pm
 
I updated the Arduino IDE, as suggested. There were no compile errors, but 444 warnings...and the program still didn't link and load. I included the Verbose updated avr Boards list.
Again, thanks for the follow through.
Abbott
Back to top
 

verbose_log.txt (277 KB | )
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #24 - Jan 9th, 2020 at 8:46pm
 
No problem and there are a lot of versions / software to keep up with...

Can you update the core as well to 1.8.1 and see if it improves?
(It must be a combination of all of this that works is all I can think now)

How: expand Arduino AVR Boards section and left click on 1.8.1
A message will appear at the bottom of this window when complete
Then click Rescan or restart VS to finish the update
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #25 - Jan 9th, 2020 at 11:20pm
 
The latest 1.8.2 was installed.
It appears that the #ifndef _DEBUG
did not work.
After I commented the attachInterrupts out (again) I was able to upload the sketch to the Mega 2560.

I then downloaded the vmicro\tools zip files and installed them.
After the upload debugging did not start. If I hit the vMicro upload button, the upload occurs and debugging does not start. When I hit Debug->Start Debugging I get the following screen without the breakpoint being hit.

Are there any special VMico Menu entries that should be set?

Thanks
Abbott

Abbott
Back to top
« Last Edit: Jan 10th, 2020 at 3:09pm by Abbott HMG »  

Debug1_003.PNG (108 KB | )
Debug1_003.PNG
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #26 - Jan 10th, 2020 at 3:10pm
 
_DEBUG not working:
have you set the project property "Configuration Define _DEBUG" to 1?
(highlight in solution explorer, press F4)

Not Landing on Breakpoint
With this GDBStub implementation you have to have at least one breakpoint set at compile time, using the breakpoint() function, which is in the top of loop() normally, and suits most needs.

If you add breakpoint() on the line before then it should land there after re-upload and starting debugging again.

The below shows the project property, code amendment and debug landing on this break.

...
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #27 - Jan 10th, 2020 at 7:31pm
 
Almost there ... I guess ...
_debug worked and I get ...
Uploading 'MaplePump' to 'ATmega2560 (Mega 2560) (Arduino Mega)' using 'COM3'
     The upload process has finished.
The breakpoint is still not hit. Are there any other vMicro config params that I should look at?
Is there a limit to the number of breakpoints?
Do the breakpoints set by clicking the desired line work?
See the screen shot after the upload.
Note - I left debug_init() at the top of setup.
Thanks
Abbott
Back to top
 

Debug2.PNG (107 KB | )
Debug2.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #28 - Jan 10th, 2020 at 8:14pm
 
One thing of note as mentioned previously, the GDBStub does not allow the main Serial to be used because you are trying to use that for GDB. You need to use a different serial on the mega along with an ftdi cable or other pin to usb converter.
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #29 - Jan 10th, 2020 at 11:50pm
 
I previously commented out all the serial references. So the serial is free for GDBStub. The only things that might interfere is the Webserver.
I do believe that ethernet uses the Serial to report on the port id. I'll remove that for now and try it.
...I removed all Ethernet / wifi references ... which use Serial port and it does not go into debug after uploading.
Do I still have to set up a separate Serial?
Thanks
Abbott
Back to top
« Last Edit: Jan 11th, 2020 at 2:37am by Abbott HMG »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #30 - Jan 11th, 2020 at 12:07am
 
I suggest testing the debugger in a simple new project so that you can prove your config and it is also worth reading more on the avr-debugging library git page. The git page for the library might also be the best place for questions to the author.

https://github.com/jdolinay/avr_debug

Code (C++):
#include <avr8-stub.h>

void setup(void)
{
	debug_init();	// initialize the debugger
	pinMode(13, OUTPUT);
}

void loop(void)
{
	breakpoint();		// stop execution here
	digitalWrite(13, HIGH);
	delay(200);
	digitalWrite(13, LOW);
	delay(500);
}
 



I found some useful test on google about the limitations and also some suggestions. No idea if still current.


The Arduino Serial class cannot be used in your program together with the debugger. The debugger uses the serial line to communicate with the eclipse IDE. This may look like a big problem if you write your programs "the Arduino way", that is, print debug messages to serial line. But when you debug with a debugger you usually do not need to print such messages. If you do need it, there is a function debug_message which can be used to send mesages to debug console in eclipse. If you need to send data from your program (for normal operation, not for debugging), then you have to first debug the program without the serial output and then enable the serial output and disable the debugger. Or you can use the SoftwareSerial on Arduino Uno and on Arduino Mega also the other hardware serial interfaces Serial1, 2, etc.

One of the pins with external interrupt function (INT0, INT1,…) must be reserved for the debugger. With Arduino Uno this can be either digital pin 2 or 3 (PD2 or PD3 pin of the MCU). For Arduino Mega there are more options. By default, INT0 pin (Uno pin 2, Mega pin 21) is used, but you can change this by AVR8_SWINT_SOURCE constant in avr8-stub.h file.

As described above, in the default configuration with RAM breakpoints, the program executes at much lower speed when breakpoints are set in the program. This is because the breakpoints are implemented using a little strange feature of the Atmel AVR architecture - there is always one instruction executed after return from interrupt service routine (ISR) before the same or other ISR can be entered again. Thanks to this feature it is possible to single step the program and compare current program counter with desired breakpoint addresses. But having an interrupt triggered after each instruction does slow down the program a lot. This slowness is not a problem in many cases but if you do find it limiting, you can switch to flash breakpoints.

When using flash breakpoints the watchdog cannot be used. Arduino library does not use watchdog so this is usually not a problem. If you need to use watchdog in your application, enable the code which works with the watchdog only after the application is debugged, or use the RAM breakpoints configuration.
Back to top
« Last Edit: Jan 11th, 2020 at 12:08am by Visual Micro »  
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #31 - Jan 11th, 2020 at 11:04am
 
I tried the simple example you supplied and it works.
I'll contact Jan Dolinay
Thanks
Abbott
Back to top
« Last Edit: Jan 11th, 2020 at 11:34am by Abbott HMG »  
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #32 - Jan 11th, 2020 at 12:45pm
 
VS = Version 16.4.2
Micro Build -
Program MaplePump size: 72,692 bytes (used 29% of a 253,952 byte maximum) (7.90 secs)
Minimum Memory Usage: 5177 bytes (63% of a 8192 byte maximum)

# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: file:///C:/Users/Abbott/Documents/Arduino/Solutions/MaplePump/Debug/

Uploading 'MaplePump' to 'ATmega2560 (Mega 2560) (Arduino Mega)' using 'COM3'
     The upload process has finished.
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: file:///C:/Users/Abbott/Documents/Arduino/Solutions/MaplePump/Debug/

Thanks
Abbott
Back to top
 

Debug3_001.PNG (107 KB | )
Debug3_001.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #33 - Jan 11th, 2020 at 1:17pm
 
Our posts crossed and I think you previously reported the simple example didn't work and subsequently changed to a post that confirmed it did work. I agree it's a question for the git site.

Your verbose output was useful and will help you be clearer in your report to git. At some point you have used board manager to install the arduino avr. The arduino ide is installed with an avr tool chain, when you install via board manager it overrides and can then cause some confusion.

I suggest you delete C:\Users\Abbott\AppData\Local\arduino15\packages\arduino. That will zap your arduino board manager packages (which can be reinstalled again via board manager in the future). The benefit of this is that your problem reporting  will be accurate in terms of the tool chains and core that you are using. Thus, when you report the issue on git you will say that you are using Arduino IDE 1.8.x and the author of git will be able to replicate your arduino environment.

After deleting the package restart vs or click Rescan so that VS is also using the same tool chain.



Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #34 - Jan 11th, 2020 at 9:33pm
 
I did as you asked and it still does not go into debug.
I then created a MaplePumpDebug2 in which I started to add the low level parts of my program.
I made the .ino logic basic (no calls to my classes).
When I hit the breakpoint, I got an exception dialog.

I've included the screen shot, program with verbose included.

I guess that this is a debugger issue???

I'll continue with this process (to see when debugger totally fails) and update the thread when I hit the failure.

All I did was to include the log.cpp file (which I forgot to include at the beginning of the thread), and the debugger stopped working completely. I did not even make a call to the log.
Back to top
« Last Edit: Jan 12th, 2020 at 2:55am by Abbott HMG »  

1Debug1.PNG (84 KB | )
1Debug1.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #35 - Jan 11th, 2020 at 9:43pm
 
Well it's good it is working of a sorts.

Yes you are now into either the gdbstuf realm of the microsoft mi debugger realm although the mi debugger has various options that might better control what errors are ignored.

Where you able to continue after the error or add another breakpoint? It might be that you just needed to add a real breakpoint for it to stop on. Try adding the breakpoint() to the setup() then adding a real breakpoint in the loop.

Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #36 - Jan 12th, 2020 at 10:58am
 
I made the test simpler (by removing everything but avr.
When  i add the breakpoint in Loop, the setup breakpoint is never hit.

The same exception now occurs in the loop breakpoint.

I can F10 to next, when it gets to delay, F10 steps into instead of over.

This seams pretty rudimentary for the debugger to fail like this.

I've attached the solution.

Abbott
Back to top
« Last Edit: Jan 12th, 2020 at 11:07am by Abbott HMG »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #37 - Jan 13th, 2020 at 1:12pm
 
It migt be an idea to debug some of your own simple code. You have optimize core enabled so diving into or over core methods might be a bit suspect. The control of the debugger is 100% in vs's hands. The Microsoft MI debugger is included with Visual Studio. We just pass it some json instructions and it does the rest.

You can see the json we pass to it at the end of the verbose build output in the Micro Build output window.

Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #38 - Jan 15th, 2020 at 12:16am
 
As you suggested, I dumbed down my test solution.
It stops at the various breakpoint, once (as expected).
But the count++ after the delay(600) is never trapped. The system goes into an internal loop.
Stopping debugging takes a while and the com3 port is locked.
I have to remove the usb cable to start another session.
See below, plus test solution.
The screen shot is of when the endless loop occurs.
Am I using the wrong approach to debug?
Abbott
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #39 - Jan 15th, 2020 at 8:54pm
 
Before I continue, I think I should rethink gdb. My application is data intensive. It looks as if gdb goobles up too much memory for my json sring to cohabitate... and it puked on my large set of enums.
I'll go back to serial debugging for a bit and see if I can get any further there.
I may come back and test some basic modules with gdb.
When/if I have time after this project  I may put together notes about the experience and post them (??? where).
It has been an unwanted learning experience in a very time critical project.
Thanks
Abbott
You've been great with the support.
Back to top
 
 
IP Logged
 
Pages: 1 2 3 
Send Topic Print