How to disable compiler optimization for SITL debugging?

I am debugging the NavEKF2_core::updateFilterStatus function and when I attempt to view the value of any of the variables in this function I am seeing instead of a value. I am running sim_vehicle.py with the -D flag.
I came across the file ardupilot\build\c4che\sitl_cache.py which looks like it contains compiler related options used for when compiling most recent SITL build. Within this file the CXXFLAGS list appears to contain the flags used during compilation. I ran sim_vehicle.py with the -D flag and then viewed sitl_cache.py and see that the CXXFlags list contains the -O0 flag which I believe should not enable compiler optimizations.
Any ideas why I am encountering optimized code? Is sitl_cache.py indeed the compiler options that were used to compile the sitl? Thanks.