I had to build gcc with debug use and -g etc. for having the symbols in the backtraces BUT it still uses -O2 that is not debug friendly, please add support for -Og or -O0 sys-devel/gcc-5.4.0-r3::gentoo was built with the following: USE="cilk cxx debug fortran gcj go graphite hardened mpx nls nptl objc objc++ objc-gc openmp (pie) (ssp) vtv (-altivec) (-awt) -doc (-fixed-point) (-jit) (-libssp) (-multilib) -nopie -nossp -regression-test (-sanitize) -vanilla" RUBY_TARGETS="rbx" CFLAGS="-O2 -pipe -march=native -mtune=native -Wformat -Wformat-security -O2 -g2 -ggdb2 -fno-omit-frame-pointer -Wl,-O1 -Wl,--as-needed -Wl,-O2 -Wno-error=implicit-function-declaration" CXXFLAGS="-O2 -pipe -march=native -mtune=native -Wformat -Wformat-security -O2 -g2 -ggdb2 -fno-omit-frame-pointer -Wl,-O1 -Wl,--as-needed -Wl,-O2 -Wno-error=implicit-function-declaration"
This makes no sense, since the *code* changes with -O0... you end up debugging something different...