VS Arduino
Visual Micro >> Hardware Debugging (GDB, GDB WiFi, GDB Stub) >> Error when building with avr_gdb library
https://www.visualmicro.com/forums/YaBB.pl?num=1576786986

Message started by Abbott HMG on Dec 19th, 2019 at 8:23pm

Title: Error when building with avr_gdb library
Post by Abbott HMG on Dec 19th, 2019 at 8:23pm
I'm back. I got Traffic_Light to work in debug. When I include avr_dbg in my sketch, I get the avr_ errors (I've attached a screen shot of includes & setup and a verbose log)

Thanks
Abbott


https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verboselog_001.txt ( 138 KB | 9 Downloads )
Capture_019.PNG ( 161 KB | 20 Downloads )

Title: Re: Error when building with avr-gdb library
Post by Visual Micro on Dec 19th, 2019 at 8:30pm
It is possible the interrupts code in your project conflicts with the interrupts used by the avr-gdb library.

Please try the GDBStub in a simple project to prove it is working for you.

Thanks

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Dec 20th, 2019 at 4:53pm
It works with Traffic_Light, although it throws an "Exception Unhandled" at the end of setup and then continues properly.
When I comment out the interrput related code, this is what I get - see screen and log.
Thanks
Abbott
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verboselog_002.txt ( 135 KB | 8 Downloads )
Capture_020.PNG ( 124 KB | 6 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Dec 20th, 2019 at 4:54pm
Here's the Traffic_Light error ...
Abbott
Capture2_004.PNG ( 120 KB | 6 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Dec 28th, 2019 at 2:15am
The full Maple Sap Pump project can be found at:
https://github.com/AbbottHMG/AduinoSolutions

The VS compile of my full project yields the errors in the attached png.
When I compile the sketch in the Arduino IDE the only  errors I get  are avg related:

Arduino: 1.8.10 Hourly Build 2019/04/02 05:33 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"


Code (]In file included from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:27:0,

                 from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/arduino.h:233,

                 from sketch\FlowMeter.h:7,

                 from sketch\FlowMeter.cpp:6:

c:\program files (x86)\arduinoide\hardware\tools\avr\avr\include\util\delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp):



# warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"

   ^

In file included from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:27:0,

                 from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,

                 from sketch\MaplePump.ino.cpp:1:

c:\program files (x86)\arduinoide\hardware\tools\avr\avr\include\util\delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]

# warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"

   ^

In file included from C:\Users\Abbott\Documents\Arduino\libraries\WiFi\src/WiFiServer.h:24:0,

                 from sketch\WebServer.h:17,

                 from C:\Users\Abbott\Documents\Arduino\Solutions\MaplePump\MaplePump.ino:36:

C:\Users\Abbott\Documents\Arduino\libraries\WiFi\src/utility/wl_definitions.h:42:0: warning: "MAX_SOCK_NUM" redefined

#define MAX_SOCK_NUM  4

^

In file included from sketch\WebServer.h:12:0,

                 from C:\Users\Abbott\Documents\Arduino\Solutions\MaplePump\MaplePump.ino:36:

C:\Users\Abbott\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:39:0: note: this is the location of the previous definition

#define MAX_SOCK_NUM 8

^

HardwareSerial0.cpp.o (symbol from plugin): In function `__vector_25':

(.text+0x0): multiple definition of `__vector_25'

libraries\avr-debugger\avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here

c:/program files (x86)/arduinoide/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

WInterrupts.c.o (symbol from plugin): In function `attachInterrupt':

(.text+0x0): multiple definition of `__vector_1'

libraries\avr-debugger\avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\Abbott\AppData\Local\Temp\ccniHOKR.ltrans19.ltrans.o: In function `save_regs1':

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\AppData\Local\Temp\ccniHOKR.ltrans19.ltrans.o:C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:2043: more undefined references to `regs' follow

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "SD.h"
Used: C:\Users\Abbott\Documents\Arduino\libraries\SD
Not used: C:\Program Files (x86)\ArduinoIDE\libraries\SD
Multiple libraries were found for "Ethernet.h"
Used: C:\Users\Abbott\Documents\Arduino\libraries\Ethernet
Not used: C:\Program Files (x86)\ArduinoIDE\libraries\Ethernet
Multiple libraries were found for "WiFiUdp.h"
Used: C:\Users\Abbott\Documents\Arduino\libraries\WiFi
Not used: C:\Program Files (x86)\ArduinoIDE\libraries\WiFi
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

AbgErrors.PNG ( 19 KB | 9 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on Dec 28th, 2019 at 1:15pm
Sorry we don't have time to assist with standard code syntax issues in this forum. Please use stackoverflow or the arduino forum where you will find the relevant experts.


Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Dec 29th, 2019 at 12:27am
There are no syntax errors. Without the avr debugger, included the application compiles clean and uploads. With the avr debugger included, the only errors are :
libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'
Who's responsible for avr-debugger issues?
Abbott

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on Dec 29th, 2019 at 1:35am
Reading the error again it appears to be saying that some sources can not work with optimization disabled. Is there any reason why you have disabled optimization? Was it based on a blog or expert advice? If so please post a link.

Thanks

ps: the lib is on git.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 2nd, 2020 at 1:22am
I set Default Optimization and for the .ino - Maximum Optimization (Favor Size) (/O1).
The avr8-stub.c regs errors still appear. I've attached the verbose log and screen image.
Thanks for continued follow-up.
Abbott
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verboselog_003.txt ( 3 KB | 6 Downloads )
With_Optimization_on.PNG ( 227 KB | 8 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on Jan 2nd, 2020 at 11:46am
Would it be possible to post or email us the solution as you have it currently on your machine, so we can investigate further more easily?


Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 2nd, 2020 at 9:27pm
You can find it at:
https://github.com/AbbottHMG/AduinoSolutions
If not, I'll zip it up and send it to you.

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on Jan 2nd, 2020 at 9:36pm
Thanks, if it is the MaplePump it looks like it is missing the .vcxproj files(s)

The GDbStub does not allow serial and does hog timer(s) so it might be a clash of libs. True hardware debug would then be the answer for lib debugging.

Anyway the vcxproj will allow is to replicate and possibly recommend workaround.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 3rd, 2020 at 11:48pm
Are these sufficient?
Also, I've disabled my timed interrupts. Should I also stub out the RTC Class?

Abbott
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vcxproj.zip ( 7 KB | 6 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on Jan 6th, 2020 at 12:59pm
Thanks for the Project files.

Performing the following steps allowed us to get the debugging running on the ATMega 2560 with GDBStub and the MaplePump project, but as the remaining hardware isn't connected we could only get into the LCD init...

The steps we took were:
Pulling the Git Repo, and merging the additional VCXProj files
Open SLN in Visual Micro (note missing files)
Ensure Deep Search Enabled
Remove references in Solution to the missing files noted on startup
Set board, Hardware Debug, GDB Stub options
Comment out all Serial and Interrupt code
Add AVR GDB Stub Library Reference in MaplePump.ino
Add debug_init(); to top of setup()
Add breakpoint as early as needed (above LCDInit() for our purposes)
Build & Upload, then Attach to process

As our breakpoint is so early and we attached it after startup, we had to reset the board after attaching the debugger to land on the breakpoint.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 6th, 2020 at 7:24pm
Thanks.
I'll be working on this tonight & tomorrow am.
You've been lots of help.

Some notes ...
I still get the undefined references to regs, even though they are defined static within the avr8-stub.c at line 550
Code (c++):

static unsigned char regs[GDB_NUMREGBYTES];      /* Copy of all registers */

and used throughout avr8-stub.c

except at line 1946 in:


Code (c++):

/* Note: The save and restore functions must be always inline,
otherwise the debug version will call these functions and
destroy the stack; The functions assume the stack is not touched.
*/
__attribute__((always_inline))
static inline void save_regs1 (void)
{
     /*  20-6-2017
      Nova verze, dle gdb.c co nejdrive zakazat preruseni */
     asm volatile (
                       "push      r0      \n"
                       "in            r0, __SREG__ \n"
                       "cli      \n"                  /* disable interrupts */
                       "sts regs+32, r0\n"      /* save SREG to its place */
                       "pop r0 \n"            /* restore r0 from stack */
                       "sts      regs+31, r31\n"            /* save R31 */
                       "sts      regs+30, r30\n"            /* save R30 */
                       "ldi      r31, hi8(regs)\n"      /* Z points to regs */
                       "ldi      r30, lo8(regs)\n"
                       "std      Z+29, r29\n");            /* save R29 */
                       /*"in      r29, __SREG__\n");*/      /* get SREG */

     /* Original verze, nebezpecna pokud se vola bez zakazanych preruseni, protoze
       ISR muze poskodit obsah registru r31, r30...
       Pro pouziti v ISR to neni problem, preruseni jsou zazakana ale pro breakpoint() by
       to mohlo delat problemy... */
#if 0
     asm volatile (
     "sts      regs+31, r31\n"            /* save R31 */
     "sts      regs+30, r30\n"            /* save R30 */
     "ldi      r31, hi8(regs)\n"      /* Z points to regs */
     "ldi      r30, lo8(regs)\n"
     "std      Z+29, r29\n"            /* save R29 */
     "in      r29, __SREG__\n");      /* get SREG */
#endif
}


As per your notes ...
I have no missing files in my solution
How do I enable Deep Search?
I've commented out all Serial references
When you refer to AVR GB Stub you mean avr8-stub..h

I've attached a zip of my entire solution

Abbott
VacuumPump_001.zip (Attachment deleted)

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on Jan 7th, 2020 at 10:50am
Thanks for the solution, and running it on my machine I don't see the same errors related to regs, and it is the correct GDB Stub we suggest.

The missing files were likely just on the version on git so a red-herring.

Deep Search was just to ensure the SPI Library is found correctly, and is enabled from vMicro > Compiler > Deep Search For Libraries.

Trying to build this for GDBStub still showed there is interrupt code active in the FlowMeter.cpp file, and once these are commented out (just attach and detach interrupt lines) the project builds without error.

As the GDBStub is embedded in the project we are definitely using the same one and same VS.

Just a note - If you change the Error List to be just "Build" instead of "Build + Intellisense" it will hide all non-critical errors.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 7th, 2020 at 8:26pm
Let me start by saying that I think there are gremlins in my DELL Precision.

Thanks. When I disabled the flowmeter attachInterrupt, the solution clean compiled, no errors, but the link failed. When I compiled again, the regs errors popped up. (I noticed an attachInterrupt in SPI.h). I compiled again after removing & adding back all libraries & classes using interrupts and got a clean compile...but no Link.
I've attached the verbose output of my last compile.
Might the Mega2560 board (ELEGOO) have any effect on the linking???

An aside: Has anyone built some scaffolding that would ignore attachInterrupt/detachInterrupt, etc. and Serial calls when in AVR-GDB debug mode. That would eliminate this type of stupid (me) user error and reduce commenting out lines.

Abbott
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verboselog_004.txt ( 268 KB | 4 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on Jan 7th, 2020 at 8:59pm
Glad to hear its moving forwards for you now.

There is a project option in Visual Micro for just this:
Project Properties (highlight project in Solution Explorer, Press F4)
"Micro General Current Configuration" section > "Configuration Define _DEBUG"
Set this to 1

Now in your code you can check for the _DEBUG definitions presence (or value), which will not be present when in Release Mode:
[code]// Only AttachInterrupt if not in Debug Configuration
#ifndef _DEBUG 
    attachInterrupt();
#endif  [/code]


Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 8th, 2020 at 1:10pm
Thanks ...
But the project still does not link, so I can not debug it.
I've attached the full project and my libraries directory. The  original verbose log is in in my prior response.
What's worse is that when I recompile, the reg errors pop up again.
If I do a Build->Clean the regs errors disappear????

The new verbose with reg errors is also attached.

Abbott :-[ :-[ :-[
Abbott

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=MaplePump_002.zip ( 17617 KB | 7 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verboselog-reg_001.txt ( 136 KB | 6 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on Jan 8th, 2020 at 1:41pm
Apologes, I think I had seen progress, and didn't acknowledge the linker error....

Can you confirm which version of the AVR Boards package you have installed? (shown in Visual Micro Explorer > Manage Boards)

The amended version of the maple project which compiles for me is attached for reference.
MaplePump_001.zip (Attachment deleted)

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 9th, 2020 at 4:01am
Version 1.6.23
AVR_Boards.PNG ( 34 KB | 1 Download )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on 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.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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 :-[ :)

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verbose_log.txt ( 277 KB | 3 Downloads )
AVR_Boards_001.PNG ( 36 KB | 1 Download )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on 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

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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
Debug1_003.PNG ( 108 KB | 7 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Simon Hopkinson on 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.



Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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
Debug2.PNG ( 107 KB | 19 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on 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.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on 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.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 11th, 2020 at 11:04am
I tried the simple example you supplied and it works.
I'll contact Jan Dolinay
Thanks
Abbott

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=verbose_log_001.txt ( 44 KB | 6 Downloads )
Debug3_001.PNG ( 107 KB | 2 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on 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.




Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=MaplePumpDebug2_001.zip ( 2047 KB | 1 Download )
1Debug1.PNG ( 84 KB | 16 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on 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.


Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=MaplePumpDebug2_002.zip ( 2051 KB | 2 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on 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.


Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=MaplePumpDebug2_003.zip ( 6 KB | 6 Downloads )
Debug1_004.PNG ( 178 KB | 8 Downloads )

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on 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.

Title: Re: Error when building with avr_gdb library
Post by Visual Micro on Jan 15th, 2020 at 9:53pm
Thanks that will be useful but I should add that Visual Micro doesn't have any rethinking to do. We just hook up what is there. Non of the microcontroller debugging is as perfect as windows debugging that is for sure.

The choice of debugger can vary the gdb experience a lot. Each has it's own strenghts. The only strenght of the gdbStub compared to real avr hardware debug is the fact that you don't need to buy a hardware debugger.

The difference in gsb also vararies dramatically for each type of micro controller. Furthermore, many micro controllers support a variety of different hardware debuggers and each hardware debugger has different strenghts and quirks.

All we can do with the current state of the market is to make everything work as much as it is capable of.

The serial debugging might seem weak from point of view of stepping or live variable watch but it support lots of trace points and because it uses standard arduino serial it is more robust and faster.

Sorry there isn't a perfect world but if you find one it would be good to hear about it. An Atmel ICE debugger might give you better results on the mega2560, it will use the ICSP port on the board instead of the serial and doesn't kill the processor in the same was as gdbstub.

Title: Re: Error when building with avr_gdb library
Post by Abbott HMG on Jan 17th, 2020 at 11:16pm
Went back to serial. Now it looks as if my handling of the strings used to populate json are giving me a problem.

Thanks
I'll stick with VisualMicro. Can't beat the support.
Abbott

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.