Debug in VSCode problem

My setup:

Our own PCB with nRF5340

Debugger = nRF5340 DK

macOS 13.2.1 (22D68)

Project with T2: Star topology, application is the manifest repository. The only external files used by project is Toolchain aka zephyr-sdk-0.15.2.

I have such a problem. Debug in VSCode doesn't work as it is supposed to.

(!) If I don't tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build I can debug but with stipulations. A part of my code is not accessible, probably it optiized, breakpoints are ignored and this code is never touched by the processor/compiler/system.

- How to workaround this? How not to optimize my code?

- + I have played with some config like DEBUG_OPTIMIZATION and NO_OPTIMIZATION, my code just can't be built.

- Why I even have a possibility to run Debug if  I didn't tick Enable debug options in Edit Build Configuratioin?

(!) If I tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build my program just runs as it would be run after Flashing (w/o Debug). But I have that DEBUG CONSOLE OUTPUT with some information so the last lines are:

Thread 4 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 3939856308]
There are even debug flow buttons. But they doesn' work, only Pause, Restart and Stop are available and Pause doesn't do nothing, Restart breaks everything so that even nRF5340 DK is not available anymore.
What's going on there?
Related