Sometimes you have an optimized build for whatever reason (say you’re doing a lot of profiling) but optimizations make non trivial debugging impossible. You don’t have an up to date build without optimization so you whine, start a non optimize build and start looking at bugzilla for 20 mins.
Frankenstein optimized/non optimized build to the rescue! Simply add:
MOZ_OPTIMIZE_FLAGS += -O0 -g
CXXFLAGS += -O0 -g
or for moz.build use:
MOZ_OPTIMIZE_FLAGS += ['-O0', '-g']
or for MSVC:
MOZ_OPTIMIZE_FLAGS += ['-Od']
to the Makefile for the module(s) you’re interested in debugging, for me it was gfx/layers/Makefile.in.
How does this work? Well optimizations are done at the object level and each object file are built to follow the ABI. As long as the ABI is followed, and it really really should, then you can expect this to work without any problems.
Disclaimer: This isn’t supported! If you have problems then do a clobber build.