]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/count.exp
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / count.exp
1 # Copyright 2014-2015 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # Tests to cover DW_AT_count attribute in subranges.
17
18 load_lib dwarf.exp
19
20 # Only run on targets which support dwarf and gas.
21 if { ![dwarf2_support] } {
22 return 0
23 }
24
25 standard_testfile main.c count.S
26
27 set asm_file [standard_output_file $srcfile2]
28 Dwarf::assemble $asm_file {
29 cu {} {
30 compile_unit {{language @DW_LANG_C99}} {
31 declare_labels char_label array_label array_label2 static_array_label
32
33 char_label: base_type {
34 {name char}
35 {encoding @DW_ATE_signed}
36 {byte_size 1 DW_FORM_sdata}
37 }
38
39 array_label: array_type {
40 {type :$char_label}
41 } {
42 subrange_type {
43 {count {DW_OP_lit5} SPECIAL_expr}
44 {type :$char_label}
45 }
46 }
47
48 array_label2: array_type {
49 {type :$char_label}
50 } {
51 subrange_type {
52 {count {DW_OP_lit1} SPECIAL_expr}
53 {type :$char_label}
54 }
55 }
56
57 static_array_label: array_type {
58 {type :$char_label}
59 } {
60 subrange_type {
61 {count 5 DW_FORM_sdata}
62 {type :$char_label}
63 }
64 }
65
66 DW_TAG_variable {
67 {name array2}
68 {type :$array_label2}
69 {const_value 65 DW_FORM_udata}
70 }
71
72 DW_TAG_variable {
73 {name array}
74 {type :$array_label}
75 {const_value hello DW_FORM_block1}
76 }
77
78 DW_TAG_variable {
79 {name static_array}
80 {type :$static_array_label}
81 {const_value world DW_FORM_block1}
82 }
83 }
84 }
85 }
86
87 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
88 object {nodebug}] != "" } {
89 return -1
90 }
91
92 if { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
93 return -1
94 }
95
96 if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
97 "${binfile}" executable {}] != "" } {
98 return -1
99 }
100
101 global GDBFLAGS
102 set saved_gdbflags $GDBFLAGS
103 set GDBFLAGS [concat $GDBFLAGS " -readnow"]
104 clean_restart ${testfile}
105 set GDBFLAGS $saved_gdbflags
106
107 if ![runto_main] {
108 perror "couldn't run to main"
109 return -1
110 }
111
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"
116
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"
121
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"