don't know how others do but I find I have to recompile a program without optimization flags in order to be able to fully debug a live C++ program. Understandable but annoying.
This applies to any language with AOT compilation to native code. There are lots of optimizations that cannot be properly mapped back to the original source code.
In most languages compilers are allowed to do whatever they want as long as the semantic outcome stays the same.