Search code examples
linuxgccgdbg++

How to modify the DWARF version of G++ compiled debugging information


I'm compiling a library using g++, using following parameters:

g++ -gdwarf-2 
    -std=c++0x 
    -m32 
    -Dunix=1
    -Dlinux=1
    -D_JAVA=1
    -DNDEBUG=1
    -I...

Although I'm using specific DWARF version 2, the investigation of my core-file keeps on giving following error message:

Dwarf Error: wrong version in 
             compilation unit header
             (is 4, should be 2)

Does anybody know what I can do?

I'm working with following versions:

  • Platform version : `CentOS 5.2`
  • g++ version : `g++ (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52)`
  • gdb version : `GNU gdb Red Hat Linux (6.5-37.el5rh)`

    It is not possible to update the platform.

    For your information: meanwhile I've found this URL (http://www.delorie.com/gnu/docs/gdb/gdb_17.html), which explains that sometimes it might be a bad idea to mix debugging information with optimisation flags. As a result, I have removed the optimisation flag (although it was "-O0", and I have used "g++ -gdwarf-2 -g3" (as mentioned in the URL), but still no improvement.


  • Solution

  • Meanwhile I've solved the problem, by updating my GDB (and related) processes.