[SOLVED]Setup avr-stub for Nano

Hello everything, I discovered a library that help to debug the atmega328p and others, I installed the package in Pio, but it does not work. I followed the PDF document (as indicated in other posts) and did the test with the two cases of figures:
And :
In both cases it opens the launch.json file but I do not know what to get?
Any idea ?

So on what COM port is your Nano? Did you look in the device manager?

HELLO @maxgerhardt Port Com is 3, so to compile the code I put it on 13 in the PIO.ini file all is Ok. Then I put back to 3 then I start the debugger (Ctrl+Shift+D) with green Start then on Console this message :

Reading symbols from C:\Users\Utilisateur\Documents\PlatformIO\Projects\Debug_Blink\.pio\build\nanoatmega328new\firmware.elf...done.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = avr-stub
PlatformIO: Initializing remote target...
.pioinit:13: Error in sourced command file:
\\ .\COM3: No such file or directory.

There is a space there that shouldn’t be there. What’s the whole platformio.ini?

.ini files here :

platform = atmelavr
board = nanoatmega328new
framework = arduino
build_flags = 
debug_tool = avr-stub
debug_port = \\.\COM3
lib_deps = jdolinay/avr-debugger@^1.4

main.cpp :

#include <Arduino.h>
#include <avr8-stub.h>
//#include <app-api.h>   // Not working !

void setup() 
    // initialize the avr-debugger

void loop() 
    digitalWrite(LED_BUILTIN, HIGH); 
    digitalWrite(LED_BUILTIN, LOW); 

Hi, in addition when I start the Arduino IDE on Tools → Manage Libraries I get this message on Consol :
Invalid library found in C:\Program Files (x86)\Arduino\libraries\avr_debug: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\avr_debug.strong
Following the avr-debug pdf documentation on page 77 : To use the Arduino library just copy the avr-debugger folder into your folder with Arduino libraries – which on Windows is in Documents/Arduino/libraries. Then you should see the avr-debugger library in the Contributed libraries categories in your IDE.
It does not seem to be the case. :

Finally after many iterations I found a solution !
Into the platformio.ini file we need to place :
Using : debug_port = \ .\COM3 ==> NOT WORK ! :nauseated_face:
Same for : debug_port = \. \COM3 ==> NOT WORK ! :cold_face:
I put simply : ==> debug_port = COM3 :wink:

In addition we need to Add the file platform.local.txt into :
C:\Program Files (x86)\Arduino\hardware\arduino\avr

with this contents :

#Arduino AVR Core and platform.
#custom file for experiments with Arduino debugger avr-stub.
#turn off optimizations by -O0 instead of -Os (optimize for size)
#All other options are the same as in original platform.txt in Arduino IDE 1.8.9
compiler.c.flags=-c -g -O0 {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
compiler.cpp.flags=-c -g -O0 {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto

Note: This could disrupt the use of the standard Arduino IDE, so in this case, it must be renamed!