Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] Fix DW_AT_lower_bound DWARF-4+ defaults
Date: Thu, 26 Apr 2012 15:08:00 -0000	[thread overview]
Message-ID: <20120426150708.GA31687@host2.jankratochvil.net> (raw)

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)


             reply	other threads:[~2012-04-26 15:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 15:08 Jan Kratochvil [this message]
2012-04-26 16:09 ` Tom Tromey
2012-04-26 15:39   ` Jan Kratochvil
2012-04-26 15:55     ` Tom Tromey
2012-04-26 16:16       ` Jan Kratochvil
2012-04-26 20:35         ` [commit] " Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120426150708.GA31687@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox