Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2013-2015 Free Software Foundation, Inc. |
5bd1ef56 TT |
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 | load_lib dwarf.exp | |
17 | ||
18 | # This test can only be run on targets which support DWARF-2 and use gas. | |
19 | if {![dwarf2_support]} { | |
20 | return 0 | |
21 | } | |
22 | ||
23 | if { [skip_cplus_tests] } { continue } | |
24 | ||
25 | standard_testfile main.c implptrpiece-dw.S | |
26 | ||
27 | # Make some DWARF for the test. | |
28 | set asm_file [standard_output_file $srcfile2] | |
29 | ||
30 | Dwarf::assemble $asm_file { | |
31 | # Using a funny address size here and in the pointer type lets us | |
32 | # also check for a sign-extension bug in the | |
33 | # DW_OP_GNU_implicit_pointer code. | |
34 | cu { addr_size 2 } { | |
35 | compile_unit {} { | |
36 | declare_labels struct_label short_type_label | |
37 | declare_labels char_type_label ptr_label | |
38 | declare_labels var_label | |
39 | ||
40 | struct_label: structure_type { | |
41 | {name S} | |
42 | {byte_size 4 DW_FORM_sdata} | |
43 | } { | |
44 | member { | |
45 | {name a} | |
46 | {type :$short_type_label} | |
47 | {data_member_location 0 DW_FORM_sdata} | |
48 | } | |
49 | member { | |
50 | {name b} | |
51 | {type :$char_type_label} | |
52 | {data_member_location 2 DW_FORM_sdata} | |
53 | } | |
54 | member { | |
55 | {name c} | |
56 | {type :$char_type_label} | |
57 | {data_member_location 3 DW_FORM_sdata} | |
58 | } | |
59 | } | |
60 | ||
61 | short_type_label: base_type { | |
62 | {name "short int"} | |
63 | {encoding @DW_ATE_signed} | |
64 | {byte_size 2 DW_FORM_sdata} | |
65 | } | |
66 | ||
67 | char_type_label: base_type { | |
68 | {name "signed char"} | |
69 | {encoding @DW_ATE_signed} | |
70 | {byte_size 1 DW_FORM_sdata} | |
71 | } | |
72 | ||
73 | # See comment above to understand the pointer size. | |
74 | ptr_label: pointer_type { | |
75 | {byte_size 2 DW_FORM_sdata} | |
76 | {type :$char_type_label} | |
77 | } | |
78 | ||
79 | var_label: DW_TAG_variable { | |
80 | {name s} | |
81 | {type :$struct_label} | |
82 | {location { | |
83 | const1u 1 | |
84 | stack_value | |
85 | piece 2 | |
86 | const1u 2 | |
87 | stack_value | |
88 | piece 1 | |
89 | const1u 3 | |
90 | stack_value | |
91 | piece 1 | |
92 | } SPECIAL_expr} | |
93 | } | |
94 | ||
95 | DW_TAG_variable { | |
96 | {name p} | |
97 | {type :$ptr_label} | |
98 | {location { | |
99 | GNU_implicit_pointer $var_label 2 | |
100 | } SPECIAL_expr} | |
101 | } | |
102 | } | |
103 | } | |
104 | } | |
105 | ||
e0c0f156 AA |
106 | if { [build_executable ${testfile}.exp ${testfile} \ |
107 | [list $srcfile $asm_file] {nodebug}] } { | |
5bd1ef56 TT |
108 | return -1 |
109 | } | |
110 | ||
111 | # We need --readnow because otherwise we never read in the CU we | |
112 | # created above. | |
113 | set saved_gdbflags $GDBFLAGS | |
114 | set GDBFLAGS "$GDBFLAGS -readnow" | |
115 | clean_restart ${testfile} | |
116 | set GDBFLAGS $saved_gdbflags | |
117 | ||
118 | if ![runto_main] { | |
119 | return -1 | |
120 | } | |
121 | ||
122 | gdb_test "print/d p\[-1\]" " = 0" |