New to Platformio Debugging help please

Im using Sparkfun Pro Micro with a very simple 2 lines of code to write to the Serial Monitor. It works fine just running it. But I get an exception in Debug , Have no idea why . Can some point me in the right direction.

Platform Ini

[env:sparkfun_promicro16]
platform = atmelavr
board = sparkfun_promicro16
framework = arduino
debug_tool = simavr

Code :

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
   Serial.println("Hello World!");
}

Running in Debug Mode I get

Reading symbols from c:\Users\Pete Rawlings\Documents\PlatformIO\Projects\Hello World\.pio\build\sparkfun_promicro16\firmware.elf...
done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = simavr
PlatformIO: Initializing remote target...
0x00000000 in __vectors ()
warning: Can not parse XML memory map; XML support was disabled at compile time
Temporary breakpoint 1 at 0xe76: file C:\Users\Pete Rawlings\.platformio\packages\framework-arduino-avr\cores\arduino/main.cpp, line 35.
Loading section .text, size 0x1138 lma 0x0
Loading section .data, size 0x36 lma 0x1138
Start address 0x0, load size 4462
Transfer rate: 1089 KB/sec, 185 bytes/write.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug

Temporary breakpoint
1, main () at C:\Users\Pete Rawlings\.platformio\packages\framework-arduino-avr\cores\arduino/main.cpp:35
35		init();

Breakpoint
2, setup () at src/main.cpp:5
5	   Serial.begin(9600);

Breakpoint
3, loop () at src/main.cpp:10
10	   Serial.println("Hello World!");
setWriteError () at C:\Users\Pete Rawlings\.platformio\packages\framework-arduino-avr\cores\arduino/Print.h:44
44	    void setWriteError(int err = 1) { write_error = err; }
Not implemented stop reason (assuming exception): undefined

Breakpoint
3, loop () at src/main.cpp:10
10	   Serial.println("Hello World!");
setWriteError () at C:\Users\Pete Rawlings\.platformio\packages\framework-arduino-avr\cores\arduino/Print.h:44
44	    void setWriteError(int err = 1) { write_error = err; }
Not implemented stop reason (assuming exception): undefined

Running normally works fine.

This is ATMega32U4 and Serial goes via USB, and that’s a very complex thing… The setWriteError() function is called when either the USB serial is not opened in a serial monitor (lineState == 0) or writing USB data fails.

So at the very least, SimAVR either has to emulate an opened USB serial or forward the created USB device to the host computer and you have to open the USB serial it created for it to advance.

USB support in simavr doesn’t seem to be in the very best state: USB Support Revisited - VHCI · Issue #286 · buserror/simavr · GitHub

The simplest way would be to change board = sparkfun_promicro16 to like board = uno for debugging / simple testing since that is UART based serial and works very well. Of course you wouldn’t have access to anything ATmega32u4 specific anymore. So going further, I’d recommend to open an issue at Issues · platformio/platform-atmelavr · GitHub which should then result in some investigation and possible an issue at Issues · buserror/simavr · GitHub.