代码之家  ›  专栏  ›  技术社区  ›  Kaleb Pederson

gdb错误消息:dw_op_reg、dw_op_piece和dw_op_bit_piece

  •  5
  • Kaleb Pederson  · 技术社区  · 15 年前

    我正在调试其他人的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.
    

    我不知道这意味着什么,谷歌也没什么帮助。

    上下文如下- sLocation 是一个 QString 这是在几行之前宣布的。但是,它是从内联函数创建的,因此我不确定其值,并尝试在附加到以下函数之前进行检查:

    (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 回复  |  直到 13 年前
        1
  •  4
  •   Employed Russian    15 年前

    错误消息意味着 GDB 是阅读 DWARF2 调试可执行文件中的信息,并拒绝将该信息视为无效(不遵循 矮秆2 标准)。

    无效信息可能是由于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*.
    
        2
  •  1
  •   John Conde    13 年前

    我在运行Ubuntu10.10 64位时遇到了同样的问题。但是,10.04 LTS 32位上的相同代码工作得很好。

    这是两个设置的版本输出 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)
    

    10.04 LTS上的GCC:

    $ 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
    

    干杯, 安德烈