gdb错误消息:DW_OP_reg,DW_OP_piece和DW_OP_bit_piece

时间:2010-09-15 19:28:01

标签: c++ debugging qt gdb

我正在调试其他人的Qt程序并遇到以下错误消息,我不明白:

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.

我不确定这意味着什么,谷歌没有多大帮助。

以下是上下文 - sLocationQString之前声明的几行。但是,它是从内联的函数创建的,所以我不确定它的值,并且在尝试检查之前被附加到:

(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.)>

有人可以解释一下该错误信息的含义或可能导致错误信息的原因吗?

2 个答案:

答案 0 :(得分:4)

错误消息表示GDB正在从可执行文件中读取DWARF2调试信息,并拒绝将该信息视为无效(不遵循DWARF2标准)。

无效信息可能是由于GCC中的错误,已在SVN修订版147187中修复:

2009-05-06  Jakub Jelinek  <jakub@redhat.com>

    * 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*.

答案 1 :(得分:1)

我遇到了运行Ubuntu 10.10 64bit的问题。但是,10.04 LTS 32bit上的相同代码可以很好地工作。

以下是两种设置的版本输出 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于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

干杯, 安德烈