On 25 June 2012 17:15, Peter A. Felvegi wrote: > Hello, > > I found out while single stepping a new template function in gdb that gcc > generates bad/inaccurate line numbers in the debug info. Optimization was > turned off, but the execution jumped strangely, see below. gcc-4.4 and the > current clang produced the expected results, gcc 4.5, 4.6, 4.7, 4.8 all had > problems. The code was factored out from a proof-of-concept hack.
Which version of GDB? As documented at http://gcc.gnu.org/gcc-4.5/changes.html GCC now generates unwind info also for epilogues. DWARF debuginfo generated by GCC now uses more features of DWARF3 than before, and also some DWARF4 features. GDB older than 7.0 is not able to handle either of these, so to debug GCC 4.5 generated binaries or libraries GDB 7.0 or later is needed. You can disable use of DWARF4 features with the -gdwarf-3 -gstrict-dwarf options, or use -gdwarf-2 -gstrict-dwarf to restrict GCC to just DWARF2, but epilogue unwind info is emitted unconditionally whenever unwind info is emitted.