re PR debug/40659 (A simple struct member offset doesn't need a full dwarf location...
authorMark Wielaard <mjw@redhat.com>
Wed, 8 Jul 2009 18:07:47 +0000 (18:07 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Wed, 8 Jul 2009 18:07:47 +0000 (18:07 +0000)
2009-07-08  Mark Wielaard  <mjw@redhat.com>

PR debug/40659
* dwarf2out.c (add_data_member_location_attribute): When we have
only a constant offset don't emit a new location description using
DW_OP_plus_uconst, but just add the constant with add_AT_int, when
dwarf_version > 2.

From-SVN: r149377

gcc/ChangeLog
gcc/dwarf2out.c

index 47f8920..c78577a 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-08  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/40659
+       * dwarf2out.c (add_data_member_location_attribute): When we have
+       only a constant offset don't emit a new location description using
+       DW_OP_plus_uconst, but just add the constant with add_AT_int, when
+       dwarf_version > 2.
+
 2009-07-08  Richard Henderson  <rth@redhat.com>
 
        PR target/38900
index 01b534c..2e30a0c 100644 (file)
@@ -11475,22 +11475,31 @@ add_data_member_location_attribute (dw_die_ref die, tree decl)
 
   if (! loc_descr)
     {
-      enum dwarf_location_atom op;
-
-      /* The DWARF2 standard says that we should assume that the structure
-        address is already on the stack, so we can specify a structure field
-        address by using DW_OP_plus_uconst.  */
-
+      if (dwarf_version > 2)
+       {
+         /* Don't need to output a location expression, just the constant. */
+         add_AT_int (die, DW_AT_data_member_location, offset);
+         return;
+       }
+      else
+       {
+         enum dwarf_location_atom op;
+         
+         /* The DWARF2 standard says that we should assume that the structure
+            address is already on the stack, so we can specify a structure
+            field address by using DW_OP_plus_uconst.  */
+         
 #ifdef MIPS_DEBUGGING_INFO
-      /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst
-        operator correctly.  It works only if we leave the offset on the
-        stack.  */
-      op = DW_OP_constu;
+         /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst
+            operator correctly.  It works only if we leave the offset on the
+            stack.  */
+         op = DW_OP_constu;
 #else
-      op = DW_OP_plus_uconst;
+         op = DW_OP_plus_uconst;
 #endif
-
-      loc_descr = new_loc_descr (op, offset, 0);
+         
+         loc_descr = new_loc_descr (op, offset, 0);
+       }
     }
 
   add_AT_loc (die, DW_AT_data_member_location, loc_descr);