This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix DW_AT_lower_bound DWARF-4+ defaults


Hi,

with GCC defaults changed to DWARF-4 today
	http://gcc.gnu.org/viewcvs?view=revision&revision=186835

I have found GDB has the defaults for DW_AT_lower_bound in DWARF-4+
wrong/unimplemented.

As it is a large Ada regression I plan to check it in soon, it is also mostly
[obv]ious patch.

No regressions for DWARF 2, 3, 4 (4 both with and without .debug_types) on
{x86_64,x86_64-m32,i686}-fedora17-linux-gnu and also for x86_64,x86_64-m32
with gcc (GCC) 4.8.0 20120426 (experimental).


Thanks,
Jan


-FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small
+PASS: gdb.ada/array_return.exp: value printed by finish of Create_Small
-FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Large
+PASS: gdb.ada/array_return.exp: value printed by finish of Create_Large
-FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector
+PASS: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector
-FAIL: gdb.ada/arrayidx.exp: print one_two_three, indexes off
+PASS: gdb.ada/arrayidx.exp: print one_two_three, indexes off
-FAIL: gdb.ada/arrayidx.exp: print few_reps, indexes off
-FAIL: gdb.ada/arrayidx.exp: print many_reps, indexes off
-FAIL: gdb.ada/arrayidx.exp: print empty, indexes off
+PASS: gdb.ada/arrayidx.exp: print few_reps, indexes off
+PASS: gdb.ada/arrayidx.exp: print many_reps, indexes off
+PASS: gdb.ada/arrayidx.exp: print empty, indexes off
-FAIL: gdb.ada/arrayidx.exp: print one_two_three
+PASS: gdb.ada/arrayidx.exp: print one_two_three
-FAIL: gdb.ada/arrayidx.exp: print few_reps
-FAIL: gdb.ada/arrayidx.exp: print many_reps
-FAIL: gdb.ada/arrayidx.exp: print empty
+PASS: gdb.ada/arrayidx.exp: print few_reps
+PASS: gdb.ada/arrayidx.exp: print many_reps
+PASS: gdb.ada/arrayidx.exp: print empty
-FAIL: gdb.ada/arrayptr.exp: print arr_ptr (2)
-FAIL: gdb.ada/arrayptr.exp: print arr_ptr (3..4)
+PASS: gdb.ada/arrayptr.exp: print arr_ptr (2)
+PASS: gdb.ada/arrayptr.exp: print arr_ptr (3..4)
-FAIL: gdb.ada/homonym.exp: ptype local_type at BREAK_2
-FAIL: gdb.ada/homonym.exp: ptype local_type_subtype at BREAK_2
-FAIL: gdb.ada/homonym.exp: ptype lcl at BREAK_2
+PASS: gdb.ada/homonym.exp: ptype local_type at BREAK_2
+PASS: gdb.ada/homonym.exp: ptype local_type_subtype at BREAK_2
+PASS: gdb.ada/homonym.exp: ptype lcl at BREAK_2
-FAIL: gdb.ada/mod_from_name.exp: print xp
+PASS: gdb.ada/mod_from_name.exp: print xp
-FAIL: gdb.ada/null_array.exp: print my_matrix
+PASS: gdb.ada/null_array.exp: print my_matrix
-FAIL: gdb.ada/ptr_typedef.exp: print my_blob.bees(1)
+PASS: gdb.ada/ptr_typedef.exp: print my_blob.bees(1)
-FAIL: gdb.ada/rec_return.exp: print bar
+PASS: gdb.ada/rec_return.exp: print bar
-FAIL: gdb.ada/set_pckd_arr_elt.exp: continue to update_small
+PASS: gdb.ada/set_pckd_arr_elt.exp: continue to update_small
-FAIL: gdb.ada/str_ref_cmp.exp: print String_Var (1 .. 3) = "Hel"
+PASS: gdb.ada/str_ref_cmp.exp: print String_Var (1 .. 3) = "Hel"
-FAIL: gdb.ada/type_coercion.exp: p q
+PASS: gdb.ada/type_coercion.exp: p q
-FAIL: gdb.ada/type_coercion.exp: p q
+PASS: gdb.ada/type_coercion.exp: p q
-FAIL: gdb.ada/widewide.exp: print my_wws
-FAIL: gdb.ada/widewide.exp: print my_wws(1)
-FAIL: gdb.ada/widewide.exp: print my_wws(2)
+PASS: gdb.ada/widewide.exp: print my_wws
+PASS: gdb.ada/widewide.exp: print my_wws(1)
+PASS: gdb.ada/widewide.exp: print my_wws(2)


gdb/
2012-04-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix DW_AT_lower_bound defaults for DWARF-4+.
	* dwarf2read.c (read_subrange_type): Remove initialization of low and
	high.  Implement DWARF-4+ DW_AT_lower_bound defaults.  Print complaint
	for DW_AT_lower_bound with no default by the DWARF standard.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bd2d6f2..cfd12e5 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9086,8 +9086,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   struct type *base_type;
   struct type *range_type;
   struct attribute *attr;
-  LONGEST low = 0;
-  LONGEST high = -1;
+  LONGEST low, high;
   char *name;
   LONGEST negative_mask;
 
@@ -9100,18 +9099,47 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   if (range_type)
     return range_type;
 
-  if (cu->language == language_fortran)
-    {
-      /* FORTRAN implies a lower bound of 1, if not given.  */
-      low = 1;
-    }
-
   /* FIXME: For variable sized arrays either of these could be
      a variable rather than a constant value.  We'll allow it,
      but we don't know how to handle it.  */
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
   if (attr)
     low = dwarf2_get_attr_constant_value (attr, 0);
+  else
+    {
+      low = -1;
+      switch (cu->language)
+	{
+	case language_c:
+	case language_cplus:
+	  low = 0;
+	  break;
+	case language_fortran:
+	  low = 1;
+	  break;
+	case language_d:
+	case language_java:
+	case language_objc:
+	  if (cu->header.version >= 4)
+	    low = 0;
+	  break;
+	case language_ada:
+	case language_m2:
+	case language_pascal:
+	  if (cu->header.version >= 4)
+	    low = 1;
+	  break;
+	default:
+	  break;
+	}
+      if (low == -1)
+	{
+	  complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
+					    "- DIE at 0x%x [in module %s]"),
+		     die->offset.sect_off, cu->objfile->name);
+	  low = 0;
+	}
+    }
 
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
   if (attr)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]