Require numeric attributes to specify the form.
authorDoug Evans <xdje42@gmail.com>
Sun, 11 Jan 2015 23:45:43 +0000 (15:45 -0800)
committerDoug Evans <xdje42@gmail.com>
Sun, 11 Jan 2015 23:45:43 +0000 (15:45 -0800)
gdb/testsuite/ChangeLog:

* 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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/arr-subrange.exp
gdb/testsuite/gdb.dwarf2/corrupt.exp
gdb/testsuite/gdb.dwarf2/enum-type.exp
gdb/testsuite/gdb.trace/entry-values.exp
gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
gdb/testsuite/lib/dwarf.exp

index 4bcd4f594e927bc43f841388973c2d3d2a74fa04..6e967c7822ea6e6008c6421a7132d2ea88e7d83b 100644 (file)
@@ -1,3 +1,14 @@
+2015-01-11  Doug Evans  <xdje42@gmail.com>
+
+       * 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.
+
 2015-01-11  Doug Evans  <xdje42@gmail.com>
 
        PR gdb/15830
index 6aacb270e706f3391059bea35d22ad9045e334a0..417ee4430c4c6be8143cc33064930b7a452b0c6c 100644 (file)
@@ -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
 
index a8558be779cc1e18196bf5b89b851a50695e3281..4e86f4abc82fc2f8c3ee1b516ebd28713e04d47f 100644 (file)
@@ -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"}
                    }
                }
index 48a9f0fea4fc48561358a89b409c361d2a71ab1f..351e51f8ca6abc923855de62830d0d096be03b52 100644 (file)
@@ -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}
                }
            }
 
index 2548e89cceb136b687f2690770a39f68f2b061a5..0cf56151fc3a2e135f2102315ad0a9d0c378f0c7 100644 (file)
@@ -102,7 +102,7 @@ Dwarf::assemble $asm_file {
            }
 
            foo_label: subprogram {
-               {decl_file 1}
+               {decl_file 1 sdata}
                {MACRO_AT_func { foo ${srcdir}/${subdir}/${srcfile} }}
            } {
                formal_parameter {
@@ -119,10 +119,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}
index 75b8bf57166e6a11d8dd1bc06eb9ac68875ec205..17d3a140f14626d76d99a3dc7f460aca9f6b2737 100644 (file)
@@ -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}
            } {
index f44ecd7524c82d1b5aa4f8c9e3ded6007ae0b0cb..8ea7a0fdc42c5be2798673752c35e76f3cc55b7f 100644 (file)
@@ -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]