My gdb version is 6.6, gcc version is 4.8. I know that
gcc -g by default uses dwarf-4 format, but gcc manual says that adding
-gdwarf-2 option can use older dwarf format. I tried it, but it is not ok. When I use gdb, it still reports:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2)
According to GCC 4.5 Release Notes you should use
-gdwarf-2 -gstrict-dwarf options to completely disable use of DWARF4 features:
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.