aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2020-11-22 10:54:58 +0100
committerTom de Vries <tdevries@suse.de>2020-11-22 10:54:58 +0100
commit117c628d49309e3b6a8b11d492f497104f3e4b2c (patch)
tree4194be44158a6297599ed05d2350b87e70ac6ad8 /gdb
parent60b43650988db65e5d4ffc6053d6e37444e3752e (diff)
downloadfsf-binutils-gdb-117c628d49309e3b6a8b11d492f497104f3e4b2c.zip
fsf-binutils-gdb-117c628d49309e3b6a8b11d492f497104f3e4b2c.tar.gz
fsf-binutils-gdb-117c628d49309e3b6a8b11d492f497104f3e4b2c.tar.bz2
[gdb/testsuite] Add testcase for DW_AT_count referencing a variable
Clang describes the upper bounds of variable length arrays using a DW_AT_count attribute which references the DIE of a synthetic variable whose value is specified using a DW_AT_location. GDB handles these incorrectly if the corresponding DWARF expression finishes with a DW_OP_stack_value (PR26905). This commit adds a new kfailed test to gdb.dwarf2/count.exp with the same DWARF as that generated by Clang for gdb.base/vla-optimized-out.exp, one of the failing tests. Checked on Fedora 32 x86_64, with GCC and Clang. gdb/testsuite/ChangeLog: 2020-11-22 Gary Benson <gbenson@redhat.com> PR gdb/26905 * gdb.dwarf2/count.exp: Add test for an array whose upper bound is defined using a DW_AT_count which references another DIE.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.dwarf2/count.exp53
2 files changed, 58 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b89633f..91fc9e0 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-22 Gary Benson <gbenson@redhat.com>
+
+ PR gdb/26905
+ * gdb.dwarf2/count.exp: Add test for an array whose upper bound
+ is defined using a DW_AT_count which references another DIE.
+
2020-11-21 Tom de Vries <tdevries@suse.de>
* gdb.base/vla-ptr.exp: Add XFAIL.
diff --git a/gdb/testsuite/gdb.dwarf2/count.exp b/gdb/testsuite/gdb.dwarf2/count.exp
index 5cefb15..6dcccb5 100644
--- a/gdb/testsuite/gdb.dwarf2/count.exp
+++ b/gdb/testsuite/gdb.dwarf2/count.exp
@@ -28,7 +28,10 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {{language @DW_LANG_C99}} {
- declare_labels char_label array_label array_label2 static_array_label
+ declare_labels char_label \
+ array_size_type_label long_unsigned_int_label \
+ array_label array_label2 static_array_label \
+ vla_length_label vla_array_label
char_label: base_type {
{name char}
@@ -36,6 +39,18 @@ Dwarf::assemble $asm_file {
{byte_size 1 DW_FORM_sdata}
}
+ array_size_type_label: base_type {
+ {byte_size 8 DW_FORM_sdata}
+ {encoding @DW_ATE_unsigned}
+ {name __ARRAY_SIZE_TYPE__}
+ }
+
+ long_unsigned_int_label: base_type {
+ {byte_size 8 DW_FORM_sdata}
+ {encoding @DW_ATE_unsigned}
+ {name "long unsigned int"}
+ }
+
array_label: array_type {
{type :$char_label}
} {
@@ -63,6 +78,27 @@ Dwarf::assemble $asm_file {
}
}
+ vla_length_label:
+ DW_TAG_variable {
+ {location
+ {
+ lit6
+ stack_value
+ } SPECIAL_expr}
+ {name "__vla_array_length"}
+ {type :$long_unsigned_int_label}
+ {artificial 1 DW_FORM_flag_present}
+ }
+
+ vla_array_label: array_type {
+ {type :$char_label}
+ } {
+ subrange_type {
+ {type :$array_size_type_label}
+ {count :$vla_length_label}
+ }
+ }
+
DW_TAG_variable {
{name array2}
{type :$array_label2}
@@ -80,6 +116,12 @@ Dwarf::assemble $asm_file {
{type :$static_array_label}
{const_value world DW_FORM_block1}
}
+
+ DW_TAG_variable {
+ {name vla_array}
+ {type :$vla_array_label}
+ {const_value saluton DW_FORM_block1}
+ }
}
}
}
@@ -123,3 +165,12 @@ gdb_test "ptype static_array" "type = char \\\[5\\\]"
gdb_test "whatis static_array" "type = char \\\[5\\\]"
gdb_test "print static_array" " = \"world\""
gdb_test "print sizeof static_array" " = 5"
+
+setup_kfail "gdb/26905" *-*-*
+gdb_test "ptype vla_array" "type = char \\\[6\\\]"
+setup_kfail "gdb/26905" *-*-*
+gdb_test "whatis vla_array" "type = char \\\[6\\\]"
+setup_kfail "gdb/26905" *-*-*
+gdb_test "print vla_array" " = \"saluto\""
+setup_kfail "gdb/26905" *-*-*
+gdb_test "print sizeof vla_array" " = 6"