1 # Copyright 2014-2019 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Tests to cover DW_AT_count attribute in subranges.
20 # Only run on targets which support dwarf and gas.
21 if { ![dwarf2_support] } {
25 standard_testfile main.c count.S
27 set asm_file [standard_output_file $srcfile2]
28 Dwarf::assemble $asm_file {
30 compile_unit {{language @DW_LANG_C99}} {
31 declare_labels char_label array_label array_label2 static_array_label
33 char_label: base_type {
35 {encoding @DW_ATE_signed}
36 {byte_size 1 DW_FORM_sdata}
39 array_label: array_type {
43 {count {DW_OP_lit5} SPECIAL_expr}
48 array_label2: array_type {
52 {count {DW_OP_lit1} SPECIAL_expr}
57 static_array_label: array_type {
61 {count 5 DW_FORM_sdata}
69 {const_value 65 DW_FORM_udata}
75 {const_value hello DW_FORM_block1}
80 {type :$static_array_label}
81 {const_value world DW_FORM_block1}
87 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
88 object {nodebug}] != "" } {
92 if { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
96 if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
97 "${binfile}" executable {}] != "" } {
102 set saved_gdbflags $GDBFLAGS
103 set GDBFLAGS [concat $GDBFLAGS " -readnow"]
104 clean_restart ${testfile}
105 set GDBFLAGS $saved_gdbflags
108 perror "couldn't run to main"
112 gdb_test "ptype array" "type = char \\\[5\\\]" "ptype array"
113 gdb_test "whatis array" "type = char \\\[5\\\]" "whatis array"
114 gdb_test "print array" " = \"hello\"" "print array"
115 gdb_test "print sizeof array" " = 5" "print sizeof array"
117 gdb_test "ptype array2" "type = char \\\[1\\\]" "ptype array"
118 gdb_test "whatis array2" "type = char \\\[1\\\]" "whatis array"
119 gdb_test "print array2" " = \"A\"" "print array"
120 gdb_test "print sizeof array2" " = 1" "print sizeof array"
122 gdb_test "ptype static_array" "type = char \\\[5\\\]" "ptype static_array"
123 gdb_test "whatis static_array" "type = char \\\[5\\\]" "whatis static_array"
124 gdb_test "print static_array" " = \"world\"" "print static_array"
125 gdb_test "print sizeof static_array" " = 5" "print sizeof static_array"