From patchwork Sat Jan 3 19:21:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4494 Received: (qmail 30521 invoked by alias); 3 Jan 2015 19:22:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 30506 invoked by uid 89); 3 Jan 2015 19:21:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f172.google.com Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 03 Jan 2015 19:21:56 +0000 Received: by mail-pd0-f172.google.com with SMTP id y13so25472441pdi.17 for ; Sat, 03 Jan 2015 11:21:54 -0800 (PST) X-Received: by 10.66.155.2 with SMTP id vs2mr131832219pab.135.1420312914690; Sat, 03 Jan 2015 11:21:54 -0800 (PST) Received: from sspiff.org (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id nv7sm49992381pbc.29.2015.01.03.11.21.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Jan 2015 11:21:53 -0800 (PST) Received: by sspiff.org (sSMTP sendmail emulation); Sat, 03 Jan 2015 11:21:03 -0800 From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] dwarf.exp: All numeric attributes require a form Date: Sat, 03 Jan 2015 11:21:03 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. As a followup to this patch: https://sourceware.org/ml/gdb-patches/2015-01/msg00020.html this patch flags as an error any numeric attribute that doesn't specify a form. And lo and behold I found more bugs. :-) Regression tested on amd64-linux. 2015-01-03 Doug Evans * lib/dwarf.exp (Dwarf): Flag an error if a numeric attribute value is given without an explicit form. * gdb.dwarf2/arr-subrange.exp: Specify forms for all numeric attributes. * gdb.dwarf/corrupt.exp: Ditto. * gdb.dwarf2/enum-type.exp: Ditto. * gdb.trace/entry-values.exp: Ditto. * gdb.trace/unavailable-dwarf-piece.exp: Ditto. diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index f44ecd7..8ea7a0f 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -225,7 +225,9 @@ proc function_range { func src } { # reference. The rest of VALUE is taken to be the name of a label, # and DW_FORM_ref4 is used. See 'new_label' and 'define_label'. # * Otherwise, VALUE is taken to be a string and DW_FORM_string is -# used. +# used. In order to prevent bugs where a numeric value is given but +# no form is specified, it is an error if the value looks like a number +# (using Tcl's "string is integer") and no form is provided. # More form-guessing functionality may be added. # # CHILDREN is just Tcl code that can be used to define child DIEs. It @@ -614,6 +616,10 @@ namespace eval Dwarf { if {[llength $attr] > 2} { set attr_form [lindex $attr 2] } else { + # If the value looks like an integer, a form is required. + if [string is integer $attr_value] { + error "Integer value requires a form" + } set attr_form [_guess_form $attr_value attr_value] } set attr_form [_map_name $attr_form _FORM] diff --git a/gdb/testsuite/gdb.dwarf2/arr-subrange.exp b/gdb/testsuite/gdb.dwarf2/arr-subrange.exp index 6aacb27..417ee44 100644 --- a/gdb/testsuite/gdb.dwarf2/arr-subrange.exp +++ b/gdb/testsuite/gdb.dwarf2/arr-subrange.exp @@ -29,8 +29,8 @@ Dwarf::assemble $asm_file { {DW_AT_language @DW_LANG_Ada95} {DW_AT_name foo.adb} {DW_AT_comp_dir /tmp} - {DW_AT_low_pc 0x1000} - {DW_AT_high_pc 0x2000} + {DW_AT_low_pc 0x1000 addr} + {DW_AT_high_pc 0x2000 addr} } { declare_labels boolean_label typedef_label array_label enum_label diff --git a/gdb/testsuite/gdb.dwarf2/corrupt.exp b/gdb/testsuite/gdb.dwarf2/corrupt.exp index a8558be..4e86f4a 100644 --- a/gdb/testsuite/gdb.dwarf2/corrupt.exp +++ b/gdb/testsuite/gdb.dwarf2/corrupt.exp @@ -38,25 +38,25 @@ Dwarf::assemble $asm_file { declare_labels int_label int_label: base_type { - {byte_size 4} + {byte_size 4 sdata} {name "int"} } enumeration_type { {name "ENUM"} - {byte_size 4} + {byte_size 4 sdata} } { enumerator { {name "A"} - {const_value 0} + {const_value 0 sdata} } enumerator { {name "B"} - {const_value 1} + {const_value 1 sdata} {sibling 12345678 DW_FORM_ref4} } { base_type { - {byte_size 1} + {byte_size 1 sdata} {name "char"} } } diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp index 48a9f0f..351e51f 100644 --- a/gdb/testsuite/gdb.dwarf2/enum-type.exp +++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp @@ -50,7 +50,7 @@ Dwarf::assemble $asm_file { } { DW_TAG_enumerator { {DW_AT_name ONE} - {DW_AT_const_value 1} + {DW_AT_const_value 1 DW_FORM_sdata} } } diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp index e812241..fa6e31b 100644 --- a/gdb/testsuite/gdb.trace/entry-values.exp +++ b/gdb/testsuite/gdb.trace/entry-values.exp @@ -88,7 +88,7 @@ Dwarf::assemble $asm_file { } foo_label: subprogram { - {decl_file 1} + {decl_file 1 sdata} {MACRO_AT_func { foo ${srcdir}/${subdir}/${srcfile} }} } { formal_parameter { @@ -105,10 +105,10 @@ Dwarf::assemble $asm_file { subprogram { {name bar} - {decl_file 1} + {decl_file 1 sdata} {low_pc $bar_start addr} {high_pc "$bar_start + $bar_length" addr} - {GNU_all_call_sites 1} + {GNU_all_call_sites 1 sdata} } { formal_parameter { {type :$int_label} diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp index 75b8bf5..17d3a14 100644 --- a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp +++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp @@ -44,8 +44,8 @@ Dwarf::assemble $asm_file { struct_s_label: DW_TAG_structure_type { {name s} {byte_size 3 DW_FORM_sdata} - {decl_file 1} - {decl_line 1} + {decl_file 1 DW_FORM_sdata} + {decl_line 1 DW_FORM_sdata} } { DW_TAG_member { {name a} @@ -73,8 +73,8 @@ Dwarf::assemble $asm_file { struct_t_label: DW_TAG_structure_type { {name t} {byte_size 3 DW_FORM_sdata} - {decl_file 1} - {decl_line 1} + {decl_file 1 DW_FORM_sdata} + {decl_line 1 DW_FORM_sdata} } { DW_TAG_member { {name a} @@ -174,7 +174,7 @@ Dwarf::assemble $asm_file { DW_TAG_subprogram { {name foo} - {decl_file 1} + {decl_file 1 sdata} {low_pc foo addr} {high_pc foo_end_lbl addr} } { @@ -219,7 +219,7 @@ Dwarf::assemble $asm_file { DW_TAG_subprogram { {name bar} - {decl_file 1} + {decl_file 1 sdata} {low_pc bar addr} {high_pc bar_end_lbl addr} } {