From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6910 invoked by alias); 26 Apr 2012 15:07:35 -0000 Received: (qmail 6899 invoked by uid 22791); 26 Apr 2012 15:07:34 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_WW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Apr 2012 15:07:15 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3QF7EcW006933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 Apr 2012 11:07:14 -0400 Received: from host2.jankratochvil.net (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3QF792L016951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 26 Apr 2012 11:07:12 -0400 Date: Thu, 26 Apr 2012 15:08:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix DW_AT_lower_bound DWARF-4+ defaults Message-ID: <20120426150708.GA31687@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00915.txt.bz2 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 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)