views:

63

answers:

1

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?

+1  A: 

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*.
Employed Russian
With the help of somebody on IRC I was able to use `readelf -wi /path/to/debug/lib` to identify the offending entry: `2 byte block: 53 6 (DW_OP_reg3; DW_OP_deref).` However, I'm using gcc-4.4.4 which was tagged in r158895, so I think this may be a new or related bug.
Kaleb Pederson