Debugging Mega2560 with GDB avr-stub and TWI / I2C devices

I am new to platformio, getting to debug now. I set platformio with the avr-stub and it appears to work fine, until I load a project that includes a ssd1306 display. While the project works fine when uploading the code (no debugging), in debugging always get stuck in the TWI initialization.

After I try to step out I get:

../../gdb/gdb/infrun.c:1986: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? 
(y or n) [answered Y; input not from terminal]
This is a bug, please report it.
  For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>

Any special settings I am not aware? Does anybody had experience with TWI, I2C, or even SPI debugging?

Can you check if this problem goes away when you use a newer avr-gcc / avr-gdb toolchain version?

Assuming you’re using Windows or Linux, you can

  1. download avr toolchain 14.1.0 at https://github.com/ZakKemble/avr-gcc-build/releases
  2. Unpack it to any folder (e.g., C:\Users\<user>\Desktop\new-toolchain)
  3. copy the file C:\Users\<user>\.platformio\packages\toolchain-atmelavr\package.json to the root of the unpacked folder
  4. Modify your platformio.ini to point to your new toolchain by adding the lines
platform_packages =
   toolchain-atmelavr@symlink://C:\Users\<user>\Desktop\new-toolchain
  1. Retry debugging

Thank you, but with this chain appears not to even to start debugging. I can compile ok. But on debugging I get:

========================= [SUCCESS] Took 14.48 seconds =========================
Reading symbols from C:\Users\RICKH\Downloads\pio\.pio\build\megaatmega2560\firmware.elf...
Dwarf Error: Could not find abbrev number 3752 in CU at offset 0x117af [in module C:\Users\RICKH\Downloads\pio\.pio\build\megaatmega2560\firmware.elf]
Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.
Use 'set mi-async'.

PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = avr-stub
PlatformIO: Initializing remote target...
.pioinit:13: Error in sourced command file:
Dwarf Error: Cannot find DIE at 0x193be referenced from DIE at 0x6f7a [in module C:\Users\RICKH\Downloads\pio\.pio\build\megaatmega2560\firmware.elf]

Then I also tried the last tool chain from Microchip 3.7 and the results are like the original with Platformio toolchain-atmelavr 1.7, debugs but gets stuck in the I2C initialization