Fix PR symtab/15391
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / implptrconst.exp
CommitLineData
b6807d98
TT
1# Copyright 2013 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
16load_lib dwarf.exp
17
18# This test can only be run on targets which support DWARF-2 and use gas.
19if {![dwarf2_support]} {
20 return 0
21}
22
23if { [skip_cplus_tests] } { continue }
24
25standard_testfile .c implptrconst-dw.S
26
27# Make some DWARF for the test.
28set asm_file [standard_output_file $srcfile2]
29Dwarf::assemble $asm_file {
55fb6d27
TT
30 # Creating a CU with 4-byte addresses lets this test link on both
31 # 32- and 64-bit machines.
6c9e2db4 32 cu { addr_size 4 } {
b6807d98
TT
33 compile_unit {} {
34 declare_labels byte_label size_type_label array_label
35 declare_labels var_label ptr_label
36
37 byte_label: base_type {
38 {name byte}
39 {encoding @DW_ATE_signed}
40 {byte_size 1 DW_FORM_sdata}
41 }
42
43 size_type_label: base_type {
44 {name sizetype}
45 {encoding @DW_ATE_unsigned}
55fb6d27 46 {byte_size 4 DW_FORM_sdata}
b6807d98
TT
47 }
48
49 array_label: array_type {
50 {type :$byte_label}
51 } {
52 subrange_type {
53 {type :$size_type_label}
54 {upper_bound 7 DW_FORM_data1}
55 }
56 }
57
58 var_label: DW_TAG_variable {
59 {name b}
60 {type :$array_label}
61 {const_value rstuvwxy DW_FORM_block1}
62 }
63
64 ptr_label: pointer_type {
55fb6d27 65 {byte_size 4 DW_FORM_sdata}
b6807d98
TT
66 {type :$byte_label}
67 }
68
69 DW_TAG_variable {
70 {name c}
71 {type :$ptr_label}
72 {location {
73 GNU_implicit_pointer $var_label 0
74 } SPECIAL_expr}
75 }
5bd1ef56
TT
76
77 DW_TAG_variable {
78 {name d}
79 {type :$ptr_label}
80 {location {
81 GNU_implicit_pointer $var_label 2
82 } SPECIAL_expr}
83 }
b6807d98
TT
84 }
85 }
86}
87
88if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
89 object {nodebug}] != ""} {
90 return -1
91}
92
93if {[gdb_compile $asm_file ${binfile}2.o object {nodebug}] != ""} {
94 return -1
95}
96
97if {[gdb_compile [list ${binfile}1.o ${binfile}2.o] \
98 "${binfile}" executable {}] != ""} {
99 return -1
100}
101
102# We need --readnow because otherwise we never read in the CU we
103# created above.
104set saved_gdbflags $GDBFLAGS
105set GDBFLAGS "$GDBFLAGS -readnow"
106clean_restart ${testfile}
107set GDBFLAGS $saved_gdbflags
108
109if ![runto_main] {
110 return -1
111}
112
113gdb_test "print *c" " = 114 'r'"
5bd1ef56 114gdb_test "print d\[-2\]" " = 114 'r'"
This page took 0.042882 seconds and 4 git commands to generate.