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:
CXXFLAGS += -O0 -g
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.