How to debug on Arduino mega 2560

Can you try adding

build_flags =  -DAVR8_BREAKPOINT_MODE=2

or

build_flags =  -DAVR8_BREAKPOINT_MODE=1

to the platformio.ini and retry?