Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb error message: DW_OP_reg, DW_OP_piece, and DW_OP_bit_piece

I'm debugging somebody else's Qt program and ran into the following error message which I don't understand:

DWARF-2 expression error: DW_OP_reg operations must be used either alone or in
conjuction with DW_OP_piece or DW_OP_bit_piece.

I'm not sure what that means and Google isn't of much help.

Here's the context - sLocation is a QString that was declared a few lines earlier. However, it was created from functions which were inlined, so I'm not sure of its value and am attempting to check before being appended to:

(gdb) printqstring suffix
(QString)0xffffbd80: "sorted"
(gdb) next
1241        sLocation += suffix;
(gdb) printqstring sLocation
Can't take address of "sLocation" which isn't an lvalue.
(gdb) info local
sLocation = <error reading variable sLocation (DWARF-2 expression error:
    DW_OP_reg operations must be used either alone or in conjuction with
    DW_OP_piece or DW_OP_bit_piece.)>

Could somebody please explain what that error message means or what could cause it?

like image 208
Kaleb Pederson Avatar asked Sep 15 '10 19:09

Kaleb Pederson


2 Answers

The error message means that GDB is reading DWARF2 debug info from the executable, and is rejecting that info as invalid (not following the DWARF2 standard).

The invalid info is likely due to a bug in GCC, fixed in SVN revision 147187:

2009-05-06  Jakub Jelinek  <[email protected]>

    * dwarf2out.c (new_reg_loc_descr): Don't ever create DW_OP_regX.
    (one_reg_loc_descriptor): Create DW_OP_regX here instead of calling
    new_reg_loc_descr.
    (loc_by_reference): If loc is DW_OP_regX, change it into DW_OP_bregX 0
    instead of appending DW_OP_deref*.
like image 75
Employed Russian Avatar answered Sep 22 '22 14:09

Employed Russian


I got the same problem running a Ubuntu 10.10 64bit. However, the same code on a 10.04 LTS 32bit works perfectly.

Here is the version output of both setups Ubuntu 10.10:

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)

GCC on 10.04 LTS:

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5

Cheers, Andre

like image 33
Andre Avatar answered Sep 23 '22 14:09

Andre